Skip to content

Commit

Permalink
Start writing TestGrouper story test
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 5, 2019
1 parent 465e4d4 commit 6ea1933
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 0 deletions.
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2010-2019 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.testing.story;

import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.icf.dummy.resource.DummySyncStyle;
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.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.ResourceType;
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;

/**
*
*/
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestGrouper extends AbstractStoryTest {

public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "grouper");

protected static final File RESOURCE_GROUPER_FILE = new File(TEST_DIR, "resource-grouper.xml");
protected static final String RESOURCE_GROUPER_ID = "Grouper";
protected static final String RESOURCE_GROUPER_OID = "bbb9900a-b53d-4453-b60b-908725e3950e";

public static final File ORG_TOP_FILE = new File(TEST_DIR, "org-top.xml");
public static final String ORG_TOP_OID = "8fe3acc3-c689-4f77-9512-3d06b5d00dc2";

protected static DummyResource dummyResourceGrouper;
protected static DummyResourceContoller dummyResourceCtlGrouper;
protected ResourceType resourceDummyGrouperType;
protected PrismObject<ResourceType> resourceDummyGrouper;

@Override
protected String getTopOrgOid() {
return ORG_TOP_OID;
}

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

// Resources
dummyResourceCtlGrouper = DummyResourceContoller.create(RESOURCE_GROUPER_ID, resourceDummyGrouper);
dummyResourceGrouper = dummyResourceCtlGrouper.getDummyResource();
resourceDummyGrouper = importAndGetObjectFromFile(ResourceType.class, RESOURCE_GROUPER_FILE, RESOURCE_GROUPER_OID, initTask, initResult);
resourceDummyGrouperType = resourceDummyGrouper.asObjectable();
dummyResourceCtlGrouper.setResource(resourceDummyGrouper);
dummyResourceGrouper.setSyncStyle(DummySyncStyle.SMART);

// Org
importObjectFromFile(ORG_TOP_FILE, initResult);
}

@Test
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestGrouper.class.getName() + "." + TEST_NAME);

OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task);
TestUtil.assertSuccess(testResultGrouper);

dumpOrgTree();
}

}
25 changes: 25 additions & 0 deletions testing/story/src/test/resources/grouper/org-top.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ 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.
-->

<org oid="8fe3acc3-c689-4f77-9512-3d06b5d00dc2"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:org='http://midpoint.evolveum.com/xml/ns/public/common/org-3'>
<name>TOP</name>
<displayName>Top</displayName>
<identifier>0000</identifier>
<orgType>functional</orgType>
</org>
147 changes: 147 additions & 0 deletions testing/story/src/test/resources/grouper/resource-grouper.xml
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 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.
-->

<resource oid="bbb9900a-b53d-4453-b60b-908725e3950e"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/story/grouper/ext"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<name>Grouper Resource</name>
<connectorRef type="c:ConnectorType">
<filter>
<q:and>
<q:equal>
<q:path>connectorType</q:path>
<q:value>com.evolveum.icf.dummy.connector.DummyConnector</q:value>
</q:equal>
<q:equal>
<q:path>connectorVersion</q:path>
<q:value>2.0</q:value>
</q:equal>
</q:and>
</filter>
</connectorRef>
<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<icfc:configurationProperties>
<icfi:instanceId>Grouper</icfi:instanceId>
</icfc:configurationProperties>
</connectorConfiguration>

<schemaHandling>
<objectType>
<kind>account</kind>
<intent>subject</intent>
<objectClass>ri:AccountObjectClass</objectClass>
<default>true</default>
</objectType>
<objectType>
<kind>entitlement</kind>
<intent>group</intent>
<objectClass>ri:CustomprivilegeObjectClass</objectClass>
<default>true</default>
<attribute>
<ref>icfs:name</ref>
<inbound>
<target>
<path>name</path>
</target>
</inbound>
</attribute>
</objectType>
</schemaHandling>
<synchronization>
<objectSynchronization>
<enabled>true</enabled>
<kind>account</kind>
<intent>subject</intent>
<focusType>UserType</focusType>
<correlation>
<q:equal>
<q:path>name</q:path>
<expression>
<path>
$account/attributes/name
</path>
</expression>
</q:equal>
</correlation>
<reaction>
<situation>linked</situation>
<synchronize>true</synchronize>
</reaction>
<reaction>
<situation>deleted</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlink</handlerUri>
</action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
</action>
</reaction>
<reaction>
<situation>unmatched</situation>
</reaction>
</objectSynchronization>
<objectSynchronization>
<enabled>true</enabled>
<kind>entitlement</kind>
<intent>group</intent>
<focusType>OrgType</focusType>
<correlation>
<q:equal>
<q:path>name</q:path>
<expression>
<path>
$account/attributes/name
</path>
</expression>
</q:equal>
</correlation>
<reaction>
<situation>linked</situation>
<synchronize>true</synchronize>
</reaction>
<reaction>
<situation>deleted</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteFocus</handlerUri>
</action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
</action>
</reaction>
<reaction>
<situation>unmatched</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
</action>
</reaction>
</objectSynchronization>
</synchronization>
</resource>

0 comments on commit 6ea1933

Please sign in to comment.