/** * Is a long, an int or a {@link BigInteger}. */ public boolean isIntegralNumber(final String path) { return isIntegralNumber(getNode(path)); }
/** * Is a long, an int or a {@link BigInteger}. */ public boolean isIntegralNumber() { return isIntegralNumber(asJsonNode()); }
@Test public void whenLongWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Long.class); allowingObjectAdapterToReturn(Long.valueOf(12345678901234L)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getLong("value"), is(Long.valueOf(12345678901234L))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("long")); }
@Test public void whenLongWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Long.class); allowingObjectAdapterToReturn(Long.valueOf(12345678901234L)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getLong("value"), is(Long.valueOf(12345678901234L))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("long")); }
@Test public void whenByteWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Byte.class); allowingObjectAdapterToReturn(Byte.valueOf((byte)123)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getByte("value"), is(Byte.valueOf((byte)123))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("byte")); }
@Test public void whenShortWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Short.class); allowingObjectAdapterToReturn(Short.valueOf((short)12345)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getShort("value"), is(Short.valueOf((short)12345))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("short")); }
@Test public void whenIntWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Integer.class); allowingObjectAdapterToReturn(Integer.valueOf(12345678)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getInt("value"), is(Integer.valueOf(12345678))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("int")); }
@Test public void whenByteWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Byte.class); allowingObjectAdapterToReturn(Byte.valueOf((byte)123)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getByte("value"), is(Byte.valueOf((byte)123))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("byte")); }
@Test public void whenShortWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Short.class); allowingObjectAdapterToReturn(Short.valueOf((short)12345)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getShort("value"), is(Short.valueOf((short)12345))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("short")); }
@Test public void whenIntWrapper() throws Exception { allowingObjectSpecToReturnSpecIdFor(Integer.class); allowingObjectAdapterToReturn(Integer.valueOf(12345678)); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getInt("value"), is(Integer.valueOf(12345678))); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("int")); }
@Test public void whenBytePrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(byte.class); allowingObjectAdapterToReturn((byte)123); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getByte("value"), is((byte)123)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("byte")); }
@Test public void whenIntPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(int.class); allowingObjectAdapterToReturn(12345678); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getInt("value"), is(12345678)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("int")); }
@Test public void whenIntPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(int.class); allowingObjectAdapterToReturn(12345678); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getInt("value"), is(12345678)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("int")); }
@Test public void whenBytePrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(byte.class); allowingObjectAdapterToReturn((byte)123); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getByte("value"), is((byte)123)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("byte")); }
@Test public void whenShortPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(short.class); allowingObjectAdapterToReturn((short)12345); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getShort("value"), is((short)12345)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("short")); }
@Test public void whenLongPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(long.class); allowingObjectAdapterToReturn(12345678901234L); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null, false); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getLong("value"), is(12345678901234L)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("long")); }
@Test public void whenShortPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(short.class); allowingObjectAdapterToReturn((short)12345); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getShort("value"), is((short)12345)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("short")); }
@Test public void whenLongPrimitive() throws Exception { allowingObjectSpecToReturnSpecIdFor(long.class); allowingObjectAdapterToReturn(12345678901234L); JsonValueEncoder.appendValueAndFormat(mockObjectSpec, mockObjectAdapter, representation, null); assertThat(representation.isIntegralNumber("value"), is(true)); assertThat(representation.getLong("value"), is(12345678901234L)); assertThat(representation.getString("format"), is("int")); assertThat(representation.getString("extensions.x-isis-format"), is("long")); }