Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint:
  Add pieces of documentation in correlation XSD
  MID-7947: fixed NPE if stored audit ref OID is null
  Fix indexing feature
  .gitignore: added MP Studio /scratches/ to gitignore
  Rename "owner" to "definite" correlation threshold
  • Loading branch information
katkav committed Sep 9, 2022
2 parents 6db8f76 + 5492f70 commit ed6d1d9
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ rebel.xml
.DS_Store
_mess
.checkstyle

# midPoint Studio temporary files
/scratches/
Original file line number Diff line number Diff line change
Expand Up @@ -4002,6 +4002,8 @@

For attributes this automatically turns on "beforeCorrelation" mapping evaluation phase.
(If not explicitly forbidden in the attribute definition.)

Currently supported for attributes only.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="owner" type="xsd:double" minOccurs="0" default="1.0">
<xsd:element name="definite" type="xsd:double" minOccurs="0" default="1.0">
<xsd:annotation>
<xsd:documentation>
The value of the rescaled confidence (i.e., between 0 and 1) that marks the candidate as "the chosen" one.
Expand Down Expand Up @@ -1552,14 +1552,14 @@
<xsd:annotation>
<xsd:documentation>
Local item name in the 'indexed items' container.
Normally, it is derived from the item name.
Usually it can be left unspecified, because by default, the item local name is used.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="normalization" type="tns:IndexedItemNormalizationDefinitionType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Set of normalizations that are applied to the given item.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand All @@ -1582,14 +1582,16 @@
<xsd:element name="name" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Name of the index. It is appended to the item name.
Name of the index (normalization). It is appended to the item name.
Usually it can be left unspecified, because it is derived from the normalization step(s).
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="default" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
Is this the default index (normalization) for the given item?
It is necessary to specify it only if there is more than one normalization defined.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -1629,28 +1631,28 @@
<xsd:element name="none" type="tns:NoOpNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Does no normalization, i.e., keeps the original value intact.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="polyString" type="tns:PolyStringNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Applies system-defined or custom PolyString normalization.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="prefix" type="tns:PrefixNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Takes first N characters of the value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="custom" type="tns:CustomNormalizationStepType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
Applies a custom expression to the value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand All @@ -1673,14 +1675,17 @@
<xsd:element name="order" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO nulls go last
Order in which the step is to be applied.
It should be used, because current prism structures (containers) are not guaranteed
to preserve the order of their values.
Steps without value go last.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="documentation" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO (or ref?)
Technical documentation for this step.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -1721,7 +1726,8 @@
<xsd:element name="configuration" type="t:PolyStringNormalizerConfigurationType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Configuration of PolyString normalizer. NOT IMPLEMENTED YET.
Configuration of PolyString normalizer.
If not specified, the one defined at the system level is used.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand All @@ -1747,7 +1753,7 @@
<xsd:element name="length" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
How many characters to keep.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand All @@ -1759,7 +1765,7 @@
<xsd:complexType name="CustomNormalizationStepType">
<xsd:annotation>
<xsd:documentation>
TODO; NOT IMPLEMENTED YET
Normalization carried out using custom expression.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.6</a:since>
Expand All @@ -1773,7 +1779,8 @@
<xsd:element name="expression" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
TODO
Expression that transforms the value to its normalized form.
Expects `input` as the original value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.delta.*;

import org.testng.annotations.Test;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy;
import com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy;
import com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl;
Expand All @@ -38,6 +38,7 @@
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

@SuppressWarnings("SimplifiableAssertion")
public class TestDiffEquals extends AbstractSchemaTest {

public static final File TEST_DIR = new File("src/test/resources/diff");
Expand Down Expand Up @@ -77,7 +78,7 @@ public void testUserListSimpleDiff() throws SchemaException {
PrismTestUtil.getPrismContext().adopt(u1);
PrismTestUtil.getPrismContext().adopt(u2);

ObjectDelta delta = u1.asPrismObject().diff(u2.asPrismObject());
ObjectDelta<UserType> delta = u1.asPrismObject().diff(u2.asPrismObject());
assertNotNull(delta);
assertEquals(0, delta.getModifications().size());

Expand All @@ -90,18 +91,16 @@ public void testUserListSimpleDiff() throws SchemaException {

@Test
public void testAssignmentEquals1() {
PrismContext prismContext = PrismTestUtil.getPrismContext();

when();
AssignmentType a1a = new AssignmentType(prismContext).description("descr1");
AssignmentType a1b = new AssignmentType(prismContext).description("descr1");
AssignmentType a1e = new AssignmentType(prismContext).description("descr1")
AssignmentType a1a = new AssignmentType().description("descr1");
AssignmentType a1b = new AssignmentType().description("descr1");
AssignmentType a1e = new AssignmentType().description("descr1")
.activation(new ActivationType().effectiveStatus(ActivationStatusType.ENABLED));
AssignmentType a1m = new AssignmentType(prismContext).description("descr1")
AssignmentType a1m = new AssignmentType().description("descr1")
.metadata(new MetadataType().createTimestamp(
XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis())));

AssignmentType a2 = new AssignmentType(prismContext).description("descr2");
AssignmentType a2 = new AssignmentType().description("descr2");

then("None of a1 equals to a2 (and vice versa)");
assertThat(a1a).isNotEqualTo(a2);
Expand Down Expand Up @@ -159,24 +158,24 @@ public void testAssignmentEquals2() throws Exception {

@Test
public void testAssignmentEquivalent() {
PrismContext prismContext = PrismTestUtil.getPrismContext();

AssignmentType a1 = new AssignmentType(prismContext);
ActivationType a1a = new ActivationType(prismContext);
AssignmentType a1 = new AssignmentType();
ActivationType a1a = new ActivationType();
a1a.setValidFrom(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
a1a.setEffectiveStatus(ActivationStatusType.ENABLED);
a1.setActivation(a1a);

AssignmentType a2 = new AssignmentType(prismContext);
ActivationType a2a = new ActivationType(prismContext);
AssignmentType a2 = new AssignmentType();
ActivationType a2a = new ActivationType();
a2a.setEffectiveStatus(ActivationStatusType.ENABLED);
a2.setActivation(a2a);

// WHEN
assertFalse(a1.equals(a2));
//noinspection unchecked
assertFalse(a1.asPrismContainerValue().equivalent(a2.asPrismContainerValue())); // a bit redundant

assertFalse(a2.equals(a1));
//noinspection unchecked
assertFalse(a2.asPrismContainerValue().equivalent(a1.asPrismContainerValue())); // a bit redundant
}

Expand Down Expand Up @@ -204,7 +203,7 @@ public void testContextlessAssignmentEquals() throws Exception {
}

@Test(enabled = false)
public void testContextlessAssignmentEquals2() throws Exception {
public void testContextlessAssignmentEquals2() {
// (1) user without prismContext - the functionality is reduced

UserType user = new UserType();
Expand All @@ -220,12 +219,12 @@ public void testContextlessAssignmentEquals2() throws Exception {
a2identical.setDescription("descr2");
assertTrue(user.getAssignment().contains(a2identical));

ObjectDelta delta1 = user.asPrismObject().createDelta(ChangeType.DELETE); // delta1 is without prismContext
ObjectDelta<UserType> delta1 = user.asPrismObject().createDelta(ChangeType.DELETE); // delta1 is without prismContext
assertNull(delta1.getPrismContext());

// (2) user with prismContext

UserType userWithContext = new UserType(PrismTestUtil.getPrismContext());
UserType userWithContext = new UserType();

AssignmentType b1 = new AssignmentType(); // no prismContext here
b1.setDescription("descr1");
Expand All @@ -243,7 +242,7 @@ public void testContextlessAssignmentEquals2() throws Exception {
assertNotNull(b2.asPrismContainerValue().getPrismContext());
assertFalse(b1.equals(b2));

ObjectDelta delta2 = userWithContext.asPrismObject().createDelta(ChangeType.DELETE);
ObjectDelta<UserType> delta2 = userWithContext.asPrismObject().createDelta(ChangeType.DELETE);
assertNotNull(delta2.getPrismContext());
}

Expand Down Expand Up @@ -310,9 +309,7 @@ public void testAssignmentHashcode() throws Exception {
// MID-4251
@Test
public void testAssignmentHashcode2() {
PrismContext prismContext = PrismTestUtil.getPrismContext();

AssignmentType a1a = new AssignmentType(prismContext).id(6L)
AssignmentType a1a = new AssignmentType().id(6L)
.beginMetadata()
.createApprovalComment("hi")
.<AssignmentType>end()
Expand All @@ -321,7 +318,7 @@ public void testAssignmentHashcode2() {
.effectiveStatus(ActivationStatusType.ENABLED)
.validTo("2018-01-01T00:00:00.000+01:00")
.end();
AssignmentType a1b = new AssignmentType(prismContext)
AssignmentType a1b = new AssignmentType()
.targetRef(new ObjectReferenceType().oid("target").type(OrgType.COMPLEX_TYPE))
.beginActivation()
.validTo("2018-01-01T00:00:00.000+01:00")
Expand All @@ -334,9 +331,7 @@ public void testAssignmentHashcode2() {
// MID-4251
@Test
public void testAssignmentHashcode3() {
PrismContext prismContext = PrismTestUtil.getPrismContext();

AssignmentType a1a = new AssignmentType(prismContext)
AssignmentType a1a = new AssignmentType()
.beginActivation()
.validTo("2018-01-01T00:00:00.000+01:00")
.end();
Expand All @@ -363,7 +358,6 @@ public void testDiffShadow() throws Exception {
ShadowType shadow1Type = shadow1.asObjectable();
shadow1Type.setName(new PolyStringType("Whatever"));
shadow1Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "foo"));
PrismContainer<Containerable> shadow1Attrs = shadow1.findOrCreateContainer(ShadowType.F_ATTRIBUTES);

ShadowType shadow2Type = new ShadowType();
PrismObject<ShadowType> shadow2 = shadow2Type.asPrismObject();
Expand Down Expand Up @@ -402,6 +396,7 @@ public void testDiffShadow() throws Exception {

PrismAsserts.assertIsModify(delta);
PrismAsserts.assertPropertyAdd(delta, ShadowType.F_AUXILIARY_OBJECT_CLASS, new QName(NS_TEST_RI, "bar"));
//noinspection unchecked
PrismAsserts.assertContainerAdd(delta, ShadowType.F_ATTRIBUTES, shadow2Attrs.getValue().clone());
PrismAsserts.assertModifications(delta, 2);
}
Expand Down Expand Up @@ -463,12 +458,10 @@ public void diffRoles() throws Exception {

@Test // MID-4688
public void testDiffWithMetadata() {
PrismContext prismContext = PrismTestUtil.getPrismContext();

ProtectedStringType value = new ProtectedStringType();
value.setClearValue("abc");

PrismObject<UserType> user1 = new UserType(prismContext)
PrismObject<UserType> user1 = new UserType()
.beginCredentials()
.beginPassword()
.value(value.clone())
Expand All @@ -478,7 +471,7 @@ public void testDiffWithMetadata() {
.<CredentialsType>end()
.<UserType>end()
.asPrismObject();
PrismObject<UserType> user2 = new UserType(prismContext)
PrismObject<UserType> user2 = new UserType()
.beginCredentials()
.beginPassword()
.value(value.clone())
Expand Down Expand Up @@ -516,12 +509,12 @@ public void testRawValuesHashCode() throws SchemaException {
propertyParsed.setRealValue("value");
propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl<>("value")));

PrismObject<UserType> userParsed = new UserType(prismContext)
PrismObject<UserType> userParsed = new UserType()
.name("user")
.asPrismObject();
userParsed.getOrCreateExtension().add(propertyParsed);

PrismObject<UserType> userRaw = new UserType(prismContext)
PrismObject<UserType> userRaw = new UserType()
.name("user")
.asPrismObject();
userRaw.getOrCreateExtension().add(propertyRaw);
Expand All @@ -547,6 +540,6 @@ private void assertHashAndEquals(PrismObject<UserType> user1, PrismObject<UserTy
hash1 = user1.hashCode(strategy);
hash2 = user2.hashCode(strategy);
}
assertEquals("Hashcodes are not equal (strategy=" + strategy + ")", hash1, hash2);
assertEquals("Hash codes are not equal (strategy=" + strategy + ")", hash1, hash2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public CorrelatorContext(
return templateCorrelationConfiguration;
}

public double getOwnerThreshold() {
public double getDefiniteThreshold() {
CorrelationConfidenceThresholdsDefinitionType thresholds = correlationDefinitionBean.getThresholds();
Double owner = thresholds != null ? thresholds.getOwner() : null;
return Objects.requireNonNullElse(owner, DEFAULT_OWNER);
Double definite = thresholds != null ? thresholds.getDefinite() : null;
return Objects.requireNonNullElse(definite, DEFAULT_OWNER);
}

public double getCandidateThreshold() {
Expand Down

0 comments on commit ed6d1d9

Please sign in to comment.