### Question:
AttributeConverter { Attribute convert(com.sabre.oss.yare.core.model.Attribute attribute) { if (attribute == null) { return null; } return new Attribute() .withName(attribute.getName()) .withType(typeConverter.toString(Type.class, attribute.getType())) .withValue(attribute.getValue()); } AttributeConverter(TypeConverter typeConverter);   }### Answer:
@Test void shouldConvertToAttribute() { com.sabre.oss.yare.core.model.Attribute toConvert = new com.sabre.oss.yare.core.model.Attribute("attribute-name", String.class, "attribute-value"); Attribute attribute = attributeConverter.convert(toConvert); Attribute expected = new Attribute() .withName("attribute-name") .withType("String") .withValue("attribute-value"); assertThat(attribute).isEqualTo(expected); }
@Test void shouldConvertToAttributeWhenTypeIsNull() { com.sabre.oss.yare.core.model.Attribute toConvert = new com.sabre.oss.yare.core.model.Attribute("attribute-name", null, "attribute-value"); Attribute attribute = attributeConverter.convert(toConvert); Attribute expected = new Attribute() .withName("attribute-name") .withType(Expression.Undefined.class.getName()) .withValue("attribute-value"); assertThat(attribute).isEqualTo(expected); }
@Test void shouldConvertNullAttribute() { Attribute attribute = attributeConverter.convert(null); assertThat(attribute).isNull(); }