@Test void updateMappedByEntitiesEntity() { String refEntityName = "refEntityName"; EntityType refEntityMeta = mock(EntityType.class); when(refEntityMeta.getId()).thenReturn(refEntityName); String mappedByAttrName = "mappedByAttr"; Attribute mappedByAttr = mock(Attribute.class); when(mappedByAttr.getName()).thenReturn(mappedByAttrName); EntityType entityMeta = mock(EntityType.class); Attribute oneToManyAttr = mock(Attribute.class); String oneToManyAttrName = "oneToManyAttr"; when(oneToManyAttr.getName()).thenReturn(oneToManyAttrName); when(oneToManyAttr.getDataType()).thenReturn(ONE_TO_MANY); when(oneToManyAttr.isMappedBy()).thenReturn(true); when(oneToManyAttr.getMappedBy()).thenReturn(mappedByAttr); when(oneToManyAttr.getRefEntity()).thenReturn(refEntityMeta); when(entityMeta.getMappedByAttributes()).thenReturn(Stream.of(oneToManyAttr)); Entity refEntity0 = mock(Entity.class); Entity refEntity1 = mock(Entity.class); Entity entity = mock(Entity.class); when(entity.getEntities(oneToManyAttrName)).thenReturn(newArrayList(refEntity0, refEntity1)); when(entity.getEntityType()).thenReturn(entityMeta); restService.updateMappedByEntities(entity); @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Entity>> captor = ArgumentCaptor.forClass(Stream.class); verify(dataService).update(eq(refEntityName), captor.capture()); List<Entity> refEntities = captor.getValue().collect(toList()); assertEquals(newArrayList(refEntity0, refEntity1), refEntities); verify(refEntity0).set(mappedByAttrName, entity); verify(refEntity1).set(mappedByAttrName, entity); verifyNoMoreInteractions(dataService); }
public void updateMappedByEntities(@Nonnull Entity entity) { updateMappedByEntities(entity, null); }
RestService { public void updateMappedByEntities(@Nonnull Entity entity) { updateMappedByEntities(entity, null); } }
RestService { public void updateMappedByEntities(@Nonnull Entity entity) { updateMappedByEntities(entity, null); } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); }
RestService { public void updateMappedByEntities(@Nonnull Entity entity) { updateMappedByEntities(entity, null); } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); Entity toEntity(final EntityType meta, final Map<String, Object> request); Object toEntityValue(Attribute attr, Object paramValue, Object id); void updateMappedByEntities(@Nonnull Entity entity); void updateMappedByEntities(
      @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity); }
RestService { public void updateMappedByEntities(@Nonnull Entity entity) { updateMappedByEntities(entity, null); } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); Entity toEntity(final EntityType meta, final Map<String, Object> request); Object toEntityValue(Attribute attr, Object paramValue, Object id); void updateMappedByEntities(@Nonnull Entity entity); void updateMappedByEntities(
      @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity);  }