@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsDoubleButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(double.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBigDecimalButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBigDecimalButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsIntegerButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(int.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsIntegerButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(int.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBigIntegerButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigInteger.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsDoubleButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(double.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBigIntegerButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigInteger.class); representation = JsonRepresentation.newMap("foo", "bar"); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test public void whenReprIsBigInteger() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigInteger.class); final BigInteger value = BigInteger.valueOf(123); representation = new JsonRepresentation(BigIntegerNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
@Test public void whenReprIsBigDecimal() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class); final BigDecimal value = new BigDecimal("123234234.45612312343535"); representation = new JsonRepresentation(DecimalNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
@Test public void whenReprIsBigDecimal() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class); final BigDecimal value = new BigDecimal("123234234.45612312343535"); representation = new JsonRepresentation(DecimalNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBooleanButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(boolean.class); context.checking(new Expectations() { { one(mockEncodableFacet).fromEncodedString("aString"); will(throwException(new TextEntryParseException("'aString' cannot be parsed as a boolean value"))); } }); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsLongButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(long.class); context.checking(new Expectations() { { one(mockEncodableFacet).fromEncodedString("aString"); will(throwException(new TextEntryParseException("'aString' cannot be parsed as a long value"))); } }); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsLongButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(long.class); context.checking(new Expectations() { { one(mockEncodableFacet).fromEncodedString("aString"); will(throwException(new TextEntryParseException("'aString' cannot be parsed as a long value"))); } }); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
@Test(expected = IllegalArgumentException.class) public void whenObjectSpecIsBooleanButReprIsNot() throws Exception { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(boolean.class); context.checking(new Expectations() { { one(mockEncodableFacet).fromEncodedString("aString"); will(throwException(new TextEntryParseException("'aString' cannot be parsed as a boolean value"))); } }); // when JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); }
private void whenReprIsDouble(final Class<?> correspondingClass) { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass); final double value = 123.45; representation = new JsonRepresentation(DoubleNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
private void whenReprIsInteger(final Class<?> correspondingClass) { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass); final int value = 123; representation = new JsonRepresentation(IntNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
private void whenReprIsBoolean(final Class<?> correspondingClass) { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass); final boolean value = true; representation = new JsonRepresentation(BooleanNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
private void whenReprIsInteger(final Class<?> correspondingClass) { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass); final int value = 123; representation = new JsonRepresentation(IntNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }
private void whenReprIsDouble(final Class<?> correspondingClass) { // given allowingObjectSpecHas(EncodableFacet.class, mockEncodableFacet); allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass); final double value = 123.45; representation = new JsonRepresentation(DoubleNode.valueOf(value)); context.checking(new Expectations() { { oneOf(mockAdapterManager).adapterFor(value); will(returnValue(mockObjectAdapter)); } }); // when final ObjectAdapter adapter = JsonValueEncoder.asAdapter(mockObjectSpec, representation, null); // then assertSame(mockObjectAdapter, adapter); }