Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@
/**
* Interface for a label
*
* @since com.adobe.cq.forms.core.components.models.form 5.4.0
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@ConsumerType
public interface Label extends TextContent {
public interface Label {

/**
* Returns {@code true} if label is rich text, otherwise {@code false}.
*
* @return {@code true} if label is rich text, otherwise {@code false}
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Nullable
default Boolean isRichText() {
return null;
}

/**
* Returns {@code true} if label should be visible, otherwise {@code false}.
Expand All @@ -37,4 +48,15 @@ default Boolean isVisible() {
return null;
}

/**
* Returns the value of this label.
*
* @return the value of this label
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Nullable
default String getValue() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.osgi.annotation.versioning.ProviderType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand Down Expand Up @@ -58,17 +57,5 @@ default boolean isEnforceEnum() {
* @return the list of enum names
* @since com.adobe.cq.forms.core.components.models.form 0.0.1
*/
@Deprecated
@JsonIgnore
String[] getEnumNames();

/**
* Returns a list of RichText to be displayed to the end user.
* The length of enum and enumNames array must match
*
* @return the list of enum names
* @since com.adobe.cq.forms.core.components.models.form 5.4.0
*/
@JsonProperty("enumNames")
TextContent[] getEnumNamesAsTextContent();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* version, is bound to this proxy component resource type.
* </p>
*/
@Version("5.4.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650
@Version("5.3.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650
package com.adobe.cq.forms.core.components.models.form;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

import com.adobe.cq.forms.core.components.models.form.Field;
import com.adobe.cq.forms.core.components.models.form.OptionsConstraint;
import com.adobe.cq.forms.core.components.models.form.TextContent;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
* Abstract class which can be used as base class for options {@link Field} implementations.
Expand All @@ -52,10 +49,6 @@ public abstract class AbstractOptionsFieldImpl extends AbstractFieldImpl impleme
@Nullable
protected String[] enumNames;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "areOptionsRichText")
@Nullable
private Boolean areOptionsRichText;

@Override
public boolean isEnforceEnum() {
return enforceEnum;
Expand Down Expand Up @@ -102,8 +95,6 @@ public Object[] getEnums() {
}

@Override
@Deprecated
@JsonIgnore
public String[] getEnumNames() {
if (enumNames != null) {
Map<Object, String> map = removeDuplicates();
Expand All @@ -117,29 +108,6 @@ public String[] getEnumNames() {
return null;
}

@Override
public TextContent[] getEnumNamesAsTextContent() {
if (enumNames != null) {
Map<Object, String> map = removeDuplicates();
String[] enumName = map.values().toArray(new String[0]);
return Arrays.stream(enumName)
.map(p -> new TextContent() {
@Override
@JsonInclude(JsonInclude.Include.NON_NULL)
public @Nullable Boolean isRichText() {
return areOptionsRichText;
}

@Override
public @Nullable String getValue() {
return translate("enumNames", p);
}
})
.toArray(TextContent[]::new);
}
return null;
}

@Override
public Object[] getDefault() {
Object[] typedDefaultValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -297,44 +296,6 @@ void testGetType() {
void testGetEnumNames() {
CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP);
assertArrayEquals(new String[] { "m", "f", "o" }, checkboxGroup.getEnumNames());
TextContent textContent1 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "m";
}
};
TextContent textContent2 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "f";
}
};
TextContent textContent3 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "o";
}
};
TextContent[] textContent = new TextContent[] { textContent1, textContent2, textContent3 };
for (int i = 0; i < checkboxGroup.getEnumNamesAsTextContent().length; i++) {
assertEquals(textContent[i].getValue(), checkboxGroup.getEnumNamesAsTextContent()[i].getValue());
assertEquals(textContent[i].isRichText(), checkboxGroup.getEnumNamesAsTextContent()[i].isRichText());
}
}

@Test
Expand All @@ -345,9 +306,6 @@ void testGetEnumNamesWithDuplicateEnumValues() {
map.put("1", "Item 2");
map.put("0", "Item 3");
assertArrayEquals(map.values().toArray(new String[0]), checkboxGroup.getEnumNames());
String[] checkboxGroupValues = Arrays.stream(checkboxGroup.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray(
size -> new String[checkboxGroup.getEnumNamesAsTextContent().length]);
assertArrayEquals(map.values().toArray(new String[0]), checkboxGroupValues);
}

@Test
Expand Down Expand Up @@ -428,8 +386,5 @@ void testInsertionOrderForEnumNames() {
Set<String> set = new LinkedHashSet<>(Arrays.asList("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty"));
assertArrayEquals(set.toArray(new String[0]), checkboxGroup.getEnumNames());
String[] checkboxGroupValues = Arrays.stream(checkboxGroup.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray(
size -> new String[checkboxGroup.getEnumNamesAsTextContent().length]);
assertArrayEquals(set.toArray(new String[0]), checkboxGroupValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@

import com.adobe.cq.forms.core.Utils;
import com.adobe.cq.forms.core.components.internal.form.FormConstants;
import com.adobe.cq.forms.core.components.models.form.*;
import com.adobe.cq.forms.core.components.models.form.Base;
import com.adobe.cq.forms.core.components.models.form.CheckBox;
import com.adobe.cq.forms.core.components.models.form.CheckBox.Orientation;
import com.adobe.cq.forms.core.components.models.form.ConstraintType;
import com.adobe.cq.forms.core.components.models.form.FieldType;
import com.adobe.cq.forms.core.components.models.form.Label;
import com.adobe.cq.forms.core.context.FormsCoreComponentTestContext;
import com.adobe.cq.wcm.style.ComponentStyleInfo;
import io.wcm.testing.mock.aem.junit5.AemContext;
Expand Down Expand Up @@ -305,16 +309,6 @@ void testGetEnum() {

}

@Test
void testGetNullEnumNames() {
CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX);
assertNull(checkbox.getEnumNamesAsTextContent());
assertNull(checkbox.getEnumNames());
CheckBox noEnumCheckbox = getCheckBoxUnderTest(PATH_CHECKBOX_NOENUM);
assertNull(noEnumCheckbox.getEnumNamesAsTextContent());
assertNull(noEnumCheckbox.getEnumNames());
}

@Test
void testGetNullEnum() {
CheckBox noEnumCheckbox = getCheckBoxUnderTest(PATH_CHECKBOX_NOENUM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -380,44 +379,6 @@ void testGetMultiSelectMaxItems() {
void testGetEnumNames() {
DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN_1, DropDown.class, context);
assertArrayEquals(new String[] { "m", "f", "o" }, dropdown.getEnumNames());
TextContent textContent1 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "m";
}
};
TextContent textContent2 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "f";
}
};
TextContent textContent3 = new TextContent() {
@Override
public @Nullable Boolean isRichText() {
return null;
}

@Override
public @Nullable String getValue() {
return "o";
}
};
TextContent[] textContent = new TextContent[] { textContent1, textContent2, textContent3 };
for (int i = 0; i < dropdown.getEnumNamesAsTextContent().length; i++) {
assertEquals(textContent[i].getValue(), dropdown.getEnumNamesAsTextContent()[i].getValue());
assertEquals(textContent[i].isRichText(), dropdown.getEnumNamesAsTextContent()[i].isRichText());
}
}

@Test
Expand All @@ -428,10 +389,6 @@ void testGetEnumNamesWithDuplicateEnumValues() {
map.put("1", "Item 2");
map.put("0", "Item 3");
assertArrayEquals(map.values().toArray(new String[0]), dropdown.getEnumNames());
String[] dropdownValues = Arrays.stream(dropdown.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray(
size -> new String[dropdown
.getEnumNamesAsTextContent().length]);
assertArrayEquals(map.values().toArray(new String[0]), dropdownValues);
}

@Test
Expand Down Expand Up @@ -481,9 +438,5 @@ void testInsertionOrderForEnumNames() {
Set<String> set = new LinkedHashSet<>(Arrays.asList("Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty"));
assertArrayEquals(set.toArray(new String[0]), dropdown.getEnumNames());
String[] dropdownValues = Arrays.stream(dropdown.getEnumNamesAsTextContent()).map(d -> d.getValue()).toArray(
size -> new String[dropdown
.getEnumNamesAsTextContent().length]);
assertArrayEquals(set.toArray(new String[0]), dropdownValues);
}
}
Loading