Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/datamodel-diagrams' into…
Browse files Browse the repository at this point in the history
… feature/datamodel-diagrams
  • Loading branch information
jmederly committed May 7, 2021
2 parents f47f5da + 202863f commit 8926586
Show file tree
Hide file tree
Showing 168 changed files with 5,732 additions and 3,492 deletions.
Expand Up @@ -9,6 +9,8 @@
import java.io.Serializable;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.wicket.AttributeModifier;
Expand Down Expand Up @@ -52,7 +54,11 @@ public void onInitialize(Component component) {
}

private void handleId(Component component) {
writeDataAttribute(component, ATTR_ID, component.getId());
if (component instanceof CaptchaPanel) {
writeDataAttribute(component, ATTR_ID, component.getId() + ((CaptchaPanel) component).getRandomText());
} else {
writeDataAttribute(component, ATTR_ID, component.getId());
}
}

private void writeDataAttribute(Component component, String key, String value) {
Expand Down
Expand Up @@ -9,9 +9,13 @@
import java.io.File;

import com.evolveum.midpoint.gui.api.component.MainObjectListPanel;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.web.AbstractGuiIntegrationTest;
import com.evolveum.midpoint.web.page.admin.configuration.PageSystemConfiguration;
import com.evolveum.midpoint.web.page.admin.server.PageTasks;

import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.javasimon.Split;
import org.javasimon.Stopwatch;
Expand Down Expand Up @@ -39,33 +43,34 @@
import com.evolveum.midpoint.web.page.self.PageSelfCredentials;
import com.evolveum.midpoint.web.page.self.PageSelfDashboard;
import com.evolveum.midpoint.web.page.self.PageUserSelfProfile;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationsPerformanceInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;

@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
//@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ActiveProfiles("test")
@SpringBootTest(classes = TestMidPointSpringApplication.class)
public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest implements PerformanceTestMethodMixin {
public class MidScaleGuiTest extends AbstractGuiIntegrationTest implements PerformanceTestMethodMixin {

private static final String TEST_DIR = "./src/test/resources/midScale";

private static final File FILE_ORG_STRUCT = new File(TEST_DIR, "org-struct.xml");
private static final File FILE_USERS = new File(TEST_DIR, "users.xml");
// private static final File FILE_ORG_STRUCT = new File(TEST_DIR, "org-struct.xml");
// private static final File FILE_USERS = new File(TEST_DIR, "users.xml");

private static final int REPETITION_COUNT = 10;

protected PrismObject<UserType> userAdministrator;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

importObjectsFromFileNotRaw(FILE_ORG_STRUCT, initTask, initResult);
initResult.computeStatusIfUnknown();
if (!initResult.isSuccess()) {
System.out.println("init result:\n" + initResult);
}
importObjectsFromFileNotRaw(FILE_USERS, initTask, initResult);
modelService.postInit(initResult);
userAdministrator = repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, initResult);
login(userAdministrator);

// importObjectsFromFileNotRaw(FILE_ORG_STRUCT, initTask, initResult);
// initResult.computeStatusIfUnknown();
// if (!initResult.isSuccess()) {
// System.out.println("init result:\n" + initResult);
// }
// importObjectsFromFileNotRaw(FILE_USERS, initTask, initResult);

modifyObjectReplaceProperty(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(),
ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_ENABLE_EXPERIMENTAL_FEATURES),
Expand Down
Expand Up @@ -8,40 +8,35 @@

import java.io.FileNotFoundException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.commons.lang.StringUtils;

import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;

import static java.util.Collections.*;

/**
* @author Radovan Semancik
* TODO Treat null attribute values more consistently.
*
* @author Radovan Semancik
*/
public abstract class DummyObject implements DebugDumpable {

private String id;
// private int internalId = -1;
private String name;
private Map<String,Set<Object>> attributes = new HashMap<>();
private final Map<String,Set<Object>> attributes = new ConcurrentHashMap<>();
private Boolean enabled = true;
private Date validFrom = null;
private Date validTo = null;
private String lastModifier;
protected DummyResource resource;

private final Set<String> auxiliaryObjectClassNames = new HashSet<>();
private final Set<String> auxiliaryObjectClassNames = ConcurrentHashMap.newKeySet();

private BreakMode modifyBreakMode = null;

Expand Down Expand Up @@ -80,33 +75,36 @@ public Boolean isEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public void setEnabled(Boolean enabled)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.enabled = enabled;
recordModify("_ENABLED", null, null, Arrays.asList(enabled));
recordModify("_ENABLED", null, null, singletonList(enabled));
}

public Date getValidFrom() {
return validFrom;
}

public void setValidFrom(Date validFrom) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public void setValidFrom(Date validFrom)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.validFrom = validFrom;
recordModify("_VALID_FROM", null, null, Arrays.asList(validFrom));
recordModify("_VALID_FROM", null, null, singletonList(validFrom));
}

public Date getValidTo() {
return validTo;
}

public void setValidTo(Date validTo) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public void setValidTo(Date validTo)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.validTo = validTo;
recordModify("_VALID_TO", null, null, Arrays.asList(validTo));
recordModify("_VALID_TO", null, null, singletonList(validTo));
}

public String getLastModifier() {
Expand All @@ -130,17 +128,17 @@ public Set<String> getAttributeNames() {
}

public <T> Set<T> getAttributeValues(String attrName, Class<T> type) {
Set<Object> values = attributes.get(attrName);
return (Set)values;
//noinspection unchecked
return (Set<T>) attributes.get(attrName);
}

public <T> T getAttributeValue(String attrName, Class<T> type) {
Set<T> values = getAttributeValues(attrName, type);
if (values == null || values.isEmpty()) {
return null;
}
if (values.size()>1) {
throw new IllegalArgumentException("Attempt to fetch single value from a multi-valued attribute "+attrName);
if (values.size() > 1) {
throw new IllegalArgumentException("Attempt to fetch single value from a multi-valued attribute " + attrName);
}
return values.iterator().next();
}
Expand All @@ -149,83 +147,95 @@ public String getAttributeValue(String attrName) {
return getAttributeValue(attrName,String.class);
}

public void replaceAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>(1);
values.add(value);
replaceAttributeValues(name, values);
public void replaceAttributeValue(String name, Object value)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
replaceAttributeValues(name, createCollection(value));
}

public void replaceAttributeValues(String name, Collection<Object> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
private Set<Object> createCollection(Object value) {
return value != null ? singleton(value) : emptySet();
}

public void replaceAttributeValues(String name, Collection<Object> values)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
if (currentValues == null) {
currentValues = new HashSet<>();
attributes.put(name, currentValues);
} else {
currentValues.clear();
}
currentValues.addAll(values);

Set<Object> currentValues = getOrCreateAttributeValueSet(name);
currentValues.clear();

addNonNullValues(currentValues, values);
checkSchema(name, values, "replace");
recordModify(name, null, null, values);
}

public void replaceAttributeValues(String name, Object... values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
private void addNonNullValues(Set<Object> currentValues, Collection<Object> values) {
for (Object value : values) {
if (value != null) {
currentValues.add(value);
}
}
}

private Set<Object> getOrCreateAttributeValueSet(String name) {
return attributes.computeIfAbsent(name, k -> ConcurrentHashMap.newKeySet());
}

public void replaceAttributeValues(String name, Object... values)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
if (currentValues == null) {
currentValues = new HashSet<>();
attributes.put(name, currentValues);
} else {
currentValues.clear();
}

Set<Object> currentValues = getOrCreateAttributeValueSet(name);
currentValues.clear();

List<Object> valuesList = Arrays.asList(values);
currentValues.addAll(valuesList);
addNonNullValues(currentValues, valuesList);
checkSchema(name, valuesList, "replace");

// Why isn't the same code in the "collection" version of this method (above)?
// Maybe to check null-attribute handling of UCF layer, see TestDummy.test129NullAttributeValue.
if (valuesList.isEmpty()) {
attributes.remove(name);
}
recordModify(name, null, null, Arrays.asList(values));
recordModify(name, null, null, valuesList);
}

public void addAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>(1);
values.add(value);
addAttributeValues(name, values);
public void addAttributeValue(String name, Object value)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
addAttributeValues(name, createCollection(value));
}

public <T> void addAttributeValues(String name, Collection<T> valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public <T> void addAttributeValues(String name, Collection<T> valuesToAdd)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
if (currentValues == null) {
currentValues = new HashSet<>();
attributes.put(name, currentValues);
}
for(T valueToAdd: valuesToAdd) {
Set<Object> currentValues = getOrCreateAttributeValueSet(name);
for (T valueToAdd: valuesToAdd) {
addAttributeValue(name, currentValues, valueToAdd);
}
recordModify(name, valuesToAdd, null, null);
}

public void addAttributeValues(String name, String... valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public void addAttributeValues(String name, String... valuesToAdd)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
if (currentValues == null) {
currentValues = new HashSet<>();
attributes.put(name, currentValues);
}
Set<Object> currentValues = getOrCreateAttributeValueSet(name);
for (Object valueToAdd: valuesToAdd) {
addAttributeValue(name, currentValues, valueToAdd);
}
recordModify(name, Arrays.asList(valuesToAdd), null, null);
}

private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();

if (valueToAdd == null) {
return; // Concurrent hash map does not allow null values.
}
if (resource != null && !resource.isTolerateDuplicateValues()) {
for (Object currentValue: currentValues) {
if (currentValue.equals(valueToAdd)) {
Expand Down Expand Up @@ -257,34 +267,29 @@ private void addAttributeValue(String attrName, Set<Object> currentValues, Objec
currentValues.add(valueToAdd);
}

public void removeAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>();
values.add(value);
removeAttributeValues(name, values);
public void removeAttributeValue(String name, Object value)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
removeAttributeValues(name, createCollection(value));
}

public <T> void removeAttributeValues(String name, Collection<T> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
public <T> void removeAttributeValues(String name, Collection<T> values)
throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
if (currentValues == null) {
currentValues = new HashSet<>();
attributes.put(name, currentValues);
}
Set<Object> currentValues = getOrCreateAttributeValueSet(name);

Set<Object> valuesToCheck = new HashSet<>();
valuesToCheck.addAll(currentValues);
Set<Object> valuesToCheck = new HashSet<>(currentValues);
valuesToCheck.removeAll(values);
checkSchema(name, valuesToCheck, "remove");

Iterator<Object> iterator = currentValues.iterator();
boolean foundMember = false;

if (name.equals(DummyGroup.ATTR_MEMBERS_NAME) && !resource.isTolerateDuplicateValues()){
if (name.equals(DummyGroup.ATTR_MEMBERS_NAME) && !resource.isTolerateDuplicateValues()) {
checkIfExist(values, currentValues);
}

while(iterator.hasNext()) {
while (iterator.hasNext()) {
Object currentValue = iterator.next();
boolean found = false;
for (Object value: values) {
Expand Down Expand Up @@ -351,7 +356,7 @@ private <T> void checkIfExist(Collection<T> valuesToDelete, Set<Object> currentV
}
}

if (!found){
if (!found) {
throw new SchemaViolationException("no such member: " + valueToDelete + " in " + currentValues);
}
}
Expand Down

0 comments on commit 8926586

Please sign in to comment.