Skip to content

Commit

Permalink
repo-sqale + common tests: deprecated usage of const with prismCtx fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Mar 7, 2022
1 parent ac3f3f9 commit 23b3bd8
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public void test200MessageTemplate() throws Exception {

given("message template");
String objectName = "messageTemplate" + getTestNumber();
var messageTemplate = new MessageTemplateType(prismContext)
var messageTemplate = new MessageTemplateType()
.name(objectName)
.defaultContent(new MessageTemplateContentType(prismContext)
.defaultContent(new MessageTemplateContentType()
.subjectExpression(velocityExpression("subject-prefix")))
.localizedContent(new LocalizedMessageTemplateContentType(prismContext)
.localizedContent(new LocalizedMessageTemplateContentType()
.language("sk_SK")
.subjectExpression(velocityExpression("Oné")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public void test100AddOperationExecution() throws Exception {
int THREADS = 8;
long DURATION = 30_000L;

UserType user = new UserType(prismContext).name("jack");
UserType user = new UserType().name("jack");

OperationResult result = new OperationResult("test100AddOperationExecution");
String oid = plainRepositoryService.addObject(user.asPrismObject(), null, result);
Expand All @@ -540,7 +540,7 @@ public void test100AddOperationExecution() throws Exception {
Collection<ItemDelta<?, ?>> getItemDeltas() throws Exception {
return prismContext.deltaFor(UserType.class)
.item(UserType.F_OPERATION_EXECUTION).add(
new OperationExecutionType(prismContext)
new OperationExecutionType()
.channel(threadIndex + ":" + counter)
.timestamp(XmlTypeConverter.createXMLGregorianCalendar(new Date())))
.asItemDeltas();
Expand Down Expand Up @@ -576,7 +576,7 @@ public void test110AddAssignments() throws Exception {

AtomicInteger globalCounter = new AtomicInteger();

UserType user = new UserType(prismContext).name("alice");
UserType user = new UserType().name("alice");

OperationResult result = new OperationResult("test110AddAssignments");
String oid = plainRepositoryService.addObject(user.asPrismObject(), null, result);
Expand All @@ -595,7 +595,7 @@ public void test110AddAssignments() throws Exception {
globalCounter.incrementAndGet();
return prismContext.deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT).add(
new AssignmentType(prismContext).targetRef(
new AssignmentType().targetRef(
String.format("000049f4-8d7a-4791-%04d-%012d", threadIndex, counter.get()),
OrgType.COMPLEX_TYPE))
.asItemDeltas();
Expand All @@ -619,7 +619,7 @@ public void test120AddApproverRef() throws Exception {
long DURATION = 30_000L;
final String DELEGATED_REF_FORMAT = "bcce49f4-8d7a-4791-%04d-%012d";

RoleType role = new RoleType(prismContext).name("judge");
RoleType role = new RoleType().name("judge");

OperationResult result = new OperationResult("test120AddApproverRef");
String oid = plainRepositoryService.addObject(role.asPrismObject(), null, result);
Expand Down Expand Up @@ -702,7 +702,7 @@ public void test130AddDeleteObjects() throws Exception {
AddObjectsThread<UserType> thread = new AddObjectsThread<>(i, "adder #" + i, OBJECTS_PER_THREAD) {
@Override
protected PrismObject<UserType> getObjectToAdd() {
return new UserType(prismContext).name(String.format("user-%d-%06d", threadIndex, counter.intValue())).asPrismObject();
return new UserType().name(String.format("user-%d-%06d", threadIndex, counter.intValue())).asPrismObject();
}
};
thread.start();
Expand Down Expand Up @@ -753,7 +753,7 @@ public void test140WorkBucketsAdd() throws Exception {
int THREADS = 8;
long DURATION = 30_000L;

TaskType task = new TaskType(prismContext)
TaskType task = new TaskType()
.name("test140")
.beginActivityState()
.beginActivity()
Expand Down Expand Up @@ -788,7 +788,7 @@ void runOnce(OperationResult result) throws Exception {
private WorkBucketType getNextBucket(TaskType task) {
int lastBucketNumber = task.getActivityState() != null ?
getLastBucketNumber(task.getActivityState().getActivity().getBucketing().getBucket()) : 0;
return new WorkBucketType(prismContext)
return new WorkBucketType()
.sequentialNumber(lastBucketNumber + 1)
.state(WorkBucketStateType.DELEGATED)
.workerRef(String.valueOf(threadIndex), TaskType.COMPLEX_TYPE);
Expand Down Expand Up @@ -840,7 +840,7 @@ public void test150WorkBucketsReplace() throws Exception {
int THREADS = 8;
long DURATION = 30_000L;

TaskType task = new TaskType(prismContext)
TaskType task = new TaskType()
.name("test150")
.beginActivityState()
.beginActivity()
Expand Down Expand Up @@ -880,7 +880,7 @@ private List<WorkBucketType> getBucketsToReplace(TaskType task) {
}

private WorkBucketType getNextBucket(List<WorkBucketType> currentBuckets) {
return new WorkBucketType(prismContext)
return new WorkBucketType()
.sequentialNumber(getLastBucketNumber(currentBuckets) + 1)
.state(WorkBucketStateType.DELEGATED)
.workerRef(String.valueOf(threadIndex), TaskType.COMPLEX_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti

private void createRoles(OperationResult result) throws SchemaException, ObjectAlreadyExistsException {
for (int i = 0; i < ROLES; i++) {
RoleType role = new RoleType(prismContext)
RoleType role = new RoleType()
.name(String.format(ROLE_NAME_PATTERN, i));
repositoryService.addObject(role.asPrismObject(), null, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
*/
package com.evolveum.midpoint.repo.common.tasks;

import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY;

import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;

import static com.evolveum.midpoint.schema.util.task.BucketingUtil.sortBucketsBySequentialNumber;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.READY;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -22,17 +22,6 @@
import java.util.function.Consumer;
import javax.annotation.PostConstruct;

import com.evolveum.midpoint.repo.common.AbstractRepoCommonTest;
import com.evolveum.midpoint.repo.common.activity.run.CommonTaskBeans;
import com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingConfigurationOverrides;
import com.evolveum.midpoint.repo.common.activity.run.buckets.GetBucketOperationOptions.GetBucketOperationOptionsBuilder;
import com.evolveum.midpoint.schema.util.task.ActivityPath;

import com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition;

import com.evolveum.midpoint.schema.util.task.BucketingUtil;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;

import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
Expand All @@ -43,15 +32,23 @@
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.repo.common.AbstractRepoCommonTest;
import com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition;
import com.evolveum.midpoint.repo.common.activity.run.CommonTaskBeans;
import com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingConfigurationOverrides;
import com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingManager;
import com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory;
import com.evolveum.midpoint.repo.common.activity.run.buckets.GetBucketOperationOptions.GetBucketOperationOptionsBuilder;
import com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory;
import com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactoryGenerator;
import com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory;
import com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.task.ActivityPath;
import com.evolveum.midpoint.schema.util.task.BucketingUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -117,7 +114,7 @@ public void test010StringPrefixBucketsLegacy() throws Exception {
taskAdd(TASK_010, result);

Task task = taskManager.getTaskPlain(TASK_010.oid, result);
ActivityStateType workState = new ActivityStateType(prismContext);
ActivityStateType workState = new ActivityStateType();

when();

Expand All @@ -133,8 +130,7 @@ public void test010StringPrefixBucketsLegacy() throws Exception {
assertNarrowedQuery(task, bucket,
prismContext.queryFor(UserType.class)
.item(UserType.F_NAME).startsWith("a00").matchingNorm()
.build()
);
.build());

assumeNextPrefix(allocator, workState, "a01", 2);
assumeNextPrefix(allocator, workState, "a0a", 3);
Expand Down Expand Up @@ -172,7 +168,7 @@ public void test020StringExactValueBuckets() throws Exception {
taskAdd(TASK_020, result);

Task task = taskManager.getTaskPlain(TASK_020.oid, result);
ActivityStateType workState = new ActivityStateType(prismContext);
ActivityStateType workState = new ActivityStateType();

when();

Expand Down Expand Up @@ -227,7 +223,7 @@ public void test030StringIntervalBuckets() throws Exception {
taskAdd(TASK_030, result);

Task task = taskManager.getTaskPlain(TASK_030.oid, result);
ActivityStateType workState = new ActivityStateType(prismContext);
ActivityStateType workState = new ActivityStateType();

when();

Expand Down Expand Up @@ -919,7 +915,7 @@ private List<WorkBucketType> getBuckets(ActivityStateType workState) {

private List<WorkBucketType> getOrCreateBuckets(ActivityStateType workState) {
if (workState.getBucketing() == null) {
workState.setBucketing(new ActivityBucketingStateType(prismContext));
workState.setBucketing(new ActivityBucketingStateType());
}
return workState.getBucketing().getBucket();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public class ShadowAttributesHelper {
private final MutablePrismContainerDefinition<Containerable> attrsDefinition;

public ShadowAttributesHelper(ShadowType object) throws SchemaException {
attributesContainer = new ShadowAttributesType(prismContext);
attributesContainer = new ShadowAttributesType();
// let's create the container+PCV inside the shadow object
object.attributes(attributesContainer);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -86,8 +86,8 @@ public void test110StoringFullSuccessResults() throws Exception {

given("clear audit and audit configuration set to FULL");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext)
.eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext)
auditService.applyAuditConfiguration(new SystemConfigurationAuditType()
.eventRecording(new SystemConfigurationAuditEventRecordingType()
.deltaSuccessExecutionResult(OperationResultDetailLevel.FULL)));

when("audit event with delta operation executions is stored");
Expand All @@ -110,8 +110,8 @@ public void test120StoringNoneSuccessResults() throws Exception {

given("clear audit and audit configuration set to NONE");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext)
.eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext)
auditService.applyAuditConfiguration(new SystemConfigurationAuditType()
.eventRecording(new SystemConfigurationAuditEventRecordingType()
.deltaSuccessExecutionResult(OperationResultDetailLevel.NONE)));

when("audit event with delta operation executions is stored");
Expand All @@ -138,8 +138,8 @@ public void test130StoringOnlyTopSuccessResults() throws Exception {

given("clear audit and audit configuration set to TOP");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext)
.eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext)
auditService.applyAuditConfiguration(new SystemConfigurationAuditType()
.eventRecording(new SystemConfigurationAuditEventRecordingType()
.deltaSuccessExecutionResult(OperationResultDetailLevel.TOP)));

when("audit event with delta operation executions is stored");
Expand All @@ -166,8 +166,8 @@ public void test140StoringCleanedUpSuccessResults() throws Exception {

given("clear audit and audit configuration set to TOP");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext)
.eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext)
auditService.applyAuditConfiguration(new SystemConfigurationAuditType()
.eventRecording(new SystemConfigurationAuditEventRecordingType()
.deltaSuccessExecutionResult(OperationResultDetailLevel.CLEANED_UP)));

when("audit event with delta operation executions is stored");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private ObjectDeltaOperation<UserType> createDeltaWithIgnoredPath(ItemPath itemP

private PrismObject<UserType> createUser(String userName)
throws ObjectAlreadyExistsException, SchemaException {
PrismObject<UserType> user = new UserType(prismContext)
PrismObject<UserType> user = new UserType()
.name(userName)
.asPrismObject();
repositoryService.addObject(user, null, createOperationResult());
Expand Down Expand Up @@ -1004,7 +1004,7 @@ public void test300SearchReturnsMappedToManyAttributes() throws SchemaException
and("record 3 has expected properties");
AuditEventRecordType record3 = result.get(2);
assertThat(record3.getProperty()).as("two different property keys").hasSize(2);
// currently props are sorted by name during transformation to AERType
// Currently, props are sorted by name during transformation to AERType.
prop1 = record3.getProperty().get(0);
assertThat(prop1.getName()).isEqualTo("prop1");
assertThat(prop1.getValue()).containsExactlyInAnyOrder("val3-1", "val3-2", "val3-3");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -26,7 +26,7 @@ public class SequenceFunctionalTest extends SqaleRepoBaseTest {
public void test010ReturningValues() throws Exception {
OperationResult result = createOperationResult();
String oid = repositoryService.addObject(
new SequenceType(prismContext)
new SequenceType()
.name("Sequence 0-9, 5 unused values, wrap around")
.counter(0L)
.maxCounter(9L)
Expand Down Expand Up @@ -68,7 +68,7 @@ public void test010ReturningValues() throws Exception {
public void test020ReachingLimit() throws Exception {
OperationResult result = createOperationResult();
String oid = repositoryService.addObject(
new SequenceType(prismContext)
new SequenceType()
.name("Sequence 0-9")
.counter(0L)
.maxCounter(9L)
Expand Down

0 comments on commit 23b3bd8

Please sign in to comment.