Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 23, 2015
2 parents 8085f7a + 909fb42 commit 65cbe8a
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;
import org.w3c.dom.Element;

import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
Expand All @@ -40,9 +41,11 @@
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
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.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
Expand Down Expand Up @@ -250,12 +253,17 @@ public void test032ListAccountsDummyResource() throws Exception {
assertEquals("Unexpected number of accounts: "+accounts, 3, accounts.size());
}

/**
* Upgrading connector in RESOURCE_DUMMY_FAKE by changing the connectorRef in resource (add/delete case)
* The connectorRef is changed from fake to real dummy.
*/
@Test
public void test100UpgradeModelAddDelete() throws Exception {
TestUtil.displayTestTile(this, "test100UpgradeModelAddDelete");
final String TEST_NAME = "test100UpgradeModelAddDelete";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestMultiConnector.class.getName() + ".test100UpgradeModelAddDelete");
Task task = taskManager.createTaskInstance(TestMultiConnector.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
Expand All @@ -269,6 +277,9 @@ public void test100UpgradeModelAddDelete() throws Exception {
ReferenceDelta connectorRefDeltaAdd = ReferenceDelta.createModificationAdd(ResourceType.F_CONNECTOR_REF,
getResourceDefinition(), connectorDummyOid);
resourceDelta.addModification(connectorRefDeltaAdd);
// Purge the schema. New connector schema is not compatible.
resourceDelta.addModificationReplaceContainer(ResourceType.F_SCHEMA);
display("Delta", resourceDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);

// WHEN
Expand Down Expand Up @@ -514,6 +525,8 @@ private void assertUpgrade(PrismObject<ResourceType> dummyResourceModelBefore) t
// Check if resource view of the model has changed as well
resourceDummyFake = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_FAKE_OID, null, task, result);
display("Upgraded fake resource (model)", resourceDummyFake);
Element resourceDummyFakeSchemaElement = ResourceTypeUtil.getResourceXsdSchema(resourceDummyFake);
display("Upgraded fake resource schema (model)", DOMUtil.serializeDOMToString(resourceDummyFakeSchemaElement));
assertNotNull("Null fake resource after getObject (model)", resourceDummyFake);
assertEquals("Oooops. The OID of fake resource mysteriously changed. Call the police! (model)", RESOURCE_DUMMY_FAKE_OID, resourceDummyFake.getOid());
assertEquals("Wrong connectorRef in fake resource (model)", connectorDummyOid,
Expand Down
53 changes: 53 additions & 0 deletions samples/objects/lookup-employee-type.xml
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 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.
-->

<lookupTable oid="5783c174-d141-11e4-bb29-001e8c717e5b"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:piracy='http://midpoint.evolveum.com/xml/ns/samples/piracy'>

<name>Employee Type</name>

<table>
<key>FTE</key>
<label>Full-time employee</label>
</table>
<table>
<key>PTE</key>
<label>Part-time employee</label>
</table>
<table>
<key>TE</key>
<label>Temporary employee</label>
</table>
<table>
<key>C</key>
<label>Contractor</label>
</table>
<table>
<key>S</key>
<label>Serviceperson</label>
</table>
<table>
<key>O</key>
<label>Other</label>
</table>

</lookupTable>
37 changes: 37 additions & 0 deletions samples/objects/object-template-user-structured.xml
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 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.
-->

<objectTemplate oid="f76b29d4-d141-11e4-8359-001e8c717e5b"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/story/orgsync/ext">
<name>User Template (structured)</name>

<description>
User template that defines some structured attributes.
This is mostly used by the user interface.
</description>

<item>
<ref>employeeType</ref>
<valueEnumerationRef oid="5783c174-d141-11e4-bb29-001e8c717e5b"/>
</item>

</objectTemplate>

0 comments on commit 65cbe8a

Please sign in to comment.