DataPropertyFieldStrategy extends FieldStrategy<A, X> { String getLanguage() { if (attribute.isSimpleLiteral()) { return null; } final Descriptor attDescriptor = entityDescriptor.getAttributeDescriptor(attribute); return attDescriptor.hasLanguage() ? attDescriptor.getLanguage() : attribute.getLanguage(); } DataPropertyFieldStrategy(EntityType<X> et, A att, Descriptor entityDescriptor,
                              EntityMappingHelper mapper);   }
@Test void getLanguagesUsesAttributeConfiguredLanguageWhenDescriptorDoesNotSpecifyAny() { final DataPropertyFieldStrategy<?, ?> sut = (DataPropertyFieldStrategy<?, ?>) FieldStrategy .createFieldStrategy(metamodelMocks.forOwlClassA().entityType(), metamodelMocks.forOwlClassA().stringAttribute(), descriptor, mapperMock); assertTrue(metamodelMocks.forOwlClassA().stringAttribute().hasLanguage()); assertEquals(Generators.LANG, sut.getLanguage()); }
@Test void getLanguageRetrievesAttributeLanguageFromEntityDescriptor() throws Exception { final String lang = "cs"; descriptor.setAttributeLanguage(OWLClassA.getStrAttField(), lang); final DataPropertyFieldStrategy<?, ?> sut = (DataPropertyFieldStrategy<?, ?>) FieldStrategy .createFieldStrategy(metamodelMocks.forOwlClassA().entityType(), metamodelMocks.forOwlClassA().stringAttribute(), descriptor, mapperMock); assertEquals(lang, sut.getLanguage()); }
@Test void getLanguageReturnsNullForSimpleLiteralAttribute() { final DataPropertyFieldStrategy<?, ?> sut = (DataPropertyFieldStrategy<?, ?>) FieldStrategy .createFieldStrategy(metamodelMocks.forOwlClassM().entityType(), metamodelMocks.forOwlClassM().simpleLiteralAttribute(), descriptor, mapperMock); assertNull(sut.getLanguage()); }