JsonErrorUnmarshaller extends AbstractErrorUnmarshaller<JsonNode> { public boolean matchErrorCode(String actualErrorCode) { if (handledErrorCode == null) { return true; } return handledErrorCode.equals(actualErrorCode); } JsonErrorUnmarshaller(Class<? extends AmazonServiceException> exceptionClass, String handledErrorCode); @Override AmazonServiceException unmarshall(JsonNode jsonContent); boolean matchErrorCode(String actualErrorCode); static final JsonErrorUnmarshaller DEFAULT_UNMARSHALLER; }
@Test public void match_DefaultUnmarshaller_MatchesEverything() { unmarshaller = JsonErrorUnmarshaller.DEFAULT_UNMARSHALLER; assertTrue(unmarshaller.matchErrorCode(null)); assertTrue(unmarshaller.matchErrorCode("")); assertTrue(unmarshaller.matchErrorCode("someErrorCode")); }
@Test public void match_MatchingErrorCode_ReturnsTrue() throws Exception { assertTrue(unmarshaller.matchErrorCode(ERROR_TYPE)); }
@Test public void match_NonMatchingErrorCode_ReturnsFalse() throws Exception { assertFalse(unmarshaller.matchErrorCode("NonMatchingErrorCode")); }
@Test public void match_NullErrorCode_ReturnsFalse() throws Exception { assertFalse(unmarshaller.matchErrorCode(null)); }