use of com.liferay.apio.architect.related.RelatedModel in project com-liferay-apio-architect by liferay.
the class FieldsWriterTest method testGetSingleModel.
@Test
public void testGetSingleModel() {
SingleModel<Integer> parentSingleModel = new SingleModel<>(3, "", Collections.emptyList());
RelatedModel<Integer, String> relatedModel = new RelatedModel<>("key", FirstEmbeddedId.class, String::valueOf);
Optional<SingleModel<FirstEmbeddedModel>> optional = FieldsWriter.getSingleModel(relatedModel, parentSingleModel, MockWriterUtil::getSingleModel);
assertThat(optional, is(optionalWithValue()));
optional.ifPresent(singleModel -> {
assertThat(singleModel.getResourceName(), is("first"));
FirstEmbeddedModel firstEmbeddedModel = singleModel.getModel();
assertThat(firstEmbeddedModel.getId(), is("3"));
});
}
Aggregations