### Question:
EnumAccessor implements PropertyAccessor<Enum> { @Override public byte[] toBytes(Object object) { if (object == null) { return null; } String s = toString(object); try { return s.getBytes(Constants.ENCODING); } catch (UnsupportedEncodingException e) { log.error("Unsupported encoding exception, Caused by {}.", e); throw new PropertyAccessException(e); } }  @Override Enum fromBytes(Class targetClass, byte[] b); @Override byte[] toBytes(Object object); @Override String toString(Object object); @Override Enum fromString(Class targetClass, String string); @Override Enum getCopy(Object object); Enum getInstance(Class<?> clazz);  }### Answer:
@Test public void testToBytes() { try { byte[] b = accessor.toBytes(day1); String s = new String(b, Constants.ENCODING); Assert.assertEquals(day1.MONDAY.name(), s); b = accessor.toBytes(null); Assert.assertNull(b); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } catch (UnsupportedEncodingException e) { Assert.fail(e.getMessage()); } }