@Test @SuppressWarnings("unchecked") void testToEditorEntityType() { String id = "id"; String label = "label"; String i18nLabelLangEn = "en"; String i18nLabelValue = "en label"; Map<String, String> i18nLabel = singletonMap(i18nLabelLangEn, i18nLabelValue); String description = "description"; String i18nDescriptionLangEn = "en"; String i18nDescriptionValue = "en description"; Map<String, String> i18nDescription = singletonMap(i18nDescriptionLangEn, i18nDescriptionValue); String backend = "backend"; List<Attribute> referringAttributes = new ArrayList<>(); EntityType entityType = mock(EntityType.class); when(entityType.getId()).thenReturn(id); when(entityType.getLabel()).thenReturn(label); when(entityType.getString(getI18nAttributeName(EntityTypeMetadata.LABEL, i18nLabelLangEn))) .thenReturn(i18nLabelValue); when(entityType.getDescription()).thenReturn(description); when(entityType.getString( getI18nAttributeName(EntityTypeMetadata.DESCRIPTION, i18nDescriptionLangEn))) .thenReturn(i18nDescriptionValue); when(entityType.isAbstract()).thenReturn(true); when(entityType.getBackend()).thenReturn(backend); Package package_ = mock(Package.class); when(entityType.getPackage()).thenReturn(package_); EntityType extendsEntityType = mock(EntityType.class); when(entityType.getExtends()).thenReturn(extendsEntityType); @SuppressWarnings("unchecked") Iterable<Attribute> attributes = mock(Iterable.class); when(entityType.getOwnAllAttributes()).thenReturn(attributes); @SuppressWarnings("unchecked") Iterable<Tag> tags = mock(Iterable.class); when(entityType.getTags()).thenReturn(tags); Attribute idAttribute = mock(Attribute.class); when(entityType.getIdAttribute()).thenReturn(idAttribute); Attribute labelAttribute = mock(Attribute.class); when(entityType.getLabelAttribute()).thenReturn(labelAttribute); @SuppressWarnings("unchecked") Iterable<Attribute> lookupAttributes = mock(Iterable.class); when(entityType.getLookupAttributes()).thenReturn(lookupAttributes); EditorAttributeIdentifier editorIdAttribute = mock(EditorAttributeIdentifier.class); when(attributeReferenceMapper.toEditorAttributeIdentifier(idAttribute)) .thenReturn(editorIdAttribute); EditorAttributeIdentifier editorLabelAttribute = mock(EditorAttributeIdentifier.class); when(attributeReferenceMapper.toEditorAttributeIdentifier(labelAttribute)) .thenReturn(editorLabelAttribute); @SuppressWarnings("unchecked") ImmutableList<EditorAttributeIdentifier> editorLookupAttributes = mock(ImmutableList.class); when(attributeReferenceMapper.toEditorAttributeIdentifiers(lookupAttributes)) .thenReturn(editorLookupAttributes); @SuppressWarnings("unchecked") ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = mock(ImmutableList.class); when(attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes)) .thenReturn(editorReferringAttributes); ImmutableList<EditorAttribute> editorAttributes = mock(ImmutableList.class); when(attributeMapper.toEditorAttributes(attributes)).thenReturn(editorAttributes); EditorEntityTypeParent editorEntityTypeParent = mock(EditorEntityTypeParent.class); when(entityTypeParentMapper.toEditorEntityTypeParent(extendsEntityType)) .thenReturn(editorEntityTypeParent); EditorPackageIdentifier editorPackageIdentifier = mock(EditorPackageIdentifier.class); when(packageMapper.toEditorPackage(package_)).thenReturn(editorPackageIdentifier); @SuppressWarnings("unchecked") ImmutableList<EditorTagIdentifier> editorTags = mock(ImmutableList.class); when(tagMapper.toEditorTags(tags)).thenReturn(editorTags); when(entityTypeFactory.create()).thenReturn(entityType); EditorEntityType editorEntityType = entityTypeMapper.toEditorEntityType(entityType, referringAttributes); EditorEntityType expectedEditorEntityType = EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, true, backend, editorPackageIdentifier, editorEntityTypeParent, editorAttributes, editorReferringAttributes, editorTags, editorIdAttribute, editorLabelAttribute, editorLookupAttributes); assertEquals(expectedEditorEntityType, editorEntityType); }
public EditorEntityType toEditorEntityType( EntityType entityType, List<Attribute> referringAttributes) { String id = entityType.getId(); String label = entityType.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(entityType); String description = entityType.getDescription(); ImmutableMap<String, String> i18nDescription = toI18nDescription(entityType); boolean isAbstract = entityType.isAbstract(); String backend = entityType.getBackend(); EditorPackageIdentifier pack = packageMapper.toEditorPackage(entityType.getPackage()); EditorEntityTypeParent entityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType.getExtends()); ImmutableList<EditorAttribute> attributes = attributeMapper.toEditorAttributes(entityType.getOwnAllAttributes()); ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes); ImmutableList<EditorTagIdentifier> tags = tagMapper.toEditorTags(entityType.getTags()); EditorAttributeIdentifier idAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getIdAttribute()); EditorAttributeIdentifier labelAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getLabelAttribute()); ImmutableList<EditorAttributeIdentifier> lookupAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getLookupAttributes()); return EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, isAbstract, backend, pack, entityTypeParent, attributes, editorReferringAttributes, tags, idAttribute, labelAttribute, lookupAttributes); }
EntityTypeMapper { public EditorEntityType toEditorEntityType( EntityType entityType, List<Attribute> referringAttributes) { String id = entityType.getId(); String label = entityType.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(entityType); String description = entityType.getDescription(); ImmutableMap<String, String> i18nDescription = toI18nDescription(entityType); boolean isAbstract = entityType.isAbstract(); String backend = entityType.getBackend(); EditorPackageIdentifier pack = packageMapper.toEditorPackage(entityType.getPackage()); EditorEntityTypeParent entityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType.getExtends()); ImmutableList<EditorAttribute> attributes = attributeMapper.toEditorAttributes(entityType.getOwnAllAttributes()); ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes); ImmutableList<EditorTagIdentifier> tags = tagMapper.toEditorTags(entityType.getTags()); EditorAttributeIdentifier idAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getIdAttribute()); EditorAttributeIdentifier labelAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getLabelAttribute()); ImmutableList<EditorAttributeIdentifier> lookupAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getLookupAttributes()); return EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, isAbstract, backend, pack, entityTypeParent, attributes, editorReferringAttributes, tags, idAttribute, labelAttribute, lookupAttributes); } }
EntityTypeMapper { public EditorEntityType toEditorEntityType( EntityType entityType, List<Attribute> referringAttributes) { String id = entityType.getId(); String label = entityType.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(entityType); String description = entityType.getDescription(); ImmutableMap<String, String> i18nDescription = toI18nDescription(entityType); boolean isAbstract = entityType.isAbstract(); String backend = entityType.getBackend(); EditorPackageIdentifier pack = packageMapper.toEditorPackage(entityType.getPackage()); EditorEntityTypeParent entityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType.getExtends()); ImmutableList<EditorAttribute> attributes = attributeMapper.toEditorAttributes(entityType.getOwnAllAttributes()); ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes); ImmutableList<EditorTagIdentifier> tags = tagMapper.toEditorTags(entityType.getTags()); EditorAttributeIdentifier idAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getIdAttribute()); EditorAttributeIdentifier labelAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getLabelAttribute()); ImmutableList<EditorAttributeIdentifier> lookupAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getLookupAttributes()); return EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, isAbstract, backend, pack, entityTypeParent, attributes, editorReferringAttributes, tags, idAttribute, labelAttribute, lookupAttributes); } EntityTypeMapper(
      EntityTypeFactory entityTypeFactory,
      AttributeMapper attributeMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      PackageMapper packageMapper,
      TagMapper tagMapper,
      EntityTypeParentMapper entityTypeParentMapper); }
EntityTypeMapper { public EditorEntityType toEditorEntityType( EntityType entityType, List<Attribute> referringAttributes) { String id = entityType.getId(); String label = entityType.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(entityType); String description = entityType.getDescription(); ImmutableMap<String, String> i18nDescription = toI18nDescription(entityType); boolean isAbstract = entityType.isAbstract(); String backend = entityType.getBackend(); EditorPackageIdentifier pack = packageMapper.toEditorPackage(entityType.getPackage()); EditorEntityTypeParent entityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType.getExtends()); ImmutableList<EditorAttribute> attributes = attributeMapper.toEditorAttributes(entityType.getOwnAllAttributes()); ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes); ImmutableList<EditorTagIdentifier> tags = tagMapper.toEditorTags(entityType.getTags()); EditorAttributeIdentifier idAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getIdAttribute()); EditorAttributeIdentifier labelAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getLabelAttribute()); ImmutableList<EditorAttributeIdentifier> lookupAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getLookupAttributes()); return EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, isAbstract, backend, pack, entityTypeParent, attributes, editorReferringAttributes, tags, idAttribute, labelAttribute, lookupAttributes); } EntityTypeMapper(
      EntityTypeFactory entityTypeFactory,
      AttributeMapper attributeMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      PackageMapper packageMapper,
      TagMapper tagMapper,
      EntityTypeParentMapper entityTypeParentMapper); EditorEntityType toEditorEntityType(
      EntityType entityType, List<Attribute> referringAttributes); EditorEntityType createEditorEntityType(); EntityType toEntityType(EditorEntityType editorEntityType); }
EntityTypeMapper { public EditorEntityType toEditorEntityType( EntityType entityType, List<Attribute> referringAttributes) { String id = entityType.getId(); String label = entityType.getLabel(); ImmutableMap<String, String> i18nLabel = toI18nLabel(entityType); String description = entityType.getDescription(); ImmutableMap<String, String> i18nDescription = toI18nDescription(entityType); boolean isAbstract = entityType.isAbstract(); String backend = entityType.getBackend(); EditorPackageIdentifier pack = packageMapper.toEditorPackage(entityType.getPackage()); EditorEntityTypeParent entityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType.getExtends()); ImmutableList<EditorAttribute> attributes = attributeMapper.toEditorAttributes(entityType.getOwnAllAttributes()); ImmutableList<EditorAttributeIdentifier> editorReferringAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(referringAttributes); ImmutableList<EditorTagIdentifier> tags = tagMapper.toEditorTags(entityType.getTags()); EditorAttributeIdentifier idAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getIdAttribute()); EditorAttributeIdentifier labelAttribute = attributeReferenceMapper.toEditorAttributeIdentifier(entityType.getLabelAttribute()); ImmutableList<EditorAttributeIdentifier> lookupAttributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getLookupAttributes()); return EditorEntityType.create( id, label, i18nLabel, description, i18nDescription, isAbstract, backend, pack, entityTypeParent, attributes, editorReferringAttributes, tags, idAttribute, labelAttribute, lookupAttributes); } EntityTypeMapper(
      EntityTypeFactory entityTypeFactory,
      AttributeMapper attributeMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      PackageMapper packageMapper,
      TagMapper tagMapper,
      EntityTypeParentMapper entityTypeParentMapper); EditorEntityType toEditorEntityType(
      EntityType entityType, List<Attribute> referringAttributes); EditorEntityType createEditorEntityType(); EntityType toEntityType(EditorEntityType editorEntityType);  }