Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/brenoepics/at4j
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Jan 16, 2024
2 parents ee0a471 + 2729b30 commit a413222
Showing 1 changed file with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,49 @@

class RestRequestResultErrorCodeTest {

@Test
void test_all_enum_values() {
for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
Optional<RestRequestResultErrorCode> retrievedErrorCode = RestRequestResultErrorCode.fromCode(errorCode.getCode(), errorCode.getResponseCode());
assertTrue(retrievedErrorCode.isPresent());
assertEquals(errorCode, retrievedErrorCode.get());
assertEquals(errorCode.getCode(), retrievedErrorCode.get().getCode());
assertEquals(errorCode.getMeaning(), retrievedErrorCode.get().getMeaning());
}
}

@Test
void test_getCode() {
Map<RestRequestResultErrorCode, Integer> expectedCodes = new HashMap<>();
expectedCodes.putAll(Arrays.stream(RestRequestResultErrorCode.values())
.collect(HashMap::new, (map, errorCode) -> map.put(errorCode, errorCode.getCode()), HashMap::putAll));

for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
int expectedCode = expectedCodes.get(errorCode);
int actualCode = errorCode.getCode();
assertEquals(expectedCode, actualCode);
}
}

@Test
void test_getMeaning() {
Map<RestRequestResultErrorCode, String> expectedMeanings = new HashMap<>();
expectedMeanings.putAll(Arrays.stream(RestRequestResultErrorCode.values())
.collect(HashMap::new, (map, errorCode) -> map.put(errorCode, errorCode.getMeaning()), HashMap::putAll));

for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
String expectedMeaning = expectedMeanings.get(errorCode);
String actualMeaning = errorCode.getMeaning();
assertEquals(expectedMeaning, actualMeaning);
}
}
}
@Test
void test_all_enum_values() {
for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
Optional<RestRequestResultErrorCode> retrievedErrorCode =
RestRequestResultErrorCode.fromCode(errorCode.getCode(), errorCode.getResponseCode());
assertTrue(retrievedErrorCode.isPresent());
assertEquals(errorCode, retrievedErrorCode.get());
assertEquals(errorCode.getCode(), retrievedErrorCode.get().getCode());
assertEquals(errorCode.getMeaning(), retrievedErrorCode.get().getMeaning());
}
}

@Test
void test_getCode() {
Map<RestRequestResultErrorCode, Integer> expectedCodes = new HashMap<>();
expectedCodes.putAll(
Arrays.stream(RestRequestResultErrorCode.values())
.collect(
HashMap::new,
(map, errorCode) -> map.put(errorCode, errorCode.getCode()),
HashMap::putAll));

for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
int expectedCode = expectedCodes.get(errorCode);
int actualCode = errorCode.getCode();
assertEquals(expectedCode, actualCode);
}
}

@Test
void test_getMeaning() {
Map<RestRequestResultErrorCode, String> expectedMeanings = new HashMap<>();
expectedMeanings.putAll(
Arrays.stream(RestRequestResultErrorCode.values())
.collect(
HashMap::new,
(map, errorCode) -> map.put(errorCode, errorCode.getMeaning()),
HashMap::putAll));

for (RestRequestResultErrorCode errorCode : RestRequestResultErrorCode.values()) {
String expectedMeaning = expectedMeanings.get(errorCode);
String actualMeaning = errorCode.getMeaning();
assertEquals(expectedMeaning, actualMeaning);
}
}
}

0 comments on commit a413222

Please sign in to comment.