-
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.
Wired simulation result manager to tests
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
- Loading branch information
1 parent
9b296bb
commit 746da07
Showing
8 changed files
with
182 additions
and
18 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
9 changes: 9 additions & 0 deletions
9
...api/src/main/java/com/evolveum/midpoint/model/api/simulation/SimulationResultContext.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,9 @@ | ||
package com.evolveum.midpoint.model.api.simulation; | ||
|
||
import com.evolveum.midpoint.task.api.ObjectProcessingListener; | ||
|
||
public interface SimulationResultContext { | ||
|
||
ObjectProcessingListener objectProcessingListener(); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...api/src/main/java/com/evolveum/midpoint/model/api/simulation/SimulationResultManager.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
78 changes: 78 additions & 0 deletions
78
...rc/main/java/com/evolveum/midpoint/model/impl/simulation/SimulationResultContextImpl.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 @@ | ||
package com.evolveum.midpoint.model.impl.simulation; | ||
|
||
import java.util.Map; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import com.evolveum.midpoint.model.api.simulation.SimulationResultContext; | ||
import com.evolveum.midpoint.prism.PrismContainerValue; | ||
import com.evolveum.midpoint.prism.PrismContext; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.delta.ChangeType; | ||
import com.evolveum.midpoint.prism.delta.ObjectDelta; | ||
import com.evolveum.midpoint.prism.polystring.PolyString; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.ObjectProcessingListener; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectProcessingStateType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultType; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
public class SimulationResultContextImpl implements SimulationResultContext, ObjectProcessingListener { | ||
|
||
private @NotNull String oid; | ||
private @NotNull SimulationResultManagerImpl manager; | ||
private @Nullable SimulationResultType configuration; | ||
|
||
private static final Map<ChangeType, ObjectProcessingStateType> DELTA_TO_PROCESSING_STATE = new ImmutableMap.Builder<ChangeType, ObjectProcessingStateType>() | ||
.put(ChangeType.ADD, ObjectProcessingStateType.ADDED) | ||
.put(ChangeType.DELETE, ObjectProcessingStateType.DELETED) | ||
.put(ChangeType.MODIFY, ObjectProcessingStateType.MODIFIED) | ||
.build(); | ||
|
||
public SimulationResultContextImpl(SimulationResultManagerImpl manager, @NotNull String storedOid, @Nullable SimulationResultType configuration) { | ||
this.manager = manager; | ||
this.oid = storedOid; | ||
this.configuration = configuration; | ||
} | ||
|
||
@Override | ||
public void onChangeExecuted(@NotNull ObjectDelta<?> delta, boolean executed, @NotNull OperationResult result) { | ||
// | ||
SimulationResultProcessedObjectType processedObject = createProcessedObject(delta); | ||
manager.storeProcessedObject(oid, processedObject, result); | ||
|
||
} | ||
|
||
private SimulationResultProcessedObjectType createProcessedObject(@NotNull ObjectDelta<?> delta) { | ||
SimulationResultProcessedObjectType processedObject = new SimulationResultProcessedObjectType(); | ||
processedObject.setOid(delta.getOid()); | ||
// TODO fill up name | ||
|
||
processedObject.setState(DELTA_TO_PROCESSING_STATE.get(delta.getChangeType())); | ||
processedObject.setType(toQName(delta.getObjectTypeClass())); | ||
|
||
PrismContainerValue<SimulationResultProcessedObjectType> pcv = processedObject.asPrismContainerValue(); | ||
if (delta.isAdd()) { | ||
PrismObject<?> objectToAdd = delta.getObjectToAdd(); | ||
processedObject.setName(PolyString.toPolyStringType(objectToAdd.getName())); | ||
//pcv.findOrCreateContainer(containerName) | ||
} else if (delta.isDelete()) { | ||
// TODO: Fill up before state | ||
} | ||
return processedObject; | ||
} | ||
|
||
@Override | ||
public ObjectProcessingListener objectProcessingListener() { | ||
return this; | ||
} | ||
|
||
private QName toQName(Class<?> objectTypeClass) { | ||
return PrismContext.get().getSchemaRegistry().determineTypeForClass(objectTypeClass); | ||
} | ||
|
||
} |
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
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
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
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