@Test public void shouldMergeEntity() { when(productDtoInfo.getType()).thenReturn(DtoType.MERGE); defaultMapper.merge(productDto, product); Assert.assertEquals(productDto.getDescription(), product.getDescription()); Assert.assertEquals(productDto.getName(), product.getName()); Assert.assertEquals(new Integer(123), product.getProductionYear()); Assert.assertEquals(1, product.getTags().size()); Assert.assertEquals(Tag.class, product.getTags().get(0).getClass()); Assert.assertEquals(tagDto.getName(), product.getTags().get(0) .getName()); }
@Override public void merge(Object from, Object entity) { DtoInformation dtoInfo = dtoInfoRegistry.get(from.getClass()); if (dtoInfo.getType() == DtoType.CREATE) throw new IllegalStateException( "Cannot use create dto to merge with entity"); mergeByFields(from, entity); }
DefaultCreateAndUpdateMapper implements
		CreateMapper<Object, Object>, UpdateMapper<Object, Object> { @Override public void merge(Object from, Object entity) { DtoInformation dtoInfo = dtoInfoRegistry.get(from.getClass()); if (dtoInfo.getType() == DtoType.CREATE) throw new IllegalStateException( "Cannot use create dto to merge with entity"); mergeByFields(from, entity); } }
DefaultCreateAndUpdateMapper implements
		CreateMapper<Object, Object>, UpdateMapper<Object, Object> { @Override public void merge(Object from, Object entity) { DtoInformation dtoInfo = dtoInfoRegistry.get(from.getClass()); if (dtoInfo.getType() == DtoType.CREATE) throw new IllegalStateException( "Cannot use create dto to merge with entity"); mergeByFields(from, entity); } DefaultCreateAndUpdateMapper(DtoInformationRegistry dtoInfoRegistry,
			MapperDelegator mapperDelegator,
			PersistentEntities persistentEntities); }
DefaultCreateAndUpdateMapper implements
		CreateMapper<Object, Object>, UpdateMapper<Object, Object> { @Override public void merge(Object from, Object entity) { DtoInformation dtoInfo = dtoInfoRegistry.get(from.getClass()); if (dtoInfo.getType() == DtoType.CREATE) throw new IllegalStateException( "Cannot use create dto to merge with entity"); mergeByFields(from, entity); } DefaultCreateAndUpdateMapper(DtoInformationRegistry dtoInfoRegistry,
			MapperDelegator mapperDelegator,
			PersistentEntities persistentEntities); @SuppressWarnings("unchecked") @Override Object create(Object from); @Override void merge(Object from, Object entity); }
DefaultCreateAndUpdateMapper implements
		CreateMapper<Object, Object>, UpdateMapper<Object, Object> { @Override public void merge(Object from, Object entity) { DtoInformation dtoInfo = dtoInfoRegistry.get(from.getClass()); if (dtoInfo.getType() == DtoType.CREATE) throw new IllegalStateException( "Cannot use create dto to merge with entity"); mergeByFields(from, entity); } DefaultCreateAndUpdateMapper(DtoInformationRegistry dtoInfoRegistry,
			MapperDelegator mapperDelegator,
			PersistentEntities persistentEntities); @SuppressWarnings("unchecked") @Override Object create(Object from); @Override void merge(Object from, Object entity);  }