-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-8842 ninja - lookuptable merger + test
- Loading branch information
Showing
6 changed files
with
174 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
...a/src/main/java/com/evolveum/midpoint/schema/merger/object/LookupTableMergeOperation.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,34 @@ | ||
/* | ||
* Copyright (C) 2010-2023 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.schema.merger.object; | ||
|
||
import com.evolveum.midpoint.schema.merger.BaseMergeOperation; | ||
import com.evolveum.midpoint.schema.merger.GenericItemMerger; | ||
import com.evolveum.midpoint.schema.merger.OriginMarker; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public class LookupTableMergeOperation extends BaseMergeOperation<LookupTableType> { | ||
|
||
public LookupTableMergeOperation( | ||
@NotNull LookupTableType target, | ||
@NotNull LookupTableType source) { | ||
|
||
super(target, | ||
source, | ||
new GenericItemMerger( | ||
OriginMarker.forOid(source.getOid(), SecurityPolicyType.COMPLEX_TYPE), | ||
createPathMap(Map.of( | ||
|
||
)))); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
infra/schema/src/test/java/com/evolveum/midpoint/schema/merger/TestMerger.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,42 @@ | ||
/* | ||
* Copyright (C) 2010-2023 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.schema.merger; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.schema.AbstractSchemaTest; | ||
import com.evolveum.midpoint.schema.merger.object.LookupTableMergeOperation; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
|
||
import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; | ||
|
||
public class TestMerger extends AbstractSchemaTest { | ||
|
||
private static final File TEST_ROOT_DIR = new File("./src/test/resources/merger"); | ||
|
||
@Test | ||
public void testLookupTableMergeOperation() throws Exception { | ||
PrismObject<LookupTableType> source = getPrismContext().parseObject(new File(TEST_ROOT_DIR, "lookup-table-source.xml")); | ||
PrismObject<LookupTableType> target = getPrismContext().parseObject(new File(TEST_ROOT_DIR, "lookup-table-target.xml")); | ||
PrismObject<LookupTableType> result = getPrismContext().parseObject(new File(TEST_ROOT_DIR, "lookup-table-result.xml")); | ||
|
||
LookupTableMergeOperation operation = new LookupTableMergeOperation(target.asObjectable(), source.asObjectable()); | ||
operation.execute(); | ||
|
||
System.out.println("Merged object:\n" + target.debugDump()); | ||
// TODO | ||
|
||
Assertions.assertThat(target) | ||
.matches(t -> t.equivalent(result)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
infra/schema/src/test/resources/merger/lookup-table-result.xml
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,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (C) 2010-2023 Evolveum and contributors | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<lookupTable oid="00000000-0000-0000-0000-000000000240" | ||
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'> | ||
|
||
<name>States</name> | ||
|
||
<row id="1"> | ||
<key>open</key> | ||
<label>Open</label> | ||
</row> | ||
<row id="2"> | ||
<key>closed</key> | ||
<label>Closed</label> | ||
</row> | ||
<row id="3"> | ||
<key>executing</key> | ||
<label>custom executing</label> | ||
</row> | ||
<row> | ||
<key>created</key> | ||
<label>Created</label> | ||
</row> | ||
<row> | ||
<key>closing</key> | ||
<label>Closing</label> | ||
</row> | ||
|
||
</lookupTable> |
32 changes: 32 additions & 0 deletions
32
infra/schema/src/test/resources/merger/lookup-table-source.xml
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2017 Evolveum, AMI Praha and contributors | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<lookupTable oid="00000000-0000-0000-0000-000000000240" | ||
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"> | ||
<name>States</name> | ||
<row id="1"> | ||
<key>created</key> | ||
<label>Created</label> | ||
</row> | ||
<row id="2"> | ||
<key>open</key> | ||
<label>Open</label> | ||
</row> | ||
<row id="3"> | ||
<key>closing</key> | ||
<label>Closing</label> | ||
</row> | ||
<row id="4"> | ||
<key>executing</key> | ||
<label>Executing</label> | ||
</row> | ||
<row id="5"> | ||
<key>closed</key> | ||
<label>Closed</label> | ||
</row> | ||
</lookupTable> |
27 changes: 27 additions & 0 deletions
27
infra/schema/src/test/resources/merger/lookup-table-target.xml
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2017 Evolveum, AMI Praha and contributors | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<lookupTable oid="00000000-0000-0000-0000-000000000240" | ||
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'> | ||
|
||
<name>States</name> | ||
|
||
<row id="1"> | ||
<key>open</key> | ||
<label>Open</label> | ||
</row> | ||
<row id="2"> | ||
<key>closed</key> | ||
<label>Closed</label> | ||
</row> | ||
<row id="3"> | ||
<key>executing</key> | ||
<label>custom executing</label> | ||
</row> | ||
|
||
</lookupTable> |