Skip to content

Commit

Permalink
Fixing CSV intests
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 19, 2017
1 parent 7b91273 commit fac15ff
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 157 deletions.
Expand Up @@ -152,10 +152,11 @@ public void postInitSystem(Task initTask, OperationResult initResult) throws Exc

@Test
public void test010TestResourceBroken() throws Exception {
TestUtil.displayTestTile(this, "test010TestResourceBroken");
final String TEST_NAME = "test010TestResourceBroken";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test010TestResourceBroken");
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
Expand All @@ -168,10 +169,11 @@ public void test010TestResourceBroken() throws Exception {

@Test
public void test020GetResourceBroken() throws Exception {
TestUtil.displayTestTile(this, "test020GetResourceBroken");
final String TEST_NAME = "test020GetResourceBroken";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test020GetResourceBroken");
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
Expand All @@ -198,10 +200,11 @@ public void test030ListResources() throws Exception {

@Test
public void test100GetAccountMurray() throws Exception {
TestUtil.displayTestTile(this, "test100GetAccountMurray");
final String TEST_NAME = "test100GetAccountMurray";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test100GetAccountMurray");
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

try {
Expand All @@ -210,6 +213,7 @@ public void test100GetAccountMurray() throws Exception {
PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_CSVFILE_OID,
null, task, result);

display("Account (unexpected)", account);
AssertJUnit.fail("Expected SystemException but the operation was successful");
} catch (SystemException e) {
// This is expected
Expand All @@ -223,10 +227,11 @@ public void test100GetAccountMurray() throws Exception {

@Test
public void test101GetAccountMurrayNoFetch() throws Exception {
TestUtil.displayTestTile(this, "test101GetAccountMurrayNoFetch");
final String TEST_NAME = "test101GetAccountMurrayNoFetch";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test101GetAccountMurrayNoFetch");
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2013 Evolveum
~ 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.
Expand All @@ -26,7 +26,6 @@
<objectClass>ri:AccountObjectClass</objectClass>
<intent>default</intent>
<attributes>
<icfs:name>jack</icfs:name>
<icfs:uid>jack</icfs:uid>
<ri:username>jack</ri:username>
</attributes>
</account>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2013 Evolveum
~ 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.
Expand All @@ -19,14 +19,15 @@
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:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
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">
<name>jack</name>
<resourceRef oid="ef2bc95b-76e0-48e2-86d6-3d4f02d3bbbb"/>
<objectClass>ri:AccountObjectClass</objectClass>
<intent>default</intent>
<attributes>
<icfs:name>murray</icfs:name>
<icfs:uid>murray</icfs:uid>
<ri:username xsi:type="xsd:string">murray</ri:username>
</attributes>
</account>
4 changes: 2 additions & 2 deletions model/model-intest/src/test/resources/negative/broken.csv
@@ -1,3 +1,3 @@
"id","firstname","lastname","disabled","password"
"username","firstname","lastname","disabled","password"
"lechuck","Chuck","LeChuck",,"IllBEdamned"
"murray","this line is broken",,
"murray","this line is broken,,
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2014 Evolveum
~ 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.
Expand All @@ -26,40 +26,30 @@
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">


<!-- Resource name. It will be displayed in GUI. -->
<name>Localhost CSVfile Broken</name>

<!-- Reference to the ICF Flatfile connector. It contains a search filter that finds the right connector by connectorType. -->
<connectorRef type="ConnectorType">
<filter>
<q:equal>
<q:path>c:connectorType</q:path>
<q:value>com.evolveum.polygon.csvfile.CSVFileConnector</q:value>
<q:value>com.evolveum.polygon.connector.csv.CsvConnector</q:value>
</q:equal>
</filter>
</connectorRef>

<!-- Configuration section contains configuration of the connector,
such as hostnames and passwords -->
<connectorConfiguration>

<!-- Configuration specific for the CSVfile connector -->
<icfc:configurationProperties
xmlns:icfccsvfile="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csvfile/com.evolveum.polygon.csvfile.CSVFileConnector">
xmlns:icfccsvfile="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector">

<icfccsvfile:filePath>target/test/negative/broken.csv</icfccsvfile:filePath>
<icfccsvfile:encoding>utf-8</icfccsvfile:encoding>
<icfccsvfile:valueQualifier>"</icfccsvfile:valueQualifier>
<icfccsvfile:fieldDelimiter>,</icfccsvfile:fieldDelimiter>
<icfccsvfile:multivalueDelimiter>;</icfccsvfile:multivalueDelimiter>
<icfccsvfile:usingMultivalue>false</icfccsvfile:usingMultivalue>
<icfccsvfile:uniqueAttribute>id</icfccsvfile:uniqueAttribute>
<!-- <icfccsvfile:nameAttribute>id</icfccsvfile:nameAttribute> -->
<icfccsvfile:uniqueAttribute>username</icfccsvfile:uniqueAttribute>
<icfccsvfile:passwordAttribute>password</icfccsvfile:passwordAttribute>
</icfc:configurationProperties>

<!-- Generic ICF configuration -->

</connectorConfiguration>

Expand All @@ -75,28 +65,13 @@
-->
<schemaHandling>

<!-- Definition of default account type.
This is now the only account type that midPoint can work with. -->
<objectType>
<!-- Readable name for the account type -->
<displayName>Default Account</displayName>
<default>true</default>
<!-- Reference to the Resource Schema (see above) specifying
object class for this account type -->
<objectClass>ri:AccountObjectClass</objectClass>
<attribute>
<ref>icfs:uid</ref>

<!-- Readable name for the attribute. This will be used in GUI -->
<displayName>Entry UUID</displayName>

</attribute>
<attribute>
<ref>icfs:name</ref>

<!-- Readable name for the attribute. This will be used in GUI -->
<ref>ri:username</ref>
<displayName>Name</displayName>

<outbound>
<strength>weak</strength>
<source>
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2014 Evolveum
~ 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.
Expand All @@ -26,16 +26,13 @@
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">


<!-- Resource name. It will be displayed in GUI. -->
<name>Localhost CSVfile NotFound</name>

<!-- Reference to the ICF Flatfile connector. It contains a search filter that finds the right connector by connectorType. -->
<connectorRef type="ConnectorType">
<filter>
<q:equal>
<q:path>c:connectorType</q:path>
<q:value>com.evolveum.polygon.csvfile.CSVFileConnector</q:value>
<q:value>com.evolveum.polygon.connector.csv.CsvConnector</q:value>
</q:equal>
</filter>
</connectorRef>
Expand All @@ -46,15 +43,12 @@

<!-- Configuration specific for the CSVfile connector -->
<icfc:configurationProperties
xmlns:icfccsvfile="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csvfile/com.evolveum.polygon.csvfile.CSVFileConnector">
xmlns:icfccsvfile="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector">
<icfccsvfile:filePath>tH1s-F1le-d03s-nOt-3xist--it-i5-a-F1ct1ON</icfccsvfile:filePath>
<icfccsvfile:encoding>utf-8</icfccsvfile:encoding>
<icfccsvfile:valueQualifier>"</icfccsvfile:valueQualifier>
<icfccsvfile:fieldDelimiter>,</icfccsvfile:fieldDelimiter>
<icfccsvfile:multivalueDelimiter>;</icfccsvfile:multivalueDelimiter>
<icfccsvfile:usingMultivalue>false</icfccsvfile:usingMultivalue>
<icfccsvfile:uniqueAttribute>id</icfccsvfile:uniqueAttribute>
<!-- <icfccsvfile:nameAttribute>id</icfccsvfile:nameAttribute> -->
<icfccsvfile:uniqueAttribute>username</icfccsvfile:uniqueAttribute>
<icfccsvfile:passwordAttribute>password</icfccsvfile:passwordAttribute>
</icfc:configurationProperties>

Expand All @@ -77,21 +71,12 @@
<!-- Definition of default account type.
This is now the only account type that midPoint can work with. -->
<objectType>
<!-- Readable name for the account type -->
<displayName>Default Account</displayName>
<default>true</default>
<!-- Reference to the Resource Schema (see above) specifying
object class for this account type -->
<objectClass>ri:AccountObjectClass</objectClass>
<attribute>
<ref>icfs:uid</ref>
</attribute>
<attribute>
<ref>icfs:name</ref>

<!-- Readable name for the attribute. This will be used in GUI -->
<ref>ri:username</ref>
<displayName>Name</displayName>

<outbound>
<strength>weak</strength>
<source>
Expand Down
Expand Up @@ -19,68 +19,24 @@
*/
package com.evolveum.midpoint.provisioning.impl.csv;

import static com.evolveum.midpoint.test.IntegrationTestTools.display;
import static com.evolveum.midpoint.test.IntegrationTestTools.getAttributeValue;
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.util.List;

import javax.xml.namespace.QName;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
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.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.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;

import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.processor.ResourceSchemaImpl;
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.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.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.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.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;

/**
* The test of Provisioning service on the API level. The test is using CSV resource.
Expand Down

0 comments on commit fac15ff

Please sign in to comment.