@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isBoolean()) { return adapterFor(repr.asBoolean()); } return null; } @Override
public boolean isBoolean(final String path) { return isBoolean(getNode(path)); }
@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isBoolean()) { return adapterFor(repr.asBoolean()); } return null; } @Override
public boolean isBoolean() { return isBoolean(asJsonNode()); }
@Test public void whenBooleanWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Boolean.class); allowingObjectAdapterToReturn(Boolean.TRUE); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isBoolean("value"), is(true)); assertThat(representation.getBoolean("value"), is(Boolean.TRUE)); assertThat(representation.getString("format"), is(nullValue())); }
@Test public void whenBooleanPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(boolean.class); allowingObjectAdapterToReturn(true); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isBoolean("value"), is(true)); assertThat(representation.getBoolean("value"), is(true)); assertThat(representation.getString("format"), is(nullValue())); }
@Test public void whenBooleanPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(boolean.class); allowingObjectAdapterToReturn(true); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isBoolean("value"), is(true)); assertThat(representation.getBoolean("value"), is(true)); assertThat(representation.getString("format"), is(nullValue())); }
@Test public void whenBooleanWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Boolean.class); allowingObjectAdapterToReturn(Boolean.TRUE); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isBoolean("value"), is(true)); assertThat(representation.getBoolean("value"), is(Boolean.TRUE)); assertThat(representation.getString("format"), is(nullValue())); }
if (!representation.isBoolean()) { throwIncompatibleException(objectSpec, representation);