Skip to content

Commit

Permalink
Remove 'public' modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Feb 8, 2024
1 parent a6d7518 commit 57243b0
Showing 1 changed file with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class NodeAdapterTest {
public static final String NON_UNUSED_PARAMETERS = "EXPECTED_NONE";

@Test
public void testAsRawNode() {
void testAsRawNode() {
NodeAdapter subject = newNodeAdapterForTest("{ child : { foo : 'bar' } }");

// Define child
Expand All @@ -53,7 +53,7 @@ public void testAsRawNode() {
}

@Test
public void isEmpty() {
void isEmpty() {
NodeAdapter subject = newNodeAdapterForTest("");
assertTrue(subject.of("alf").asObject().isEmpty());

Expand All @@ -64,15 +64,15 @@ public void isEmpty() {
}

@Test
public void path() {
void path() {
NodeAdapter subject = newNodeAdapterForTest("{ foo : 'bar' }");
assertFalse(subject.of("foo").asObject().isEmpty());
assertTrue(subject.of("missingObject").asObject().isEmpty());
assertEquals(NON_UNUSED_PARAMETERS, unusedParams(subject));
}

@Test
public void docInfo() {
void docInfo() {
NodeAdapter subject = newNodeAdapterForTest("{ bool: false }");
subject.of("bool").since(V2_0).summary("B Summary").description("Ddd").asBoolean();
subject.of("en").since(V2_1).summary("EN Summary").asEnum(SECONDS);
Expand All @@ -95,44 +95,44 @@ public void docInfo() {
}

@Test
public void asBoolean() {
void asBoolean() {
NodeAdapter subject = newNodeAdapterForTest("{ aBoolean : true }");
assertTrue(subject.of("aBoolean").asBoolean());
assertTrue(subject.of("aBoolean").asBoolean(false));
assertFalse(subject.of("missingField").asBoolean(false));
}

@Test
public void asDouble() {
void asDouble() {
NodeAdapter subject = newNodeAdapterForTest("{ aDouble : 7.0 }");
assertEquals(7.0, subject.of("aDouble").asDouble(-1d), 0.01);
assertEquals(7.0, subject.of("aDouble").asDouble(), 0.01);
assertEquals(-1d, subject.of("missingField").asDouble(-1d), 00.1);
}

@Test
public void asDoubles() {
void asDoubles() {
NodeAdapter subject = newNodeAdapterForTest("{ key : [ 2.0, 3.0, 5.0 ] }");
assertEquals(List.of(2d, 3d, 5d), subject.of("key").asDoubles(null));
assertEquals(NON_UNUSED_PARAMETERS, unusedParams(subject));
}

@Test
public void asInt() {
void asInt() {
NodeAdapter subject = newNodeAdapterForTest("{ aInt : 5 }");
assertEquals(5, subject.of("aInt").asInt(-1));
assertEquals(-1, subject.of("missingField").asInt(-1));
}

@Test
public void asLong() {
void asLong() {
NodeAdapter subject = newNodeAdapterForTest("{ key : 5 }");
assertEquals(5, subject.of("key").asLong(-1));
assertEquals(-1, subject.of("missingField").asLong(-1));
}

@Test
public void asText() {
void asText() {
NodeAdapter subject = newNodeAdapterForTest("{ aText : 'TEXT' }");
assertEquals("TEXT", subject.of("aText").asString("DEFAULT"));
assertEquals("DEFAULT", subject.of("missingField").asString("DEFAULT"));
Expand All @@ -142,19 +142,19 @@ public void asText() {
}

@Test
public void requiredAsText() {
void requiredAsText() {
NodeAdapter subject = newNodeAdapterForTest("{ }");
assertThrows(OtpAppException.class, () -> subject.of("missingField").asString());
}

@Test
public void rawAsText() {
void rawAsText() {
NodeAdapter subject = newNodeAdapterForTest("{ aText : 'TEXT' }");
assertEquals("TEXT", subject.of("aText").asObject().asText());
}

@Test
public void asEnum() {
void asEnum() {
// Given
NodeAdapter subject = newNodeAdapterForTest("{ a : 'A', abc : 'a-b-c' }");

Expand All @@ -169,7 +169,7 @@ public void asEnum() {
}

@Test
public void asEnumWithIllegalPropertySet() {
void asEnumWithIllegalPropertySet() {
// Given
NodeAdapter subject = newNodeAdapterForTest(
"""
Expand Down Expand Up @@ -205,7 +205,7 @@ public void asEnumWithIllegalPropertySet() {
}

@Test
public void asEnumMap() {
void asEnumMap() {
// With optional enum values in map
NodeAdapter subject = newNodeAdapterForTest("{ key : { A: true, B: false } }");
assertEquals(
Expand All @@ -220,7 +220,7 @@ public void asEnumMap() {
}

@Test
public void asEnumMapWithCustomType() {
void asEnumMapWithCustomType() {
// With optional enum values in map
NodeAdapter subject = newNodeAdapterForTest("{ key : { A: {a:'Foo'} } }");
assertEquals(
Expand All @@ -235,15 +235,15 @@ public void asEnumMapWithCustomType() {
}

@Test
public void asEnumMapWithDefaultValue() {
void asEnumMapWithDefaultValue() {
var subject = newNodeAdapterForTest("{}");
final Map<AnEnum, ARecord> dflt = Map.of(AnEnum.A, new ARecord("Foo"));
assertEquals(dflt, subject.of("key").asEnumMap(AnEnum.class, ARecord::fromJson, dflt));
assertEquals(NON_UNUSED_PARAMETERS, unusedParams(subject));
}

@Test
public void asEnumMapWithUnknownKey() {
void asEnumMapWithUnknownKey() {
NodeAdapter subject = newNodeAdapterForTest("{ enumMap : { unknown : 7 } }");

subject.of("enumMap").asEnumMap(AnEnum.class, Double.class);
Expand All @@ -261,7 +261,7 @@ public void asEnumMapWithUnknownKey() {
}

@Test
public void asEnumMapAllKeysRequired() {
void asEnumMapAllKeysRequired() {
var subject = newNodeAdapterForTest("{ key : { A: true, b: false, a_B_c: true } }");
assertEquals(
Map.of(AnEnum.A, true, AnEnum.B, false, AnEnum.A_B_C, true),
Expand All @@ -280,7 +280,7 @@ public void asEnumMapAllKeysRequired() {
}

@Test
public void asEnumMapWithRequiredMissingValue() {
void asEnumMapWithRequiredMissingValue() {
// A value for C is missing in map
NodeAdapter subject = newNodeAdapterForTest("{ key : { A: true, B: false } }");

Expand All @@ -291,21 +291,21 @@ public void asEnumMapWithRequiredMissingValue() {
}

@Test
public void asEnumSet() {
void asEnumSet() {
NodeAdapter subject = newNodeAdapterForTest("{ key : [ 'A', 'B' ] }");
assertEquals(Set.of(AnEnum.A, AnEnum.B), subject.of("key").asEnumSet(AnEnum.class));
assertEquals(Set.of(), subject.of("missing-key").asEnumSet(AnEnum.class));
assertEquals(NON_UNUSED_PARAMETERS, unusedParams(subject));
}

@Test
public void asEnumSetFailsUsingWrongFormat() {
void asEnumSetFailsUsingWrongFormat() {
NodeAdapter subject = newNodeAdapterForTest("{ key : 'A,B' }");
assertThrows(OtpAppException.class, () -> subject.of("key").asEnumSet(AnEnum.class));
}

@Test
public void asFeedScopedId() {
void asFeedScopedId() {
NodeAdapter subject = newNodeAdapterForTest("{ key1: 'A:23', key2: 'B:12' }");
assertEquals("A:23", subject.of("key1").asFeedScopedId(null).toString());
assertEquals("B:12", subject.of("key2").asFeedScopedId(null).toString());
Expand All @@ -316,7 +316,7 @@ public void asFeedScopedId() {
}

@Test
public void asFeedScopedIds() {
void asFeedScopedIds() {
NodeAdapter subject = newNodeAdapterForTest("{ routes: ['A:23', 'B:12']}");
assertEquals("[A:23, B:12]", subject.of("routes").asFeedScopedIds(List.of()).toString());
assertEquals("[]", subject.of("missing-key").asFeedScopedIds(List.of()).toString());
Expand All @@ -328,7 +328,7 @@ public void asFeedScopedIds() {
}

@Test
public void asFeedScopedIdSet() {
void asFeedScopedIdSet() {
NodeAdapter subject = newNodeAdapterForTest("{ routes: ['A:23', 'B:12', 'A:23']}");
assertEquals(
List.of(
Expand All @@ -342,7 +342,7 @@ public void asFeedScopedIdSet() {
}

@Test
public void asDateOrRelativePeriod() {
void asDateOrRelativePeriod() {
// Given
var subject = newNodeAdapterForTest("{ 'a' : '2020-02-28', 'b' : '-P3Y' }");
var utc = ZoneIds.UTC;
Expand All @@ -362,7 +362,7 @@ public void asDateOrRelativePeriod() {
}

@Test
public void testParsePeriodDateThrowsException() {
void testParsePeriodDateThrowsException() {
// Given
NodeAdapter subject = newNodeAdapterForTest("{ 'foo' : 'bar' }");

Expand All @@ -374,7 +374,7 @@ public void testParsePeriodDateThrowsException() {
}

@Test
public void asDuration() {
void asDuration() {
NodeAdapter subject = newNodeAdapterForTest("{ k1:'PT1s', k2:'3h2m1s', k3:7 }");

// as required duration
Expand All @@ -390,21 +390,21 @@ public void asDuration() {
}

@Test
public void requiredAsDuration() {
void requiredAsDuration() {
NodeAdapter subject = newNodeAdapterForTest("{ }");
assertThrows(OtpAppException.class, () -> subject.of("missingField").asDuration());
}

@Test
public void asDurations() {
void asDurations() {
NodeAdapter subject = newNodeAdapterForTest("{ key1 : ['PT1s', '2h'] }");
assertEquals("[PT1S, PT2H]", subject.of("key1").asDurations(List.of()).toString());
assertEquals("[PT3H]", subject.of("missing-key").asDurations(List.of(D3h)).toString());
assertEquals(NON_UNUSED_PARAMETERS, unusedParams(subject));
}

@Test
public void asLocale() {
void asLocale() {
NodeAdapter subject = newNodeAdapterForTest(
"{ key1 : 'no', key2 : 'no_NO', key3 : 'no_NO_NY' }"
);
Expand All @@ -415,14 +415,14 @@ public void asLocale() {
}

@Test
public void asPattern() {
void asPattern() {
NodeAdapter subject = newNodeAdapterForTest("{ key : 'Ab*a' }");
assertEquals("Ab*a", subject.of("key").asPattern("ABC").toString());
assertEquals("ABC", subject.of("missingField").asPattern("ABC").toString());
}

@Test
public void uri() {
void uri() {
var URL = "gs://bucket/a.obj";
NodeAdapter subject = newNodeAdapterForTest("{ aUri : '" + URL + "' }");

Expand All @@ -433,14 +433,14 @@ public void uri() {
}

@Test
public void uriSyntaxException() {
void uriSyntaxException() {
NodeAdapter subject = newNodeAdapterForTest("{ aUri : 'error$%uri' }");

assertThrows(OtpAppException.class, () -> subject.of("aUri").asUri(null), "error$%uri");
}

@Test
public void uriRequiredValueMissing() {
void uriRequiredValueMissing() {
NodeAdapter subject = newNodeAdapterForTest("{ }");

assertThrows(
Expand All @@ -451,7 +451,7 @@ public void uriRequiredValueMissing() {
}

@Test
public void uris() {
void uris() {
NodeAdapter subject = newNodeAdapterForTest("{ foo : ['gs://a/b', 'gs://c/d'] }");
assertEquals("[gs://a/b, gs://c/d]", subject.of("foo").asUris().toString());

Expand All @@ -461,7 +461,7 @@ public void uris() {
}

@Test
public void urisNotAnArrayException() {
void urisNotAnArrayException() {
NodeAdapter subject = newNodeAdapterForTest("{ 'uris': 'no array' }");

assertThrows(
Expand All @@ -472,7 +472,7 @@ public void urisNotAnArrayException() {
}

@Test
public void objectAsList() {
void objectAsList() {
NodeAdapter subject = newNodeAdapterForTest("{ key : [{ a: 'I' }, { a: '2' } ] }");

List<ARecord> result = subject
Expand All @@ -487,21 +487,21 @@ public void objectAsList() {
}

@Test
public void asCostLinearFunction() {
void asCostLinearFunction() {
NodeAdapter subject = newNodeAdapterForTest("{ key : '400+8x' }");
assertEquals("6m40s + 8.0 t", subject.of("key").asCostLinearFunction(null).toString());
assertNull(subject.of("no-key").asCostLinearFunction(null));
}

@Test
public void asTimePenalty() {
void asTimePenalty() {
NodeAdapter subject = newNodeAdapterForTest("{ key : '400+8x' }");
assertEquals("6m40s + 8.0 t", subject.of("key").asTimePenalty(null).toString());
assertNull(subject.of("no-key").asTimePenalty(null));
}

@Test
public void asZoneId() {
void asZoneId() {
NodeAdapter subject = newNodeAdapterForTest(
"{ key1 : 'UTC', key2 : 'Europe/Oslo', key3 : '+02:00', key4: 'invalid' }"
);
Expand All @@ -515,7 +515,7 @@ public void asZoneId() {
}

@Test
public void asTextSet() {
void asTextSet() {
NodeAdapter subject = newNodeAdapterForTest("{ ids : ['A', 'C', 'F'] }");
assertEquals(
Set.of("A", "C", "F"),
Expand All @@ -528,7 +528,7 @@ public void asTextSet() {
}

@Test
public void isNonEmptyArray() {
void isNonEmptyArray() {
NodeAdapter subject = newNodeAdapterForTest("{ foo : ['A'], bar: [], foobar: true }");
assertTrue(subject.of("foo").asObject().isNonEmptyArray());
assertFalse(subject.of("bar").asObject().isNonEmptyArray());
Expand All @@ -538,13 +538,13 @@ public void isNonEmptyArray() {
}

@Test
public void deduplicateChildren() {
void deduplicateChildren() {
NodeAdapter subject = newNodeAdapterForTest("{ foo : { enabled: true } }");
assertSame(subject.of("foo").asObject(), subject.of("foo").asObject());
}

@Test
public void unusedParams() {
void unusedParams() {
// Given: two parameters a and b
NodeAdapter subject = newNodeAdapterForTest("{ foo : { a: true, b: false } }");
var buf = new StringBuilder();
Expand Down

0 comments on commit 57243b0

Please sign in to comment.