@Test public void whenFormHasNullVersion_andInstancesWithNullVersion_softDeletesForm() { formsRepository.save(new Form.Builder() .id(1L) .jrFormId("1") .jrVersion(null) .build()); instancesRepository.save(buildInstance(1L, "1", null).build()); formDeleter.delete(1L); List<Form> forms = formsRepository.getAll(); assertThat(forms.size(), is(1)); assertThat(forms.get(0).isDeleted(), is(true)); }
public void delete(Long id) { Form form = formsRepository.get(id); List<Instance> instancesForVersion = instancesRepository.getAllByJrFormIdAndJrVersionNotDeleted(form.getJrFormId(), form.getJrVersion()); if (instancesForVersion.isEmpty()) { formsRepository.delete(id); } else { formsRepository.softDelete(form.getId()); } }
FormDeleter { public void delete(Long id) { Form form = formsRepository.get(id); List<Instance> instancesForVersion = instancesRepository.getAllByJrFormIdAndJrVersionNotDeleted(form.getJrFormId(), form.getJrVersion()); if (instancesForVersion.isEmpty()) { formsRepository.delete(id); } else { formsRepository.softDelete(form.getId()); } } }
FormDeleter { public void delete(Long id) { Form form = formsRepository.get(id); List<Instance> instancesForVersion = instancesRepository.getAllByJrFormIdAndJrVersionNotDeleted(form.getJrFormId(), form.getJrVersion()); if (instancesForVersion.isEmpty()) { formsRepository.delete(id); } else { formsRepository.softDelete(form.getId()); } } FormDeleter(FormsRepository formsRepository, InstancesRepository instancesRepository); }
FormDeleter { public void delete(Long id) { Form form = formsRepository.get(id); List<Instance> instancesForVersion = instancesRepository.getAllByJrFormIdAndJrVersionNotDeleted(form.getJrFormId(), form.getJrVersion()); if (instancesForVersion.isEmpty()) { formsRepository.delete(id); } else { formsRepository.softDelete(form.getId()); } } FormDeleter(FormsRepository formsRepository, InstancesRepository instancesRepository); void delete(Long id); }
FormDeleter { public void delete(Long id) { Form form = formsRepository.get(id); List<Instance> instancesForVersion = instancesRepository.getAllByJrFormIdAndJrVersionNotDeleted(form.getJrFormId(), form.getJrVersion()); if (instancesForVersion.isEmpty()) { formsRepository.delete(id); } else { formsRepository.softDelete(form.getId()); } } FormDeleter(FormsRepository formsRepository, InstancesRepository instancesRepository); void delete(Long id);  }