Skip to content

Commit

Permalink
Fix of TestPageSystemConf...test007testPageNotificationConfiguration
Browse files Browse the repository at this point in the history
The problem is that "mail" can't be deprecated yet for the current GUI.
This is caused by check in ItemWrapperFactoryImpl.skipCreateWrapper().
  • Loading branch information
virgo47 committed Feb 11, 2022
1 parent 9794efc commit 915ba9f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Evolveum and contributors
* Copyright (C) 2018-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 @@ -10,8 +10,6 @@
import java.util.List;
import java.util.stream.Collectors;

import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
Expand All @@ -37,6 +35,7 @@
import com.evolveum.midpoint.gui.api.component.password.PasswordPanel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper;
import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.component.data.column.EditableColumn;
Expand Down Expand Up @@ -90,9 +89,6 @@ public class NotificationConfigTabPanel extends BasePanel<PrismContainerWrapper<
private static final String ID_FILE_PATH = "filePath";
private static final String ID_REMOVE_BUTTON = "removeButton";

// private MailConfigurationType mailConfigType;
// private List<MailServerConfiguration> mailServers;

public NotificationConfigTabPanel(String id, IModel<PrismContainerWrapper<NotificationConfigurationType>> model) {
super(id, model);
}
Expand All @@ -114,13 +110,19 @@ private void initPaging() {

protected void initLayout() {

PrismPropertyWrapperModel<NotificationConfigurationType, MailConfigurationType> mailConfig = PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_MAIL);
PrismPropertyWrapperModel<NotificationConfigurationType, MailConfigurationType> mailConfig =
PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_MAIL);

add(createHeader(ID_MAIL_CONFIG_HEADER, mailConfig));

PropertyModel<MailConfigurationType> mailConfigType = new ItemRealValueModel<>(new PropertyModel<>(mailConfig, "values[0]"));

if (mailConfigType.getObject() == null) {
// TODO: This fails for deprecated "mail" element if it's missing, so it's not deprecated yet.
// Reason: mailConfig.getObject() == null
// Root cause: ItemWrapperFactoryImpl.skipCreateWrapper() has a code to skip empty & deprecated stuff.
// The object for mailConfig can't be created with createItemWrapper either as it would be skipped again and return null.
// Let's create new GUI for the new transport configuration first without to-be deprecated components.
mailConfigType.setObject(new MailConfigurationType());
}

Expand All @@ -144,7 +146,7 @@ protected void initLayout() {
files.setOutputMarkupId(true);
add(files);

ListView<PrismPropertyValueWrapper<FileConfigurationType>> values = new ListView<PrismPropertyValueWrapper<FileConfigurationType>>("values",
ListView<PrismPropertyValueWrapper<FileConfigurationType>> values = new ListView<>("values",
new PropertyModel<>(fileConfig, "values")) {
private static final long serialVersionUID = 1L;

Expand All @@ -155,7 +157,7 @@ protected void populateItem(final ListItem<PrismPropertyValueWrapper<FileConfigu

item.add(createHeader(ID_VALUE_HEADER, fileConfigType == null || fileConfigType.getName() == null || fileConfigType.getName().isEmpty() ? (FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details") : fileConfigType.getName()));

AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_BUTTON) {
AjaxLink<Void> removeButton = new AjaxLink<>(ID_REMOVE_BUTTON) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -174,7 +176,7 @@ public void onClick(AjaxRequestTarget target) {

@Override
protected void onUpdate(AjaxRequestTarget target) {
((FileConfigurationType) item.getModelObject().getRealValue()).setName(name.getModelObject());
item.getModelObject().getRealValue().setName(name.getModelObject());
}
});
item.add(name);
Expand Down Expand Up @@ -204,7 +206,7 @@ public boolean isVisible() {
values.setReuseItems(true);
files.add(values);

AjaxLink<Void> addButton = new AjaxLink<Void>(ID_ADD_BUTTON) {
AjaxLink<Void> addButton = new AjaxLink<>(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -228,8 +230,8 @@ private BoxedTablePanel<MailServerConfiguration> initServersTable(PropertyModel<

List<MailServerConfiguration> mailServers = getListOfMailServerConfiguration(mailConfigType.getObject().getServer());
PageStorage pageStorage = getPageBase().getSessionStorage().getNotificationConfigurationTabMailServerTableStorage();
ISortableDataProvider<MailServerConfiguration, String> provider = new ListDataProvider<MailServerConfiguration>(this,
new ListModel<MailServerConfiguration>(mailServers) {
ISortableDataProvider<MailServerConfiguration, String> provider = new ListDataProvider<>(this,
new ListModel<>(mailServers) {

private static final long serialVersionUID = 1L;

Expand All @@ -253,9 +255,8 @@ protected PageStorage getPageStorage() {
}
};

UserProfileStorage userProfile = getPageBase().getSessionStorage().getUserProfile();
UserProfileStorage.TableId tableId = UserProfileStorage.TableId.NOTIFICATION_TAB_MAIL_SERVER_TABLE;
BoxedTablePanel<MailServerConfiguration> table = new BoxedTablePanel<MailServerConfiguration>(ID_MAIL_SERVERS_TABLE, provider, initMailServersColumns(), tableId) {
BoxedTablePanel<MailServerConfiguration> table = new BoxedTablePanel<>(ID_MAIL_SERVERS_TABLE, provider, initMailServersColumns(), tableId) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -315,7 +316,7 @@ private List<IColumn<MailServerConfiguration, String>> initMailServersColumns()
List<IColumn<MailServerConfiguration, String>> columns = new ArrayList<>();
columns.add(new CheckBoxHeaderColumn<>());

columns.add(new IconColumn<MailServerConfiguration>(Model.of("")) {
columns.add(new IconColumn<>(Model.of("")) {

private static final long serialVersionUID = 1L;

Expand All @@ -326,7 +327,7 @@ protected DisplayType getIconDisplayType(IModel<MailServerConfiguration> rowMode

});

columns.add(new EditableAjaxLinkColumn<MailServerConfiguration>(createStringResource("MailServerConfigurationType.host")) {
columns.add(new EditableAjaxLinkColumn<>(createStringResource("MailServerConfigurationType.host")) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -348,7 +349,7 @@ public void onClick(AjaxRequestTarget target, IModel<MailServerConfiguration> ro
}
});

columns.add(new EditableColumn<MailServerConfiguration, String>(createStringResource("MailServerConfigurationType.port")) {
columns.add(new EditableColumn<>(createStringResource("MailServerConfigurationType.port")) {

private static final long serialVersionUID = 1L;

Expand All @@ -366,7 +367,7 @@ protected Component createInputPanel(String componentId, IModel<MailServerConfig
}
});

columns.add(new EditableColumn<MailServerConfiguration, String>(createStringResource("MailServerConfigurationType.username")) {
columns.add(new EditableColumn<>(createStringResource("MailServerConfigurationType.username")) {

private static final long serialVersionUID = 1L;

Expand All @@ -384,7 +385,7 @@ protected Component createInputPanel(String componentId, IModel<MailServerConfig
}
});

columns.add(new EditableColumn<MailServerConfiguration, String>(createStringResource("MailServerConfigurationType.password")) {
columns.add(new EditableColumn<>(createStringResource("MailServerConfigurationType.password")) {

private static final long serialVersionUID = 1L;

Expand All @@ -400,7 +401,7 @@ protected Component createInputPanel(String componentId, IModel<MailServerConfig
}
});

columns.add(new EditableColumn<MailServerConfiguration, String>(createStringResource("MailServerConfigurationType.transportSecurity")) {
columns.add(new EditableColumn<>(createStringResource("MailServerConfigurationType.transportSecurity")) {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -458,7 +459,7 @@ public InlineMenuItemAction initAction() {
}

private ColumnMenuAction<MailServerConfiguration> createDeleteColumnAction() {
return new ColumnMenuAction<MailServerConfiguration>() {
return new ColumnMenuAction<>() {
private static final long serialVersionUID = 1L;

@Override
Expand Down Expand Up @@ -498,7 +499,7 @@ private void reloadSavePreviewButtons(AjaxRequestTarget target) {
}

private ColumnMenuAction<MailServerConfiguration> createEditColumnAction() {
return new ColumnMenuAction<MailServerConfiguration>() {
return new ColumnMenuAction<>() {
private static final long serialVersionUID = 1L;

@Override
Expand Down Expand Up @@ -575,5 +576,4 @@ public MailServerConfigurationType getValue() {
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,9 @@
<xsd:annotation>
<xsd:appinfo>
<a:displayName>NotificationConfigurationType.mail</a:displayName>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.5</a:deprecatedSince>
<!-- TODO: not deprecated yet because it breaks old GUI, see comments in NotificationConfigTabPanel -->
<!--<a:deprecated>true</a:deprecated>-->
<!--<a:deprecatedSince>4.5</a:deprecatedSince>-->
<!--TODO: <a:plannedRemoval>4.6</a:plannedRemoval>-->
</xsd:appinfo>
</xsd:annotation>
Expand Down

0 comments on commit 915ba9f

Please sign in to comment.