Skip to content

Fix a number of flaky tests #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7d82a60
added travis-ci config
mohasarc Apr 13, 2021
df05bf6
made ObjectMapper sort properties alphabetically
mohasarc Apr 13, 2021
19ce67c
Delete .travis.yml
mohasarc Jun 10, 2021
dda147b
fixed the test: Jackson2ParserTest#test
mohasarc Jun 11, 2021
590bd14
fixed ClassesTest.testUnsortedConstructor text
mohasarc Jun 11, 2021
d22d4c0
fixed a number of tests of OptionalTest
mohasarc Jun 11, 2021
77de054
fixed all flaky tests of TaggedUnionsTest and improved Jackson2Parser…
mohasarc Jun 11, 2021
12d0e0c
partially fixed JavadocTest.testJavadoc
mohasarc Jun 12, 2021
a80d258
partially fixed ReadOnlyWriteOnlyTest.test
mohasarc Jun 12, 2021
b3f19bf
fixed the test TaggedUnionsTest.testIntermediateUnions
mohasarc Jun 12, 2021
45b45a1
improved JaxrsApplicationTest.testEnumQueryParam
mohasarc Jun 12, 2021
12631f9
Merge branch 'master' into fix-flaky-property-order
mohasarc Jun 14, 2021
fb56323
reverted back the changes to JaxrsApplicationTest.testEnumQueryParam
mohasarc Jun 14, 2021
399e586
fixed the test Jackson2ParserPropertiesTest.testPropertyOrder
mohasarc Jun 20, 2021
1187ca2
changed variable names for clarity
mohasarc Jun 20, 2021
6bc43d9
reverted the indentation to how it was
mohasarc Jun 20, 2021
9b76530
reverted back the changes to items order
mohasarc Jun 21, 2021
1bf2625
added the sorting code again while changing the third comparator into…
mohasarc Jun 22, 2021
adef19c
readded deleted spaces
mohasarc Jun 22, 2021
a51d594
added more spaces
mohasarc Jun 22, 2021
d91e544
reverted back some changes
mohasarc Jun 23, 2021
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 @@ -23,6 +23,7 @@
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig;
Expand Down Expand Up @@ -113,7 +114,8 @@ public JaxbParserFactory() {

}

private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectMapper objectMapper = new ObjectMapper()
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

public Jackson2Parser(Settings settings, TypeProcessor typeProcessor) {
this(settings, typeProcessor, Collections.emptyList(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ public void testUnsortedConstructor() {
settings.sortDeclarations = false;
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(FooBar.class));
String unsortedPropertyAssignments = "" +
" this.foo = data.foo;" + settings.newline +
" this.bar = data.bar;";
" this.bar = data.bar;" + settings.newline +
" this.foo = data.foo;";
Assert.assertTrue(output.contains(unsortedPropertyAssignments));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void test() {
final BeanModel beanModel = model.getBeans().get(0);
Assert.assertEquals("DummyBean", beanModel.getOrigin().getSimpleName());
Assert.assertTrue(beanModel.getProperties().size() > 0);
Assert.assertEquals("firstProperty", beanModel.getProperties().get(0).getName());
Assert.assertEquals("booleanProperty", beanModel.getProperties().get(0).getName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public void testJavadoc() {
Assert.assertEquals("Documentation for ClassWithJavadoc. First line.", bean.getComments().get(0));
Assert.assertEquals("Second line.", bean.getComments().get(1));
final PropertyModel property1 = bean.getProperties().get(0);
Assert.assertEquals("Documentation for documentedField.", property1.getComments().get(0));
Assert.assertEquals("Documentation for documentedEnumField.", property1.getComments().get(0));
final PropertyModel property2 = bean.getProperties().get(1);
Assert.assertEquals("Documentation for documentedEnumField.", property2.getComments().get(0));
Assert.assertEquals("Documentation for documentedField.", property2.getComments().get(0));
final EnumModel enumModel = model.getEnums().get(0);
Assert.assertEquals("Documentation for DummyEnum.", enumModel.getComments().get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public void test() {
final String output = new TypeScriptGenerator(TestUtils.settings()).generateTypeScript(Input.from(Person.class));
Assert.assertEquals(
"interface Person {\n" +
" name: string;\n" +
" email?: string;\n" +
" age?: number;\n" +
" email?: string;\n" +
" name: string;\n" +
"}",
output.trim());
}
Expand Down Expand Up @@ -53,9 +53,9 @@ public void testJackson2OptionalSupport() throws Exception {
public void testDeclarationQuestionMark() {
testDeclaration(OptionalPropertiesDeclaration.questionMark,
"interface Person {\n" +
" name: string;\n" +
" email?: string;\n" +
" age?: number;\n" +
" email?: string;\n" +
" name: string;\n" +
"}"
);
}
Expand All @@ -64,9 +64,9 @@ public void testDeclarationQuestionMark() {
public void testDeclarationNullableType() {
testDeclaration(OptionalPropertiesDeclaration.nullableType,
"interface Person {\n" +
" name: string;\n" +
" email: string | null;\n" +
" age: number | null;\n" +
" email: string | null;\n" +
" name: string;\n" +
"}"
);
}
Expand All @@ -75,9 +75,9 @@ public void testDeclarationNullableType() {
public void testDeclarationQuestionMarkAndNullableType() {
testDeclaration(OptionalPropertiesDeclaration.questionMarkAndNullableType,
"interface Person {\n" +
" name: string;\n" +
" email?: string | null;\n" +
" age?: number | null;\n" +
" email?: string | null;\n" +
" name: string;\n" +
"}"
);
}
Expand All @@ -86,9 +86,9 @@ public void testDeclarationQuestionMarkAndNullableType() {
public void testDeclarationNullableAndUndefinableType() {
testDeclaration(OptionalPropertiesDeclaration.nullableAndUndefinableType,
"interface Person {\n" +
" name: string;\n" +
" email: string | null | undefined;\n" +
" age: number | null | undefined;\n" +
" email: string | null | undefined;\n" +
" name: string;\n" +
"}"
);
}
Expand All @@ -97,9 +97,9 @@ public void testDeclarationNullableAndUndefinableType() {
public void testDeclarationUndefinableType() {
testDeclaration(OptionalPropertiesDeclaration.undefinableType,
"interface Person {\n" +
" name: string;\n" +
" email: string | undefined;\n" +
" age: number | undefined;\n" +
" email: string | undefined;\n" +
" name: string;\n" +
"}"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ public void test() {
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ReadOnlyWriteOnlyUser.class));
final String expected = "\n"
+ "interface ReadOnlyWriteOnlyUser {\n"
+ " name: string;\n"
+ " /**\n"
+ " * @readonly\n"
+ " */\n"
+ " id1: string;\n"
+ " /**\n"
+ " * @writeonly\n"
+ " */\n"
+ " password1: string;\n"
+ " /**\n"
+ " * @readonly\n"
+ " */\n"
+ " id2: string;\n"
+ " name: string;\n"
+ " /**\n"
+ " * @writeonly\n"
+ " */\n"
+ " password1: string;\n"
+ " /**\n"
+ " * @writeonly\n"
+ " */\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ public void testTaggedUnions() {
"\n" +
"interface Rectangle extends Shape {\n" +
" kind: 'rectangle';\n" +
" width: number;\n" +
" height: number;\n" +
" width: number;\n" +
"}\n" +
"\n" +
"interface Circle extends Shape {\n" +
Expand Down Expand Up @@ -238,8 +238,8 @@ public void testTaggedUnionsWithInterfaces() {
"\n" +
"interface CRectangle2 extends IQuadrilateral2 {\n" +
" kind: 'rectangle';\n" +
" width: number;\n" +
" height: number;\n" +
" width: number;\n" +
"}\n" +
"\n" +
"interface CCircle2 extends IShape2 {\n" +
Expand Down Expand Up @@ -315,8 +315,8 @@ public void testTaggedUnionsDisabled() {
"\n" +
"interface Rectangle extends Shape {\n" +
" kind: 'rectangle';\n" +
" width: number;\n" +
" height: number;\n" +
" width: number;\n" +
"}\n" +
"\n" +
"interface Circle extends Shape {\n" +
Expand Down Expand Up @@ -518,8 +518,8 @@ public void testTaggedUnionsWithExistingProperty() {
"\n" +
"interface Rectangle2 extends Shape2 {\n" +
" kind: 'rectangle';\n" +
" width: number;\n" +
" height: number;\n" +
" width: number;\n" +
"}\n" +
"\n" +
"interface Circle2 extends Shape2 {\n" +
Expand Down Expand Up @@ -553,8 +553,8 @@ public void testTaggedUnionDisabledUsingAnnotation() {
"}\n" +
"\n" +
"interface Rectangle2 extends Shape2 {\n" +
" width: number;\n" +
" height: number;\n" +
" width: number;\n" +
"}\n" +
"\n" +
"interface Circle2 extends Shape2 {\n" +
Expand Down Expand Up @@ -647,13 +647,9 @@ public void testIntermediateUnions() {
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(RecordUsage.class));
final String expected = ""
+ "interface RecordUsage {\n"
+ " records: RecordUnion[];\n"
+ " formRecords: FormRecordUnion[];\n"
+ " listRecords: ListRecordUnion[];\n"
+ "}\n"
+ "\n"
+ "interface Record {\n"
+ " '@type': 'order.form' | 'product.form' | 'order.list' | 'product.list';\n"
+ " records: RecordUnion[];\n"
+ "}\n"
+ "\n"
+ "interface FormRecord extends Record {\n"
Expand All @@ -664,6 +660,10 @@ public void testIntermediateUnions() {
+ " '@type': 'order.list' | 'product.list';\n"
+ "}\n"
+ "\n"
+ "interface Record {\n"
+ " '@type': 'order.form' | 'product.form' | 'order.list' | 'product.list';\n"
+ "}\n"
+ "\n"
+ "interface OrderFormRecord extends FormRecord {\n"
+ " '@type': 'order.form';\n"
+ "}\n"
Expand All @@ -680,11 +680,11 @@ public void testIntermediateUnions() {
+ " '@type': 'product.list';\n"
+ "}\n"
+ "\n"
+ "type RecordUnion = FormRecord | ListRecord;\n"
+ "\n"
+ "type FormRecordUnion = OrderFormRecord | ProductFormRecord;\n"
+ "\n"
+ "type ListRecordUnion = OrderListRecord | ProductListRecord;\n"
+ "\n"
+ "type RecordUnion = FormRecord | ListRecord;\n"
+ "";
Assert.assertEquals(expected.trim(), output.trim());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public static class User4 {

@Test
public void testPropertyOrder() {
Assert.assertEquals(Arrays.asList("password1", "id2", "name", "id1", "password2"), getProperties(UserOrdered.class));
Assert.assertEquals(Arrays.asList("password1", "id2", "id1", "name", "password2"), getProperties(UserOrdered.class));
Assert.assertEquals(Arrays.asList("id1", "id2", "name", "password1", "password2"), getProperties(UserAlphabetic.class));
Assert.assertEquals(Arrays.asList("password2", "password1", "id2", "id1", "name"), getProperties(UserIndexed.class));
Assert.assertEquals(Arrays.asList("name", "id1", "id2", "password1", "password2"), getProperties(User1.class));
Assert.assertEquals(Arrays.asList("name", "id1", "id2", "password1", "password2"), getProperties(User2.class));
Assert.assertEquals(Arrays.asList("name", "password1", "password2", "id1", "id2"), getProperties(User3.class));
Assert.assertEquals(Arrays.asList("id1", "id2", "name", "password1", "password2"), getProperties(User1.class));
Assert.assertEquals(Arrays.asList("id1", "id2", "name", "password1", "password2"), getProperties(User2.class));
Assert.assertEquals(Arrays.asList("id1", "id2", "name", "password1", "password2"), getProperties(User3.class));
Assert.assertEquals(Arrays.asList("password1", "id1", "password2", "id2", "name"), getProperties(User4.class));
}

Expand Down