ReservationStatusConverter implements AttributeConverter<ReservationStatus, String> { @Override public ReservationStatus convertToEntityAttribute(String y) { if (null == y) { return null; } for (ReservationStatus elem : ReservationStatus.values()) { if (elem.name().equalsIgnoreCase(y)) { return elem; } } throw new IllegalArgumentException("Cannot map " + y); }  @Override String convertToDatabaseColumn(ReservationStatus x); @Override ReservationStatus convertToEntityAttribute(String y);  }
@Test public void the_entity_value_of_a_known_string_is_the_enumeration() { ReservationStatus value = new ReservationStatusConverter().convertToEntityAttribute(CANCELED.name()); assertThat(value).isSameAs(CANCELED); }
@Test(expected = IllegalArgumentException.class) public void the_entity_value_of_an_unknown_string_results_in_an_exception() { new ReservationStatusConverter().convertToEntityAttribute("Foo"); }
@Test public void the_entity_value_of_a_null_is_null() { ReservationStatus value = new ReservationStatusConverter().convertToEntityAttribute(null); assertThat(value).isNull(); }