MultilingualStringInstanceBuilder extends AbstractInstanceBuilder { @Override Object buildClone(Object cloneOwner, Field field, Object original, CloneConfiguration cloneConfiguration) { if (original == null) { return null; } assert original instanceof MultilingualString; MultilingualString orig = (MultilingualString) original; if (orig instanceof IndirectMultilingualString) { orig = ((IndirectMultilingualString) orig).unwrap(); } return new IndirectMultilingualString(cloneOwner, field, uow, new MultilingualString(orig.getValue())); } MultilingualStringInstanceBuilder(CloneBuilderImpl builder, UnitOfWorkImpl uow);   }
@Test void buildCloneCopiesAllTranslationsInSpecifiedOriginalMultilingualString() throws Exception { final MultilingualString original = MultilingualString.create("building", Generators.LANG); original.set("cs", "stavba"); final Object result = sut.buildClone(new OWLClassU(), OWLClassU.getSingularStringAttField(), original, new CloneConfiguration(descriptor)); assertThat(result, instanceOf(MultilingualString.class)); final MultilingualString typedResult = (MultilingualString) result; assertEquals(original.getValue(), typedResult.getValue()); }
@Test void buildCloneResultsNullWhenOriginalIsNull() throws Exception { final Object result = sut.buildClone(new OWLClassU(), OWLClassU.getSingularStringAttField(), null, new CloneConfiguration(descriptor)); assertNull(result); }
@Test void buildCloneReturnsIndirectWrapperAllowingToTrackModifyingOperations() throws Exception { final MultilingualString original = MultilingualString.create("building", Generators.LANG); original.set("cs", "stavba"); final Object result = sut.buildClone(new OWLClassU(), OWLClassU.getSingularStringAttField(), original, new CloneConfiguration(descriptor)); assertThat(result, instanceOf(IndirectMultilingualString.class)); }