Commit 57d72bee authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '172-deleting-a-descriptor-list' into 'master'

Resolve "Deleting a descriptor list"

Closes #172

See merge request !166
parents bc81a380 7e3f803c
Pipeline #5624 passed with stage
in 1 minute and 25 seconds
......@@ -104,7 +104,7 @@ public class DescriptorList extends UuidModel implements Publishable, SelfCleani
private String bibliographicCitation;
/** The descriptors. */
@ManyToMany(cascade = { CascadeType.REMOVE, CascadeType.REFRESH }, fetch = FetchType.LAZY)
@ManyToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY)
@JoinTable(name = "descriptorListDescriptor", joinColumns = @JoinColumn(name = "descriptorListId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "descriptorId", referencedColumnName = "id"))
@OrderColumn(name = "position")
@JsonView({ JsonViews.Public.class })
......
......@@ -289,6 +289,27 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
assertEquals(descriptorTwo.getUuid(), descriptorRepository.findByUuid(descriptorTwo.getUuid()).getUuid());
}
@Test
public void removeDescriptorListButKeepDescriptors() throws Exception {
final Descriptor descriptorOne = setupDescriptor(partner, DESCRIPTOR_TITLE_1, VERSION_1_0, Descriptor.DataType.NUMERIC);
final Descriptor descriptorTwo = setupDescriptor(partnerSecond, DESCRIPTOR_TITLE_2, VERSION_2_0, Descriptor.DataType.NUMERIC);
final List<Descriptor> descriptors = Lists.newArrayList(descriptorOne, descriptorTwo);
DescriptorList descriptorList = setupDescriptorList(DESCRIPTION_LIST_TITLE1, VERSION_1_0, DESCRIPTION_1);
descriptorList.setDescriptors(descriptors);
descriptorList = descriptorListService.createDescriptorList(descriptorList);
assertThat(descriptorList.getDescriptors(), hasSize(2));
final DescriptorList result = descriptorListService.deleteDescriptorList(descriptorList);
assertEquals(descriptorList.getUuid(), result.getUuid());
assertThat(descriptorListRepository.findByUuid(descriptorList.getUuid()), nullValue());
assertThat(descriptorRepository.findByUuid(descriptorOne.getUuid()), not(nullValue()));
assertThat(descriptorRepository.findByUuid(descriptorTwo.getUuid()), not(nullValue()));
}
@Test
public void addDescriptorToDescriptorList() throws Exception {
final Descriptor descriptorOne = setupDescriptor(partner, DESCRIPTOR_TITLE_1, VERSION_1_0, Descriptor.DataType.NUMERIC);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment