@Test public void canCloseShouldReturnTrueWhenJsonIsValid() throws Exception { final boolean actual = underTest.canClose("{}"); assertThat(actual) .overridingErrorMessage("Expected value returned by canClose is true, but was false") .isTrue(); }
@Override @SuppressWarnings("SimplifiableIfStatement") public boolean canClose(@Nullable String json) { if (Strings.isNullOrEmpty(json)) { return false; } try { final JsonElement root = parser.parse(json); return !root.isJsonNull() && !root.isJsonPrimitive(); } catch (JsonParseException e) { return false; } }
JsonValidator implements InputValidatorEx { @Override @SuppressWarnings("SimplifiableIfStatement") public boolean canClose(@Nullable String json) { if (Strings.isNullOrEmpty(json)) { return false; } try { final JsonElement root = parser.parse(json); return !root.isJsonNull() && !root.isJsonPrimitive(); } catch (JsonParseException e) { return false; } } }
JsonValidator implements InputValidatorEx { @Override @SuppressWarnings("SimplifiableIfStatement") public boolean canClose(@Nullable String json) { if (Strings.isNullOrEmpty(json)) { return false; } try { final JsonElement root = parser.parse(json); return !root.isJsonNull() && !root.isJsonPrimitive(); } catch (JsonParseException e) { return false; } } @Inject  JsonValidator(@Nonnull Json2JavaBundle bundle, @Nonnull JsonParser parser); }
JsonValidator implements InputValidatorEx { @Override @SuppressWarnings("SimplifiableIfStatement") public boolean canClose(@Nullable String json) { if (Strings.isNullOrEmpty(json)) { return false; } try { final JsonElement root = parser.parse(json); return !root.isJsonNull() && !root.isJsonPrimitive(); } catch (JsonParseException e) { return false; } } @Inject  JsonValidator(@Nonnull Json2JavaBundle bundle, @Nonnull JsonParser parser); @Nullable @Override String getErrorText(@Nullable String json); @Override boolean checkInput(@Nullable String json); @Override @SuppressWarnings("SimplifiableIfStatement") boolean canClose(@Nullable String json); }
JsonValidator implements InputValidatorEx { @Override @SuppressWarnings("SimplifiableIfStatement") public boolean canClose(@Nullable String json) { if (Strings.isNullOrEmpty(json)) { return false; } try { final JsonElement root = parser.parse(json); return !root.isJsonNull() && !root.isJsonPrimitive(); } catch (JsonParseException e) { return false; } } @Inject  JsonValidator(@Nonnull Json2JavaBundle bundle, @Nonnull JsonParser parser); @Nullable @Override String getErrorText(@Nullable String json); @Override boolean checkInput(@Nullable String json); @Override @SuppressWarnings("SimplifiableIfStatement") boolean canClose(@Nullable String json);  }