Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 17, 2020
2 parents a4b0baf + 27ed054 commit b57a839
Show file tree
Hide file tree
Showing 49 changed files with 470 additions and 693 deletions.
Expand Up @@ -102,6 +102,21 @@ public void onClick(AjaxRequestTarget target, IModel<CertCaseOrWorkItemDto> rowM
return column;
}

public <T extends CertCaseOrWorkItemDto> IColumn<T, String> createReviewerNameColumn(final PageBase page, final String headerKey) {
IColumn column;
column = new LinkColumn<CertCaseOrWorkItemDto>(page.createStringResource(headerKey), CertWorkItemDto.F_REVIEWER_NAME) {

@Override
public void onClick(AjaxRequestTarget target, IModel<CertCaseOrWorkItemDto> rowModel) {
CertCaseOrWorkItemDto dto = rowModel.getObject();
if (dto instanceof CertWorkItemDto) {
dispatchToObjectDetailsPage(((CertWorkItemDto) dto).getReviewerRef(), page, false);
}
}
};
return column;
}

public <T extends CertCaseOrWorkItemDto> IColumn<T, String> createConflictingNameColumn(final PageBase page, final String headerKey) {
return new PropertyColumn<>(page.createStringResource(headerKey), CertCaseOrWorkItemDto.F_CONFLICTING_TARGETS);
}
Expand Down
Expand Up @@ -191,6 +191,11 @@ private List<IColumn<CertWorkItemDto, String>> initColumns() {
column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
columns.add(column);

if (isDisplayingAllItems()) {
column = helper.createReviewerNameColumn(this, "PageCertDecisions.table.reviewer");
columns.add(column);
}

column = helper.createDetailedInfoColumn(this);
columns.add(column);

Expand Down
Expand Up @@ -9,11 +9,14 @@

import com.evolveum.midpoint.certification.api.OutcomeUtils;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.util.CertCampaignTypeUtil;
import com.evolveum.midpoint.schema.util.ApprovalContextUtil;
import com.evolveum.midpoint.schema.util.WorkItemTypeUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -28,13 +31,18 @@ public class CertWorkItemDto extends CertCaseOrWorkItemDto {
public static final String F_COMMENT = "comment";
@SuppressWarnings("unused")
public static final String F_RESPONSE = "response";
public static final String F_REVIEWER_NAME = "reviewerName";

@NotNull private final AccessCertificationWorkItemType workItem;
private ObjectReferenceType reviewerRef;
private String reviewerName;

CertWorkItemDto(@NotNull AccessCertificationWorkItemType workItem, @NotNull PageBase page) {
//noinspection ConstantConditions
super(CertCampaignTypeUtil.getCase(workItem), page);
this.workItem = workItem;
this.reviewerRef = workItem.getOriginalAssigneeRef();
this.reviewerName = computeReviewerName();
}

public String getComment() {
Expand Down Expand Up @@ -65,4 +73,27 @@ public Integer getEscalationLevelNumber() {
public String getEscalationLevelInfo() {
return ApprovalContextUtil.getEscalationLevelInfo(workItem);
}

public String computeReviewerName(){
if (reviewerRef == null){
return null;
}
return WebComponentUtil.getDisplayNameAndName(reviewerRef);
}

public String getReviewerName() {
return reviewerName;
}

public void setReviewerName(String reviewerName) {
this.reviewerName = reviewerName;
}

public ObjectReferenceType getReviewerRef() {
return reviewerRef;
}

public void setReviewerRef(ObjectReferenceType reviewerRef) {
this.reviewerRef = reviewerRef;
}
}
Expand Up @@ -42,7 +42,7 @@ public void testInitialObjects() throws Exception {
} catch (Throwable e) {
String msg = "Error processing file "+file.getName()+": "+e.getMessage();
logger.error(msg, e);
display(msg, e);
displayException(msg, e);
throw e;
}
}
Expand Down
Expand Up @@ -35,7 +35,6 @@ public abstract class AbstractActivationComputerTest extends AbstractUnitTest {
protected static final XMLGregorianCalendar SUMMER_SOLSTICE = XmlTypeConverter.createXMLGregorianCalendar(2013, 6, 21, 5, 4, 0);
protected static final XMLGregorianCalendar AUTUMN_EQUINOX = XmlTypeConverter.createXMLGregorianCalendar(2013, 9, 22, 20, 4, 0);
protected static final XMLGregorianCalendar WINTER_SOLSTICE = XmlTypeConverter.createXMLGregorianCalendar(2013, 12, 21, 17, 11, 0);
protected static final XMLGregorianCalendar YEAR_END = XmlTypeConverter.createXMLGregorianCalendar(2013, 12, 31, 23, 59, 59);

// Undefined state
protected static final String LIFECYCLE_STATE_LIMBO = "limbo";
Expand Down Expand Up @@ -100,38 +99,6 @@ public void testGetAdministrativeArchived() throws Exception {
assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus);
}

@Test
public void testGetDraftAdministrativeEnabled() throws Exception {
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(
ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);

// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(
SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel());

// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}

@Test
public void testGetProposedAdministrativeEnabled() throws Exception {
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(
ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);

// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(
SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel());

// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}

@Test
public void testGetLimboAdministrativeEnabled() {
// GIVEN
Expand Down
Expand Up @@ -6,6 +6,13 @@
*/
package com.evolveum.midpoint.common;

import static org.testng.AssertJUnit.assertEquals;

import org.testng.annotations.Test;

import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LifecycleStateModelType;

public class TestActivationComputerDefault extends AbstractActivationComputerTest {
Expand All @@ -14,4 +21,36 @@ public class TestActivationComputerDefault extends AbstractActivationComputerTes
protected LifecycleStateModelType createLifecycleModel() {
return null;
}

@Test
public void testGetDraftAdministrativeEnabled() {
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(
ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);

// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(
SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel());

// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}

@Test
public void testGetProposedAdministrativeEnabled() {
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(
ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);

// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(
SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel());

// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}
}
Expand Up @@ -36,7 +36,6 @@ protected LifecycleStateModelType createLifecycleModel() throws SchemaException,
}

@Test
@Override
public void testGetProposedAdministrativeEnabled() throws Exception {
// GIVEN
Clock clock = createClock(YEAR_START);
Expand All @@ -53,7 +52,6 @@ public void testGetProposedAdministrativeEnabled() throws Exception {
}

@Test
@Override
public void testGetDraftAdministrativeEnabled() throws Exception {
// GIVEN
Clock clock = createClock(YEAR_START);
Expand Down Expand Up @@ -108,5 +106,4 @@ protected void testComputeInhumed(
testCompute(LIFECYCLE_STATE_INHUMED, now, administrativeStatus,
validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity);
}

}
Expand Up @@ -87,11 +87,9 @@ public void testPrismParseXxe() throws Exception {

AssertJUnit.fail("Unexpected success");
} catch (IllegalStateException e) {
// THEN
System.out.println("Expected exception: "+e);
displayExpectedException(e);
assertTrue("Unexpected exception message: "+e.getMessage(), e.getMessage().contains("DOCTYPE"));
}

}

@Test
Expand All @@ -102,10 +100,8 @@ public void testPrismParseDomXxe() {

AssertJUnit.fail("Unexpected success");
} catch (IllegalStateException e) {
// THEN
System.out.println("Expected exception: "+e);
displayExpectedException(e);
assertTrue("Unexpected exception message: "+e.getMessage(), e.getMessage().contains("DOCTYPE"));
}

}
}

0 comments on commit b57a839

Please sign in to comment.