@SuppressWarnings("ConstantConditions") @Test void testToEditorAttributes() { String id = "id"; String name = "name"; String type = "categoricalmref"; boolean cascadeDelete = false; String expression = "expression"; boolean nullable = false; boolean auto = false; boolean visible = false; 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); boolean aggregatable = false; Long rangeMin = 5L; Long rangeMax = 10L; boolean readonly = false; boolean unique = false; String nullableExpression = "nullableExpression"; String visibleExpression = "visibleExpression"; String validationExpression = "validationExpression"; String defaultValue = "defaultValue"; Integer sequenceNumber = 1; Attribute attribute = mock(Attribute.class); when(attribute.getIdentifier()).thenReturn(id); when(attribute.getName()).thenReturn(name); when(attribute.getDataType()).thenReturn(CATEGORICAL_MREF); Attribute parentAttr = mock(Attribute.class); when(attribute.getParent()).thenReturn(parentAttr); EntityType refEntityType = mock(EntityType.class); when(attribute.hasRefEntity()).thenReturn(true); when(attribute.getRefEntity()).thenReturn(refEntityType); when(attribute.getCascadeDelete()).thenReturn(cascadeDelete); Attribute mappedByAttribute = mock(Attribute.class); when(attribute.getMappedBy()).thenReturn(mappedByAttribute); Sort sort = mock(Sort.class); when(attribute.getOrderBy()).thenReturn(sort); when(attribute.getExpression()).thenReturn(expression); when(attribute.isNillable()).thenReturn(nullable); when(attribute.isAuto()).thenReturn(auto); when(attribute.isVisible()).thenReturn(visible); when(attribute.getLabel()).thenReturn(label); when(attribute.getString(getI18nAttributeName(AttributeMetadata.LABEL, i18nLabelLangEn))) .thenReturn(i18nLabelValue); when(attribute.getDescription()).thenReturn(description); when(attribute.getString( getI18nAttributeName(AttributeMetadata.DESCRIPTION, i18nDescriptionLangEn))) .thenReturn(i18nDescriptionValue); when(attribute.isAggregatable()).thenReturn(aggregatable); when(attribute.getEnumOptions()).thenReturn(of("option0")); when(attribute.getRangeMin()).thenReturn(rangeMin); when(attribute.getRangeMax()).thenReturn(rangeMax); when(attribute.isReadOnly()).thenReturn(readonly); when(attribute.isUnique()).thenReturn(nullable); @SuppressWarnings("unchecked") Iterable<Tag> tags = mock(Iterable.class); when(attribute.getTags()).thenReturn(tags); when(attribute.getNullableExpression()).thenReturn(nullableExpression); when(attribute.getVisibleExpression()).thenReturn(visibleExpression); when(attribute.getValidationExpression()).thenReturn(validationExpression); when(attribute.getDefaultValue()).thenReturn(defaultValue); when(attribute.getSequenceNumber()).thenReturn(1); EditorAttributeIdentifier editorParentAttribute = mock(EditorAttributeIdentifier.class); when(attributeReferenceMapper.toEditorAttributeIdentifier(parentAttr)) .thenReturn(editorParentAttribute); EditorEntityTypeIdentifier editorRefEntityType = mock(EditorEntityTypeIdentifier.class); when(entityTypeReferenceMapper.toEditorEntityTypeIdentifier(refEntityType)) .thenReturn(editorRefEntityType); EditorAttributeIdentifier editorMappedByAttribute = mock(EditorAttributeIdentifier.class); when(attributeReferenceMapper.toEditorAttributeIdentifier(mappedByAttribute)) .thenReturn(editorMappedByAttribute); EditorSort editorSort = mock(EditorSort.class); when(sortMapper.toEditorSort(sort)).thenReturn(editorSort); @SuppressWarnings("unchecked") ImmutableList<EditorTagIdentifier> editorTags = mock(ImmutableList.class); when(tagMapper.toEditorTags(tags)).thenReturn(editorTags); ImmutableList<EditorAttribute> editorAttributes = attributeMapper.toEditorAttributes(of(attribute)); EditorAttribute expectedEditorAttribute = EditorAttribute.create( id, name, type, editorParentAttribute, editorRefEntityType, cascadeDelete, editorMappedByAttribute, editorSort, expression, nullable, auto, visible, label, i18nLabel, description, i18nDescription, aggregatable, of("option0"), rangeMin, rangeMax, readonly, unique, editorTags, nullableExpression, visibleExpression, validationExpression, defaultValue, sequenceNumber); assertEquals(of(expectedEditorAttribute), editorAttributes); }
ImmutableList<EditorAttribute> toEditorAttributes(Iterable<Attribute> attributes) { return ImmutableList.copyOf(stream(attributes).map(this::toEditorAttribute).iterator()); }
AttributeMapper { ImmutableList<EditorAttribute> toEditorAttributes(Iterable<Attribute> attributes) { return ImmutableList.copyOf(stream(attributes).map(this::toEditorAttribute).iterator()); } }
AttributeMapper { ImmutableList<EditorAttribute> toEditorAttributes(Iterable<Attribute> attributes) { return ImmutableList.copyOf(stream(attributes).map(this::toEditorAttribute).iterator()); } AttributeMapper(
      AttributeFactory attributeFactory,
      TagMapper tagMapper,
      EntityTypeReferenceMapper entityTypeReferenceMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      SortMapper sortMapper); }
AttributeMapper { ImmutableList<EditorAttribute> toEditorAttributes(Iterable<Attribute> attributes) { return ImmutableList.copyOf(stream(attributes).map(this::toEditorAttribute).iterator()); } AttributeMapper(
      AttributeFactory attributeFactory,
      TagMapper tagMapper,
      EntityTypeReferenceMapper entityTypeReferenceMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      SortMapper sortMapper); EditorAttribute createEditorAttribute(); }
AttributeMapper { ImmutableList<EditorAttribute> toEditorAttributes(Iterable<Attribute> attributes) { return ImmutableList.copyOf(stream(attributes).map(this::toEditorAttribute).iterator()); } AttributeMapper(
      AttributeFactory attributeFactory,
      TagMapper tagMapper,
      EntityTypeReferenceMapper entityTypeReferenceMapper,
      AttributeReferenceMapper attributeReferenceMapper,
      SortMapper sortMapper); EditorAttribute createEditorAttribute();  }