Skip to content

Commit

Permalink
Attempts to reproduce MID-5114
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Feb 27, 2019
1 parent 2f0338e commit 7fbc331
Show file tree
Hide file tree
Showing 11 changed files with 812 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.match.MatchingRule;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.util.PrismUtil;
import com.evolveum.midpoint.schema.SearchResultList;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
Expand Down Expand Up @@ -72,6 +73,10 @@ public class AbstractStoryTest extends AbstractModelIntegrationTest {

protected static final File TASK_VALIDITY_SCANNER_FILE = new File(COMMON_DIR, "task-validity-scanner.xml");
protected static final String TASK_VALIDITY_SCANNER_OID = "00000000-0000-0000-0000-000000000006";

protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy";
protected static final QName PIRACY_SHIP_QNAME = new QName(NS_PIRACY, "ship");
protected static final ItemPath PATH_EXTENSION_SHIP = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_SHIP_QNAME);

protected MatchingRule<String> caseIgnoreMatchingRule;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017 mythoss, Evolveum
* Copyright (c) 2016-2019 mythoss, Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -79,8 +79,6 @@ public class TestNullAttribute extends AbstractStoryTest {
public static final File USER_SMACK_FILE = new File(TEST_DIR, "user-smack.xml");
public static final String USER_SMACK_OID = "c0c010c0-d34d-b33f-f00d-111111111112";

protected static final String EXTENSION_NS = "http://midpoint.evolveum.com/xml/ns/samples/piracy";

@Autowired private ReconciliationTaskHandler reconciliationTaskHandler;

protected static DummyResource dummyResource;
Expand Down Expand Up @@ -145,7 +143,7 @@ public void test000Sanity() throws Exception {
PrismContainerDefinition<?> userExtensionDef = userDefinition.getExtensionDefinition();
display("User extension definition", userExtensionDef);
PrismAsserts.assertPropertyDefinition(userExtensionDef,
new QName(EXTENSION_NS, "ship"), DOMUtil.XSD_STRING, 0, 1);
new QName(NS_PIRACY, "ship"), DOMUtil.XSD_STRING, 0, 1);


}
Expand Down Expand Up @@ -216,7 +214,7 @@ public void test020UserSmackSetAttribute() throws Exception {
@SuppressWarnings("unchecked, raw")
Collection<ObjectDelta<? extends ObjectType>> deltas =
(Collection) prismContext.deltaFor(UserType.class)
.item(UserType.F_EXTENSION, new QName(EXTENSION_NS, "ship")).add("Black Pearl")
.item(UserType.F_EXTENSION, new QName(NS_PIRACY, "ship")).add("Black Pearl")
.asObjectDeltas(USER_SMACK_OID);
modelService.executeChanges(deltas, null, task, result);

Expand Down Expand Up @@ -270,7 +268,7 @@ public void test030UserSmackRemoveAttribute() throws Exception {
prismContext.adopt(userNewPrism);
if (userNewPrism.getExtension()==null)userNewPrism.createExtension();
PrismContainer<?> ext = userNewPrism.getExtension();
ext.setPropertyRealValue(new QName(EXTENSION_NS, "ship"), null);
ext.setPropertyRealValue(PIRACY_SHIP_QNAME, null);

ObjectDelta<UserType> delta = userBefore.diff(userNewPrism);
display("Modifying user with delta", delta);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.evolveum.midpoint.testing.story.uuid;
/*
* Copyright (c) 2014-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.
*/

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;

import java.io.File;

import static org.testng.AssertJUnit.assertEquals;

/**
* @author Radovan Semancik
*
*/
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class })
public abstract class AbstractUuidTest extends AbstractStoryTest {

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

public static final File OBJECT_TEMPLATE_USER_FILE = new File(TEST_DIR, "object-template-user.xml");
public static final String OBJECT_TEMPLATE_USER_OID = "10000000-0000-0000-0000-000000000222";

protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003";
protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI;

protected static final String ATTR_ROOM_NUMBER = "roomNumber";
protected static final String ATTR_MOBILE = "mobile";
protected static final String ATTR_DEPARTMENT_NUMBER = "departmentNumber";

protected ResourceType resourceOpenDjType;
protected PrismObject<ResourceType> resourceOpenDj;

protected String userRappOid;
protected String userMancombOid;

@Override
protected void startResources() throws Exception {
openDJController.startCleanServer();
}

@AfterClass
public static void stopResources() throws Exception {
openDJController.stop();
}

@Override
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();
openDJController.setResource(resourceOpenDj);

// Object Templates
importObjectFromFile(OBJECT_TEMPLATE_USER_FILE, initResult);

}

protected abstract File getResourceOpenDjFile();

@Override
protected File getSystemConfigurationFile() {
return SYSTEM_CONFIGURATION_FILE;
}

@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);
TestUtil.assertSuccess(testResultOpenDj);

waitForTaskStart(TASK_TRIGGER_SCANNER_OID, true);
waitForTaskStart(TASK_VALIDITY_SCANNER_OID, true);
}

}
Loading

0 comments on commit 7fbc331

Please sign in to comment.