Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first link-related tests (MID-6109)
Created experimental midpoint.findAssignee/findAssignees methods to make inter-object links navigation easier. Also introduced experimental AbstractEmptyModelIntegrationTest. Cleaning up display() calls when asserters are created. (We decided to call display() automatically only when creating asserters in known contexts like "before" and "after" some operation.)
- Loading branch information
Showing
21 changed files
with
622 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...t/src/test/java/com/evolveum/midpoint/model/intest/AbstractEmptyModelIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* 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.model.intest; | ||
|
||
import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.crypto.EncryptionException; | ||
import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance; | ||
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.util.annotation.Experimental; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Creates empty but functional environment for model integration tests - but without all the configured objects | ||
* in {@link AbstractConfiguredModelIntegrationTest}. | ||
* | ||
* Creates a repo with: | ||
* - empty system configuration | ||
* - administrator user (from common dir) | ||
* - superuser role (from common dir) | ||
*/ | ||
@Experimental | ||
public abstract class AbstractEmptyModelIntegrationTest extends AbstractModelIntegrationTest { | ||
|
||
private static final File SYSTEM_CONFIGURATION_EMPTY_FILE = new File(COMMON_DIR, "system-configuration-empty.xml"); | ||
|
||
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"; | ||
|
||
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 PrismObject<UserType> userAdministrator; | ||
|
||
@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<SystemConfigurationType> 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 File getSystemConfigurationFile() { | ||
return SYSTEM_CONFIGURATION_EMPTY_FILE; | ||
} | ||
|
||
// to be used in very specific cases only (it is invoked when getSystemConfigurationFile returns null). | ||
protected PrismObject<SystemConfigurationType> addSystemConfigurationObject(OperationResult initResult) | ||
throws IOException, CommonException, EncryptionException { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.