Skip to content

Commit

Permalink
FORMS-3696 resolving test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam Agarwal committed Sep 27, 2023
1 parent 5b2c671 commit 2166b51
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ void testGetType() {
@Test
void testGetEnumNames() {
CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP);
assertArrayEquals(new String[] { "m", "f", "o" }, checkboxGroup.getEnumNames());
RichText richText1 = new RichText() {
@Override
public @Nullable Boolean isRichText() {
Expand Down Expand Up @@ -342,7 +341,8 @@ void testGetEnumNamesWithDuplicateEnumValues() {
map.put("0", "Item 1");
map.put("1", "Item 2");
map.put("0", "Item 3");
assertArrayEquals(map.values().toArray(new String[0]), checkboxGroup.getEnumNames());
String[] checkboxGroupValues = Arrays.stream(checkboxGroup.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[checkboxGroup.getEnumNames().length]);
assertArrayEquals(map.values().toArray(new String[0]), checkboxGroupValues);
}

@Test
Expand Down Expand Up @@ -415,6 +415,7 @@ void testInsertionOrderForEnumNames() {
CheckBoxGroup checkboxGroup = getCheckBoxGroupUnderTest(PATH_CHECKBOX_GROUP_FOR_INSERTION_ORDER);
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.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[checkboxGroup.getEnumNames().length]);
assertArrayEquals(set.toArray(new String[0]), checkboxGroupValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,35 +307,11 @@ void testGetEnum() {
}

@Test
void testGetEnumNames() {
void testGetNullEnumNames() {
CheckBox checkbox = getCheckBoxUnderTest(PATH_CHECKBOX);
RichText richText1 = new RichText() {
@Override
public @Nullable Boolean isRichText() {
return false;
}

@Override
public @Nullable String getValue() {
return "yes";
}
};
RichText richText2 = new RichText() {
@Override
public @Nullable Boolean isRichText() {
return false;
}

@Override
public @Nullable String getValue() {
return "no";
}
};
RichText[] richText = new RichText[] { richText1, richText2 };
for (int i = 0; i < checkbox.getEnumNames().length; i++) {
assertEquals(richText[i].getValue(), checkbox.getEnumNames()[i].getValue());
assertEquals(richText[i].isRichText(), checkbox.getEnumNames()[i].isRichText());
}
assertNull(checkbox.getEnumNames());
CheckBox noEnumCheckbox = getCheckBoxUnderTest(PATH_CHECKBOX_NOENUM);
assertNull(noEnumCheckbox.getEnumNames());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ void testGetEnumNamesWithDuplicateEnumValues() {
map.put("0", "Item 1");
map.put("1", "Item 2");
map.put("0", "Item 3");
assertArrayEquals(map.values().toArray(new String[0]), dropdown.getEnumNames());
String[] dropdownValues = Arrays.stream(dropdown.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[dropdown.getEnumNames().length]);
assertArrayEquals(map.values().toArray(new String[0]), dropdownValues);
}

@Test
Expand Down Expand Up @@ -475,6 +476,7 @@ void testInsertionOrderForEnumNames() {
DropDown dropdown = Utils.getComponentUnderTest(PATH_DROPDOWN_FOR_INSERTION_ORDER, DropDown.class, context);
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.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[dropdown.getEnumNames().length]);
assertArrayEquals(set.toArray(new String[0]), dropdownValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ void testGetEnumNamesWithDuplicateEnumValues() {
map.put("0", "Item 1");
map.put("1", "Item 2");
map.put("0", "Item 3");
assertArrayEquals(map.values().toArray(new String[0]), radioButton.getEnumNames());
String[] radioButtonValues = Arrays.stream(radioButton.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[radioButton.getEnumNames().length]);
assertArrayEquals(map.values().toArray(new String[0]), radioButtonValues);
}

@Test
Expand Down Expand Up @@ -415,6 +416,7 @@ void testInsertionOrderForEnumNames() {
RadioButton radioButton = getRadioButtonUnderTest(PATH_RADIOBUTTON_FOR_INSERTION_ORDER);
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]), radioButton.getEnumNames());
String[] radioButtonValues = Arrays.stream(radioButton.getEnumNames()).map(d -> d.getValue()).toArray(size -> new String[radioButton.getEnumNames().length]);
assertArrayEquals(set.toArray(new String[0]), radioButtonValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
"readOnly": false,
"enforceEnum": true,
"enumNames": [
"Cat Person",
"Dog Person"
{
"richText": false,
"value": "Cat Person"
},
{
"richText": false,
"value": "Dog Person"
}
],
"label": {
"value": "Personality"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
"readOnly": false,
"enforceEnum": true,
"enumNames": [
"Owl",
"Wolf"
{
"richText": false,
"value": "Owl"
},
{
"richText": false,
"value": "Wolf"
}
],
"label": {
"value": "Favorite Animal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"richText": false,
"value": "o"
}s
}
],
"enum": ["0", "1", "2"],
"label": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
"readOnly": false,
"enforceEnum": true,
"enumNames": [
"Male",
"Female"
{
"richText": false,
"value": "Male"
},
{
"richText": false,
"value": "Female"
}
],
"label": {
"value": "Gender"
Expand Down

0 comments on commit 2166b51

Please sign in to comment.