Skip to content

Commit

Permalink
Sqale: first cert modify test with full object
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 25, 2021
1 parent 474fff6 commit ef226ca
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertTrue;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.SerializationOptions;
import com.evolveum.midpoint.repo.sqale.qmodel.accesscert.*;

import org.assertj.core.api.Assertions;
Expand Down Expand Up @@ -2312,18 +2315,21 @@ public void test322DeleteAssignmentWithItemPathEndingWithCidIsIllegal() {
+ " Delta path must always point to item, not to value");
}

@Test(enabled = false) // WIP 4.4-M2
@Test
public void test330AddedCertificationCaseStoresItAndGeneratesMissingId()
throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
MAccessCertificationCampaign originalRow = selectObjectByOid(QAccessCertificationCampaign.class, accessCertificationCampaign1Oid);

given("delta adding case for campaign 1");
UUID targetOid = UUID.randomUUID();
AccessCertificationCaseType caseBefore = new AccessCertificationCaseType(prismContext)
.stageNumber(3)
.iteration(4)
.targetRef(targetOid.toString(), RoleType.COMPLEX_TYPE);
ObjectDelta<AccessCertificationCampaignType> delta = prismContext.deltaFor(AccessCertificationCampaignType.class)
.item(AccessCertificationCampaignType.F_CASE)
.add(new AccessCertificationCaseType(prismContext)
.targetRef(targetOid.toString(), RoleType.COMPLEX_TYPE)) // default relation
.add(caseBefore) // default relation
.asObjectDelta(accessCertificationCampaign1Oid);

when("modifyObject is called");
Expand Down Expand Up @@ -2354,9 +2360,18 @@ public void test330AddedCertificationCaseStoresItAndGeneratesMissingId()
assertThat(aRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);
assertCachedUri(aRow.targetRefRelationId, relationRegistry.getDefaultRelation());

// TODO: case full object
String fullObjectStr = new String(aRow.fullObject, StandardCharsets.UTF_8);
display("Case full object:\n" + fullObjectStr);
String caseBeforeStr = prismContext.serializerFor(PrismContext.LANG_XML)
.options(SerializationOptions
.createSerializeReferenceNamesForNullOids()
.skipIndexOnly(true)
.skipTransient(true))
.serialize(caseBefore.asPrismContainerValue());
assertThat(fullObjectStr).isEqualTo(caseBeforeStr);
}

// TODO: cert case modify test, assert correct full object

@Test
public void test399DeleteAllAssignments()
Expand Down

0 comments on commit ef226ca

Please sign in to comment.