Search in sources :

Example 1 with RelatedModel

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"));
    });
}
Also used : SingleModel(com.liferay.apio.architect.single.model.SingleModel) RelatedModel(com.liferay.apio.architect.related.RelatedModel) FirstEmbeddedModel(com.liferay.apio.architect.test.util.model.FirstEmbeddedModel) MockWriterUtil(com.liferay.apio.architect.test.util.writer.MockWriterUtil) Test(org.junit.Test)

Aggregations

RelatedModel (com.liferay.apio.architect.related.RelatedModel)1 SingleModel (com.liferay.apio.architect.single.model.SingleModel)1 FirstEmbeddedModel (com.liferay.apio.architect.test.util.model.FirstEmbeddedModel)1 MockWriterUtil (com.liferay.apio.architect.test.util.writer.MockWriterUtil)1 Test (org.junit.Test)1