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
KaterynaHonchar committed Dec 5, 2019
2 parents 12b848c + a8c5037 commit d5ef5c7
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Expand Up @@ -147,4 +147,17 @@ public boolean removeAll(Collection<?> objects) {
}
return changed;
}

@Override
public T set(int index, T element) {

if (index < 0 || index >= size()) {
throw new IndexOutOfBoundsException("Can't set object on position '"
+ index + "', list size is '" + size() + "'.");
}
Object propertyRealValue = JaxbTypeConverter.mapJaxbToPropertyRealValue(element);
getPropertyValue(index).setValue(propertyRealValue);

return element;
}
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2010-2019 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.prism;

import com.evolveum.midpoint.prism.foo.UserType;
import com.evolveum.midpoint.prism.impl.xjc.PropertyArrayList;
import com.evolveum.midpoint.util.DOMUtil;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

import java.io.File;
import java.io.IOException;

import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*;
import static org.testng.AssertJUnit.*;

public class TestPropertyArrayList {

public static final String USER_JACK_XXE_BASENAME = "user-jack-xxe";

private String getSubdirName() {
return "xml";
}

private String getFilenameSuffix() {
return "xml";
}

private File getCommonSubdir() {
return new File(COMMON_DIR_PATH, getSubdirName());
}

private File getFile(String baseName) {
return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix());
}

@Test
public void testPrismParseDom() throws Exception {
final String TEST_NAME = "testPrismParseDom";
PrismInternalTestUtil.displayTestTitle(TEST_NAME);

// GIVEN
Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME));
Element userElement = DOMUtil.getFirstChildElement(document);

PrismContext prismContext = constructInitializedPrismContext();

PrismObject<UserType> user = prismContext.parserFor(userElement).parse();
PrismProperty<String> property = user.findProperty(UserType.F_ADDITIONAL_NAMES);
PropertyArrayList<String> propertyArrayList = new PropertyArrayList<String>(property, user.getValue());

// WHEN
System.out.println("Additional names before test: " );
System.out.println(property.debugDump());
String testName = "test-name";
propertyArrayList.set(1, "test-name");

// THEN
System.out.println("Additional names after test: " );
System.out.println(property.debugDump());
assertEquals(testName, propertyArrayList.get(1));
}
}
1 change: 1 addition & 0 deletions infra/prism-impl/testng-unit.xml
Expand Up @@ -43,6 +43,7 @@
<class name="com.evolveum.midpoint.prism.query.TestQueryConverters"/>
<class name="com.evolveum.midpoint.prism.query.TestQueryBuilder"/>
<class name="com.evolveum.midpoint.prism.path.ItemPathTest"/>
<class name="com.evolveum.midpoint.prism.TestPropertyArrayList"/>
</classes>
</test>
</suite>

0 comments on commit d5ef5c7

Please sign in to comment.