BooleanSerializer extends StringSerializer<Boolean> { public String serialize(Boolean value, Charset charset) { return value ? trueString : falseString; } BooleanSerializer(CRestConfig crestConfig); String serialize(Boolean value, Charset charset);  }
@Test public void shouldSerializeFalseToFalseUsingDefaultBooleanFormat() throws Exception { OutputStream out = new ByteArrayOutputStream(); toTest.serialize(false, charset, out); assertEquals("false", out.toString()); }
@Test public void shouldSerializeTrueToTrueUsingDefaultBooleanFormat() throws Exception { OutputStream out = new ByteArrayOutputStream(); toTest.serialize(true, charset, out); assertEquals("true", out.toString()); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerWhenSerializingNull() throws Exception { toTest.serialize(null, charset, new ByteArrayOutputStream()); }
@Test public void shouldSerializeFalseToCustomFalseUsingCustomBooleanFormat() throws Exception { Serializer toTest = newToTest(); OutputStream out = new ByteArrayOutputStream(); toTest.serialize(false, charset, out); assertEquals("0", out.toString()); }
@Test public void shouldSerializeTrueToCustomTrueUsingCustomBooleanFormat() throws Exception { Serializer toTest = newToTest(); OutputStream out = new ByteArrayOutputStream(); toTest.serialize(true, charset, out); assertEquals("1", out.toString()); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerWhenSerializingNullUsingCustomBooleanFormat() throws Exception { newToTest().serialize(null, charset, new ByteArrayOutputStream()); }