Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed missing xsi:type for polymorphic (multivalued?) properties.
- Loading branch information
Showing
4 changed files
with
128 additions
and
8 deletions.
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
78 changes: 78 additions & 0 deletions
78
infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseWorkflowContext.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,78 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package com.evolveum.midpoint.schema.parser; | ||
|
||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.schema.SchemaConstantsGenerated; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingsType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfProcessEventType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemCompletionEventType; | ||
import org.testng.annotations.Test; | ||
|
||
import javax.xml.namespace.QName; | ||
import java.io.File; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
/** | ||
* TODO finish | ||
* @author mederly | ||
* | ||
*/ | ||
@SuppressWarnings({ "Convert2MethodRef", "Duplicates" }) | ||
public class TestParseWorkflowContext extends AbstractContainerValueParserTest<WfContextType> { | ||
|
||
@Override | ||
protected File getFile() { | ||
return getFile("wf-context"); | ||
} | ||
|
||
@Test | ||
public void testParseFile() throws Exception { | ||
displayTestTitle("testParseFile"); | ||
processParsings(null, null); | ||
} | ||
|
||
@Test | ||
public void testParseRoundTrip() throws Exception{ | ||
displayTestTitle("testParseRoundTrip"); | ||
|
||
//processParsings(v -> getPrismContext().serializerFor(language).serialize(v)); // no item name nor definition => cannot serialize | ||
processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); | ||
processParsings(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_USER).serialize(v), "s2"); // misleading item name | ||
processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeRealValue(v.asContainerable()), "s3"); | ||
processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); | ||
} | ||
|
||
private void processParsings(SerializingFunction<PrismContainerValue<WfContextType>> serializer, String serId) throws Exception { | ||
processParsings(WfContextType.class, null, WfContextType.COMPLEX_TYPE, null, serializer, serId); | ||
} | ||
|
||
@Override | ||
public void assertPrismContainerValueLocal(PrismContainerValue<WfContextType> value) throws SchemaException { | ||
WfContextType wfc = value.asContainerable(); | ||
assertEquals("Wrong # of events", 1, wfc.getEvent().size()); | ||
assertEquals("Wrong type of first event", WorkItemCompletionEventType.class, wfc.getEvent().get(0).getClass()); | ||
|
||
} | ||
|
||
@Override | ||
protected boolean isContainer() { | ||
return false; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
infra/schema/src/test/resources/common/xml/ns/wf-context.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,40 @@ | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<workflowContext 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" | ||
xsi:type="c:WfContextType"> | ||
<processInstanceId>1</processInstanceId> | ||
<processName>a</processName> | ||
<processInstanceName>b</processInstanceName> | ||
<event xsi:type="c:WorkItemCompletionEventType"> | ||
<timestamp>2017-02-03T15:59:40.015+01:00</timestamp> | ||
<initiatorRef oid="00000000-d34d-b33f-f00d-111111111111" type="c:UserType"> | ||
<targetName> | ||
<t:orig>test</t:orig> | ||
<t:norm>test</t:norm> | ||
</targetName> | ||
</initiatorRef> | ||
<stageNumber>1</stageNumber> | ||
<workItemId>116</workItemId> | ||
<result> | ||
<outcome>approve</outcome> | ||
<outcomeAsString>__APPROVED__</outcomeAsString> | ||
</result> | ||
</event> | ||
</workflowContext> |
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