Skip to content

Commit

Permalink
Tests for read-modify mapping (MID-3661)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jan 13, 2017
1 parent 7717841 commit a46c9ab
Show file tree
Hide file tree
Showing 5 changed files with 505 additions and 63 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 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 Down Expand Up @@ -411,25 +411,25 @@ public Collection<DummyAccount> listAccounts() throws ConnectException, FileNotF
checkBlockOperations();
if (getBreakMode == BreakMode.NONE) {
return accounts.values();
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

Expand All @@ -439,25 +439,25 @@ private <T extends DummyObject> T getObjectByName(Map<String,T> map, String name
}
if (getBreakMode == BreakMode.NONE) {
return map.get(normalize(name));
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

Expand Down Expand Up @@ -487,25 +487,25 @@ private <T extends DummyObject> T getObjectById(Class<T> expectedClass, String i
throw new IllegalStateException("Arrrr! Wanted "+expectedClass+" with ID "+id+" but got "+dummyObject+" instead");
}
return (T)dummyObject;
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

Expand All @@ -529,77 +529,77 @@ public Collection<DummyGroup> listGroups() throws ConnectException, FileNotFound
checkBlockOperations();
if (getBreakMode == BreakMode.NONE) {
return groups.values();
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

public Collection<DummyPrivilege> listPrivileges() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
checkBlockOperations();
if (getBreakMode == BreakMode.NONE) {
return privileges.values();
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

public Collection<DummyOrg> listOrgs() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
checkBlockOperations();
if (getBreakMode == BreakMode.NONE) {
return orgs.values();
} else if (schemaBreakMode == BreakMode.NETWORK) {
} else if (getBreakMode == BreakMode.NETWORK) {
throw new ConnectException("Network error (simulated error)");
} else if (schemaBreakMode == BreakMode.IO) {
} else if (getBreakMode == BreakMode.IO) {
throw new FileNotFoundException("IO error (simulated error)");
} else if (schemaBreakMode == BreakMode.SCHEMA) {
} else if (getBreakMode == BreakMode.SCHEMA) {
throw new SchemaViolationException("Schema violation (simulated error)");
} else if (schemaBreakMode == BreakMode.CONFLICT) {
} else if (getBreakMode == BreakMode.CONFLICT) {
throw new ConflictException("Conflict (simulated error)");
} else if (schemaBreakMode == BreakMode.GENERIC) {
} else if (getBreakMode == BreakMode.GENERIC) {
// The connector will react with generic exception
throw new IllegalArgumentException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.RUNTIME) {
} else if (getBreakMode == BreakMode.RUNTIME) {
// The connector will just pass this up
throw new IllegalStateException("Generic error (simulated error)");
} else if (schemaBreakMode == BreakMode.UNSUPPORTED) {
} else if (getBreakMode == BreakMode.UNSUPPORTED) {
throw new UnsupportedOperationException("Not supported (simulated error)");
} else {
// This is a real error. Use this strange thing to make sure it passes up
throw new RuntimeException("Unknown schema break mode "+schemaBreakMode);
throw new RuntimeException("Unknown get break mode "+getBreakMode);
}
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 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 Down Expand Up @@ -60,6 +60,8 @@
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -908,4 +910,24 @@ public static String composeDnWithSuffix(Object... components) throws InvalidNam
return composeDn(components);
}

public static String debugDump(Object o) {
if (o == null) {
return "null";
}
if (o instanceof ObjectType) {
return DebugUtil.debugDump(((ObjectType)o).asPrismObject(), 0);
}
return DebugUtil.debugDump(o, 0);
}

public static String debugDump(Object o, int indent) {
if (o == null) {
return "null";
}
if (o instanceof ObjectType) {
return DebugUtil.debugDump(((ObjectType)o).asPrismObject(), indent);
}
return DebugUtil.debugDump(o, indent);
}

}
Expand Up @@ -309,6 +309,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444";
public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush";
public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood";
public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island";
public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml");
public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml");

Expand Down

0 comments on commit a46c9ab

Please sign in to comment.