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
KaterynaHonchar committed Jan 31, 2019
2 parents 5a796ae + 736997c commit f9240b0
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 67 deletions.
Expand Up @@ -61,7 +61,7 @@
<body wicket:id="body" class="">
<div wicket:id="mainPopup"/>
<div class="wrapper">
<header wicket:id="mainHeader" class="main-header">
<header wicket:id="mainHeader" class="main-header" style="max-height:150px;">
<!-- Logo -->
<a class="custom-logo" wicket:id="customLogo">
<i wicket:id="customLogoImgCss"/>
Expand All @@ -77,7 +77,7 @@
<span class="sr-only"><wicket:message key="PageTemplate.toggleNavigation"/></span>
</a>

<div class="navbar-title" wicket:id="pageTitleContainer">
<div class="navbar-title" wicket:id="pageTitleContainer" style="max-width:94%;">
<span class="page-title" wicket:id="pageTitle">
<span wicket:id="deploymentName"/>
<span wicket:id="pageTitleReal"/>
Expand Down
Expand Up @@ -29,12 +29,12 @@

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.stream.Collectors;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.UniformItemPath;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
Expand Down Expand Up @@ -109,10 +109,38 @@ public class TestIntegrationObjectWrapperFactory extends AbstractInitializedGuiI
private static final String USER_NEWMAN_EMPLOYEE_NUMBER = "N00001";
private static final String USER_NEWMAN_SHIP = "Nova";

private static final int BASIC_USERS_CONTAINERS = 9;
private static final int BASIC_SHADOW_CONTAINERS = 10;
private static final int BASIC_ORG_CONTAINERS = 15;

private static final List<ItemPath> BASIC_USER_CONTAINERS_PATHS = Arrays.asList(
ItemPath.EMPTY_PATH,
UserType.F_EXTENSION,
UserType.F_METADATA,
UserType.F_ASSIGNMENT,
UserType.F_ACTIVATION,
UserType.F_CREDENTIALS,
UserType.F_ADMIN_GUI_CONFIGURATION);
private static final List<ItemPath> BASIC_SHADOW_CONTAINERS_PATHS = Arrays.asList(
ItemPath.EMPTY_PATH,
ShadowType.F_EXTENSION,
ShadowType.F_METADATA,
ShadowType.F_PENDING_OPERATION,
ShadowType.F_ATTRIBUTES,
ShadowType.F_ASSOCIATION,
ShadowType.F_ACTIVATION,
ShadowType.F_CREDENTIALS);
private static final List<ItemPath> BASIC_ORG_CONTAINERS_PATHS = Arrays.asList(
ItemPath.EMPTY_PATH,
OrgType.F_EXTENSION,
OrgType.F_METADATA,
OrgType.F_ASSIGNMENT,
OrgType.F_ACTIVATION,
OrgType.F_INDUCEMENT,
OrgType.F_AUTHORIZATION,
OrgType.F_EXCLUSION,
OrgType.F_CONDITION,
OrgType.F_POLICY_CONSTRAINTS,
OrgType.F_ADMIN_GUI_CONFIGURATION,
OrgType.F_DATA_PROTECTION,
OrgType.F_AUTOASSIGN);

private String userWallyOid;
private String accountWallyOid;

Expand Down Expand Up @@ -146,7 +174,7 @@ public void test100CreateWrapperUserJack() throws Exception {
IntegrationTestTools.display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "user display name", "user description", user, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_USERS_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);

ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findContainerWrapper(null);
WrapperTestUtil.assertWrapper(mainContainerWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath)null, user, ContainerStatus.MODIFYING);
Expand Down Expand Up @@ -190,7 +218,17 @@ public void test100CreateWrapperUserJack() throws Exception {
display("Delta", objectDelta);
assertTrue("non-empty delta produced from wrapper: "+objectDelta, objectDelta.isEmpty());
}


private void assertContainersPaths(ObjectWrapper<?> objectWrapper, Collection<ItemPath> expectedPaths) {
Set<UniformItemPath> expectedUniformPaths = expectedPaths.stream()
.map(p -> prismContext.toUniformPath(p))
.collect(Collectors.toSet());
Set<UniformItemPath> realUniformPaths = objectWrapper.getContainers().stream()
.map(c -> prismContext.toUniformPath(c.getPath()))
.collect(Collectors.toSet());
assertEquals("wrong container paths in "+objectWrapper, expectedUniformPaths, realUniformPaths);
}

/**
* Create wrapper for brand new empty user.
*/
Expand All @@ -215,7 +253,7 @@ public void test110CreateWrapperUserNewEmpty() throws Exception {
IntegrationTestTools.display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "user display name", "user description", user, ContainerStatus.ADDING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_USERS_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);

ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findContainerWrapper(null);
WrapperTestUtil.assertWrapper(mainContainerWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath)null, user, ContainerStatus.ADDING);
Expand Down Expand Up @@ -293,7 +331,7 @@ public void test112CreateWrapperUserNewman() throws Exception {
IntegrationTestTools.display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "user display name", "user description", user, ContainerStatus.ADDING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_USERS_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);

WrapperTestUtil.assertWrapper(mainContainerWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath)null, user, ContainerStatus.ADDING);
assertEquals("wrong number of containers in "+mainContainerWrapper, 1, mainContainerWrapper.getValues().size());
Expand Down Expand Up @@ -360,7 +398,7 @@ public void test102CreateWrapperUserEmpty() throws Exception {
IntegrationTestTools.display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "user display name", "user description", user, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_USERS_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);

ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findContainerWrapper(null);
WrapperTestUtil.assertWrapper(mainContainerWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath)null, user, ContainerStatus.MODIFYING);
Expand Down Expand Up @@ -419,7 +457,7 @@ public void test150CreateWrapperShadow() throws Exception {
display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_SHADOW_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_SHADOW_CONTAINERS_PATHS);

ContainerWrapper<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(ShadowType.F_ATTRIBUTES);
assertEquals("wrong number of values in "+attributesContainerWrapper, 1, attributesContainerWrapper.getValues().size());
Expand Down Expand Up @@ -481,7 +519,7 @@ public void test160CreateWrapperOrgScummBar() throws Exception {
IntegrationTestTools.display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "org display name", "org description", org, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_ORG_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_ORG_CONTAINERS_PATHS);

ContainerWrapper<OrgType> mainContainerWrapper = objectWrapper.findContainerWrapper(null);
WrapperTestUtil.assertWrapper(mainContainerWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath)null, org, ContainerStatus.MODIFYING);
Expand Down Expand Up @@ -570,7 +608,7 @@ public void test220AssignRoleLandluberToWally() throws Exception {
display("Wrapper after", objectWrapper);

WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
assertEquals("wrong number of containers in "+objectWrapper, BASIC_SHADOW_CONTAINERS, objectWrapper.getContainers().size());
assertContainersPaths(objectWrapper, BASIC_SHADOW_CONTAINERS_PATHS);

ContainerWrapper<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(ShadowType.F_ATTRIBUTES);
WrapperTestUtil.assertWrapper(attributesContainerWrapper, "Attributes", ShadowType.F_ATTRIBUTES, shadow.findContainer(ShadowType.F_ATTRIBUTES),
Expand Down
Expand Up @@ -52,7 +52,7 @@ public Message(NotificationMessageType message) {
contentType = message.getContentType();
attachments.addAll(message.getAttachment());
}

public String getBody() {
return body;
}
Expand Down Expand Up @@ -116,19 +116,51 @@ public void setFrom(String from) {
public List<NotificationMessageAttachmentType> getAttachments() {
return attachments;
}

public void setAttachments(@NotNull List<NotificationMessageAttachmentType> attachments) {
this.attachments = attachments;
}

@Override
public String toString() {
return "Message{" +
"to='" + to + '\'' +
(from != null ? ", from='" + from + "'" : "") +
", cc='" + cc + "'" +
", bcc='" + bcc + "'" +
", subject='" + subject + '\'' +
", contentType='" + contentType + '\'' +
", body='" + body + '\'' +
", attachments: " + attachments.size() + // TODO provide a short information here (the same as in debugDump below)
'}';
StringBuilder sb = new StringBuilder();
sb.append("Message{")
.append("to='").append(to).append("'")
.append((from != null ? ", from='" + from + "'" : ""))
.append(", cc='").append(cc).append("'")
.append(", bcc='").append(bcc).append("'")
.append(", subject='").append(subject).append("'")
.append(", contentType='").append(contentType).append("'")
.append(", body='").append(body).append("'")
.append(", attachmentsCount: ").append(attachments.size());
if(attachments.size() > 0) {
sb.append(", attachments: {");
boolean isFirst = true;
for(NotificationMessageAttachmentType attachment : attachments) {
if(!isFirst) {
sb.append(", ");
}
isFirst= false;
sb.append("[")
.append("contentType='").append(attachment.getContentType()).append("'")
.append(attachment.getContentFromFile() != null ?
", contentFromFile='" + attachment.getContentFromFile() + "'" : "");
if(attachment.getContent() != null) {
if(attachment.getContent() instanceof String) {
sb.append(", contentLength='").append(((String)attachment.getContent()).length()).append("'");
} else if(attachment.getContent() != null && attachment.getContent() instanceof String) {
sb.append(", contentSizeOfByte='").append(((byte[])attachment.getContent()).length).append("'");
} else {
sb.append(", content='").append(attachment.getContent().toString()).append("'");
}
}
sb.append(attachment.getFileName() != null ?
", fileName='" + attachment.getFileName() + "'" : "")
.append("]");
};
sb.append("}");
}
return sb.toString();
}

@Override
Expand Down Expand Up @@ -159,10 +191,44 @@ public String debugDump(int indent) {

DebugUtil.debugDumpWithLabel(rv, "Subject", subject, indent+1);
rv.append("\n");

DebugUtil.debugDumpWithLabel(rv, "Content type", contentType, indent+1);
rv.append("\n");

DebugUtil.debugDumpWithLabel(rv, "Body", DebugUtil.fixIndentInMultiline(indent+1, DebugDumpable.INDENT_STRING, body), indent+1);

// TODO attachments (instead of content provide only information about e.g. its size in case of byte[] or length in case of String)
rv.append("\n");

DebugUtil.debugDumpLabel(rv, "Attachments", indent);
rv.append("\n");

attachments.forEach(attachment -> {

DebugUtil.debugDumpLabel(rv, "Attachment", indent+2);
rv.append("\n");

DebugUtil.debugDumpWithLabel(rv, "Content type", attachment.getContentType(), indent+3);
rv.append("\n");

if (from != null){
DebugUtil.debugDumpWithLabel(rv, "Content from file", attachment.getContentFromFile(), indent+3);
rv.append("\n");
}

if(attachment.getContent() != null) {
if(attachment.getContent() instanceof String) {
DebugUtil.debugDumpWithLabel(rv, "Content length", ((String)attachment.getContent()).length(), indent+3);
rv.append("\n");
} else if(attachment.getContent() != null && attachment.getContent() instanceof String) {
DebugUtil.debugDumpWithLabel(rv, "Content size of byte", ((byte[])attachment.getContent()).length, indent+3);
rv.append("\n");
}
}

if (from != null){
DebugUtil.debugDumpWithLabel(rv, "File name", attachment.getFileName(), indent+3);
rv.append("\n");
}
});
return rv.toString();
}
}

0 comments on commit f9240b0

Please sign in to comment.