Commit 55241dca authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

#172 Deleting a descriptor list

parent bc81a380
......@@ -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,26 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
assertEquals(descriptorTwo.getUuid(), descriptorRepository.findByUuid(descriptorTwo.getUuid()).getUuid());
}
@Test
public void removeDescriptorListWithoutDescriptor() 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());
assertEquals(descriptorOne.getUuid(), descriptorRepository.findByUuid(descriptorOne.getUuid()).getUuid());
assertEquals(descriptorTwo.getUuid(), descriptorRepository.findByUuid(descriptorTwo.getUuid()).getUuid());
}
@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