Commit 65a80967 authored by Matija Obreza's avatar Matija Obreza

Updated all publishable entity services to use getUnpublishedXxxx

- loadXxxx includes lazyload, getXxxx does not
parent 7f80bcac
......@@ -83,7 +83,7 @@ public interface DescriptorListService {
* @param id id of descriptorList
* @return found descriptorList
*/
DescriptorList getDescriptorList(Long id);
DescriptorList loadDescriptorList(Long id);
/**
* Find descriptorList by UUID.
......@@ -91,7 +91,7 @@ public interface DescriptorListService {
* @param uuid UUID of descriptorList
* @return found descriptorList
*/
DescriptorList getDescriptorList(UUID uuid);
DescriptorList loadDescriptorList(UUID uuid);
/**
* Find descriptorList by UUID and version.
......@@ -100,7 +100,7 @@ public interface DescriptorListService {
* @param version record version
* @return found descriptorList
*/
DescriptorList getDescriptorList(UUID uuid, int version);
DescriptorList loadDescriptorList(UUID uuid, int version);
/**
* Reload descriptor list from database by identifiers and version.
......
......@@ -114,7 +114,7 @@ public interface DescriptorService {
* @return the descriptor
* @throws NotFoundElement if descriptor is not found
*/
Descriptor getDescriptor(UUID uuid, int version) throws NotFoundElement;
Descriptor loadDescriptor(UUID uuid, int version) throws NotFoundElement;
/**
* Page with descriptor list by user.
......
......@@ -15,7 +15,7 @@
*/
package org.genesys.catalog.service.impl;
import static org.genesys.catalog.model.traits.QDescriptor.descriptor;
import static org.genesys.catalog.model.traits.QDescriptor.*;
import java.io.IOException;
import java.io.OutputStream;
......@@ -59,8 +59,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
......@@ -72,11 +70,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate;
import org.springframework.web.multipart.MultipartFile;
/**
* The Class DescriptorServiceImpl.
......@@ -139,7 +137,35 @@ public class DescriptorServiceImpl implements DescriptorService {
return lazyLoad(descriptorRepository.save(descriptor));
}
private Descriptor getDescriptor(final Descriptor input) {
Descriptor descriptor = null;
if (input.getUuid() != null) {
descriptor = descriptorRepository.findByUuid(input.getUuid());
} else {
descriptor = descriptorRepository.findOne(input.getId());
}
if (descriptor == null) {
throw new NotFoundElement("Record not found by uuid=" + input.getUuid() + " or id=" + input.getId());
}
if (input.getVersion() != null && !descriptor.getVersion().equals(input.getVersion())) {
throw new ConcurrencyFailureException("Object version changed to " + descriptor.getVersion() + ", you provided " + input.getVersion());
}
return descriptor;
}
private Descriptor getUnpublishedDescriptor(Descriptor descriptor) {
descriptor = getDescriptor(descriptor);
if (descriptor.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Descriptor.");
}
return descriptor;
}
/**
* {@inheritDoc}
*/
......@@ -184,10 +210,7 @@ public class DescriptorServiceImpl implements DescriptorService {
public Descriptor updateImage(Descriptor descriptor, final MultipartFile file, final RepositoryImage imageMetadata) throws IOException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, NoSuchRepositoryFileException {
descriptor = descriptorRepository.findByUuidAndVersion(descriptor.getUuid(), descriptor.getVersion());
if (descriptor.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Descriptor.");
}
descriptor = getUnpublishedDescriptor(descriptor);
if (!file.getContentType().startsWith("image/")) {
throw new InvalidApiUsageException("Invalid image type: " + file.getContentType() + " is not permitted.");
......@@ -217,10 +240,7 @@ public class DescriptorServiceImpl implements DescriptorService {
@Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'write')")
public Descriptor removeImage(Descriptor descriptor) throws NoSuchRepositoryFileException, IOException {
descriptor = descriptorRepository.findByUuidAndVersion(descriptor.getUuid(), descriptor.getVersion());
if (descriptor.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Descriptor.");
}
descriptor = getUnpublishedDescriptor(descriptor);
final RepositoryImage repositoryImage = descriptor.getImage();
if (repositoryImage != null) {
......@@ -262,14 +282,10 @@ public class DescriptorServiceImpl implements DescriptorService {
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'WRITE')")
public Descriptor updateDescriptor(@Valid final Descriptor descriptor) {
final Descriptor loaded = getUnpublishedDescriptor(descriptor);
LOG.info("Updating descriptor uuid={} id={}", descriptor.getUuid(), descriptor.getId());
final Descriptor loaded = reloadDescriptor(descriptor);
final Partner owner = loaded.getOwner();
if (loaded.isPublished()) {
throw new DataIntegrityViolationException("Published descriptor can't be updated");
}
if (descriptor.getOwner() != null && !loaded.getOwner().equals(descriptor.getOwner())) {
throw new InvalidApiUsageException("Descriptor owner can't be changed");
}
......@@ -291,25 +307,6 @@ public class DescriptorServiceImpl implements DescriptorService {
return null;
}
private Descriptor reloadDescriptor(final Descriptor input) {
Descriptor descriptor = null;
if (input.getUuid() != null) {
descriptor = descriptorRepository.findByUuid(input.getUuid());
} else {
descriptor = descriptorRepository.findOne(input.getId());
}
if (descriptor == null) {
throw new DataRetrievalFailureException("Record not found by uuid=" + input.getUuid() + " or id=" + input.getId());
}
if (!descriptor.getVersion().equals(input.getVersion())) {
throw new ConcurrencyFailureException("Object version changed to " + descriptor.getVersion() + ", you provided " + input.getVersion());
}
return descriptor;
}
/**
* {@inheritDoc}
......@@ -337,7 +334,7 @@ public class DescriptorServiceImpl implements DescriptorService {
*/
@Override
@PostAuthorize("hasRole('ADMINISTRATOR') || returnObject==null || returnObject.isPublished() || hasPermission(returnObject, 'read')")
public Descriptor getDescriptor(final UUID uuid, final int version) {
public Descriptor loadDescriptor(final UUID uuid, final int version) {
return lazyLoad(descriptorRepository.findByUuidAndVersion(uuid, version));
}
......@@ -396,10 +393,8 @@ public class DescriptorServiceImpl implements DescriptorService {
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'delete')")
public Descriptor removeDescriptor(final Descriptor descriptor) {
final Descriptor loadedDescriptor = reloadDescriptor(descriptor);
if (loadedDescriptor.isPublished()) {
throw new InvalidApiUsageException("Cannot remove a published descriptor");
}
final Descriptor loadedDescriptor = getUnpublishedDescriptor(descriptor);
if (loadedDescriptor.getImage() != null) {
try {
repositoryService.removeFile(loadedDescriptor.getImage());
......@@ -471,7 +466,7 @@ public class DescriptorServiceImpl implements DescriptorService {
for (final Descriptor source : sources) {
Descriptor target;
if (source.getVersion() != null) {
target = descriptorRepository.findByUuidAndVersion(source.getUuid(), source.getVersion());
target = getUnpublishedDescriptor(source);
} else {
target = new Descriptor();
target.setUuid(source.getUuid());
......@@ -494,13 +489,8 @@ public class DescriptorServiceImpl implements DescriptorService {
@Transactional
@PreAuthorize("hasRole('ADMINISTRATOR')")
public Descriptor approveDescriptor(final Descriptor descriptor) {
final Descriptor loaded = descriptorRepository.findByUuidAndVersion(descriptor.getUuid(), descriptor.getVersion());
if (loaded == null) {
throw new NotFoundElement("No Descriptor with specified uuid and version");
}
if (loaded.isPublished()) {
throw new InvalidApiUsageException("Descriptor is already published");
}
final Descriptor loaded = getUnpublishedDescriptor(descriptor);
if (loaded.getState() == PublishState.DRAFT) {
throw new InvalidApiUsageException("Descriptor should be sent for review before publication");
}
......@@ -519,13 +509,8 @@ public class DescriptorServiceImpl implements DescriptorService {
@Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'administration')")
public Descriptor reviewDescriptor(final Descriptor descriptor) {
final Descriptor loaded = descriptorRepository.findByUuidAndVersion(descriptor.getUuid(), descriptor.getVersion());
if (loaded == null) {
throw new NotFoundElement("No Descriptor with specified uuid and version");
}
if (loaded.isPublished()) {
throw new InvalidApiUsageException("Descriptor is already published");
}
final Descriptor loaded = getUnpublishedDescriptor(descriptor);
if (loaded.getState() == PublishState.REVIEWING) {
throw new InvalidApiUsageException("The Descriptor is already under approval");
}
......@@ -545,10 +530,7 @@ public class DescriptorServiceImpl implements DescriptorService {
@Transactional(isolation = Isolation.READ_UNCOMMITTED, noRollbackFor = InvalidApiUsageException.class)
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#descriptor, 'administration')")
public Descriptor rejectDescriptor(final Descriptor descriptor) {
final Descriptor loaded = descriptorRepository.findByUuidAndVersion(descriptor.getUuid(), descriptor.getVersion());
if (loaded == null) {
throw new NotFoundElement("No Descriptor with specified uuid and version");
}
final Descriptor loaded = getDescriptor(descriptor);
if (!securityUtils.hasRole(UserRole.ADMINISTRATOR)) {
long oneDay = 24 * 60 * 60 * 1000;
......@@ -608,7 +590,7 @@ public class DescriptorServiceImpl implements DescriptorService {
@Transactional
@PreAuthorize("#descriptor.isPublished() || hasRole('ADMINISTRATOR') || hasPermission(#descriptor, 'read')")
public Descriptor nextVersion(final Descriptor descriptor, final boolean major) {
final Descriptor source = reloadDescriptor(descriptor);
final Descriptor source = getDescriptor(descriptor);
LOG.info("Creating new version for descriptor uuid={} id={}", descriptor.getUuid(), descriptor.getId());
final Descriptor copy = new Descriptor();
copy.apply(source);
......
......@@ -104,7 +104,7 @@ public class DescriptorController extends ApiBaseController {
@DeleteMapping(value = "/{uuid},{version}")
public Descriptor deleteDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version) {
try {
return descriptorService.removeDescriptor(descriptorService.getDescriptor(uuid, version));
return descriptorService.removeDescriptor(descriptorService.loadDescriptor(uuid, version));
} catch (DataIntegrityViolationException e) {
throw new InvalidApiUsageException("Cannot delete a referenced descriptor");
}
......@@ -119,7 +119,7 @@ public class DescriptorController extends ApiBaseController {
*/
@RequestMapping(value = "/approve", method = RequestMethod.POST)
public Descriptor approveDescriptor(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final Descriptor descriptor = descriptorService.getDescriptor(uuid, version);
final Descriptor descriptor = descriptorService.loadDescriptor(uuid, version);
return descriptorService.approveDescriptor(descriptor);
}
......@@ -132,7 +132,7 @@ public class DescriptorController extends ApiBaseController {
*/
@RequestMapping(value = "/for-review", method = RequestMethod.POST)
public Descriptor reviewDescriptor(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final Descriptor descriptor = descriptorService.getDescriptor(uuid, version);
final Descriptor descriptor = descriptorService.loadDescriptor(uuid, version);
return descriptorService.reviewDescriptor(descriptor);
}
......@@ -145,7 +145,7 @@ public class DescriptorController extends ApiBaseController {
*/
@RequestMapping(value = "/reject", method = RequestMethod.POST)
public Descriptor rejectDescriptor(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final Descriptor descriptor = descriptorService.getDescriptor(uuid, version);
final Descriptor descriptor = descriptorService.loadDescriptor(uuid, version);
return descriptorService.rejectDescriptor(descriptor);
}
......
......@@ -108,7 +108,7 @@ public class DescriptorListController {
*/
@GetMapping(value = "/{uuid}")
public DescriptorList getDescriptorList(@PathVariable("uuid") final UUID uuid) {
return descriptorListService.getDescriptorList(uuid);
return descriptorListService.loadDescriptorList(uuid);
}
/**
......@@ -120,7 +120,7 @@ public class DescriptorListController {
*/
@DeleteMapping(value = "/{uuid},{version}")
public DescriptorList deleteDescriptorList(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version) {
return descriptorListService.deleteDescriptorList(descriptorListService.getDescriptorList(uuid, version));
return descriptorListService.deleteDescriptorList(descriptorListService.loadDescriptorList(uuid, version));
}
/**
......@@ -133,7 +133,7 @@ public class DescriptorListController {
@Transactional(readOnly = true)
@GetMapping(value = "/{uuid}/html", produces = { "text/html" })
public void generateDocument(@PathVariable("uuid") final UUID uuid, final HttpServletRequest request, final HttpServletResponse response) throws IOException {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid);
final String descriptorListHtml = exporter.htmlDescriptorList(descriptorList);
String eTag = descriptorList.getUuid() + "-" + descriptorList.getVersion();
......@@ -268,7 +268,7 @@ public class DescriptorListController {
*/
@PostMapping(value = "/add-descriptors/{uuid},{version}")
public DescriptorList addDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
final List<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toList());
return descriptorListService.addDescriptors(descriptorList, descriptors.toArray(new Descriptor[] {}));
}
......@@ -283,7 +283,7 @@ public class DescriptorListController {
*/
@PostMapping(value = "/remove-descriptors/{uuid},{version}")
public DescriptorList removeDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
final Set<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toSet());
return descriptorListService.removeDescriptors(descriptorList, descriptors.toArray(new Descriptor[] {}));
}
......@@ -298,7 +298,7 @@ public class DescriptorListController {
*/
@PostMapping(value = "/set-descriptors/{uuid},{version}")
public DescriptorList setDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
final List<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toList());
return descriptorListService.setDescriptors(descriptorList, descriptors.toArray(new Descriptor[] {}));
}
......@@ -312,7 +312,7 @@ public class DescriptorListController {
*/
@RequestMapping(value = "/approve", method = RequestMethod.POST)
public DescriptorList approveDescriptorList(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
return descriptorListService.approveDescriptorList(descriptorList);
}
......@@ -325,14 +325,14 @@ public class DescriptorListController {
*/
@RequestMapping(value = "/for-review", method = RequestMethod.POST)
public DescriptorList reviewDescriptorList(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
return descriptorListService.reviewDescriptorList(descriptorList);
}
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "{uuid}/download", method = RequestMethod.POST)
public void download(@PathVariable("uuid") final UUID uuid, HttpServletResponse response) throws IOException, NotFoundElement {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid);
if (descriptorList == null) {
throw new NotFoundElement();
}
......@@ -359,7 +359,7 @@ public class DescriptorListController {
*/
@RequestMapping(value = "/reject", method = RequestMethod.POST)
public DescriptorList rejectDescriptorList(@RequestParam(value = "uuid", required = true) final UUID uuid, @RequestParam(value = "version", required = true) final int version) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final DescriptorList descriptorList = descriptorListService.loadDescriptorList(uuid, version);
return descriptorListService.rejectDescriptorList(descriptorList);
}
......
......@@ -24,6 +24,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import javax.validation.ConstraintViolationException;
import org.genesys.catalog.model.Partner;
import org.genesys.catalog.model.filters.DescriptorListFilter;
import org.genesys.catalog.model.traits.Descriptor;
......@@ -34,11 +36,11 @@ import org.genesys.catalog.service.impl.DescriptorListServiceImpl;
import org.genesys2.server.exception.InvalidApiUsageException;
import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.impl.Crop;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -47,8 +49,6 @@ import org.springframework.data.domain.Sort;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import javax.validation.ConstraintViolationException;
/**
* Test for {@link DescriptorListServiceImpl}
*
......@@ -94,12 +94,12 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
@Test(expected = NotFoundElement.class)
public void testNonExistent() {
descriptorListService.getDescriptorList(UUID.randomUUID());
descriptorListService.loadDescriptorList(UUID.randomUUID());
}
@Test(expected = NotFoundElement.class)
public void findNullDescriptorListById() {
assertNull(descriptorListService.getDescriptorList(10L));
assertNull(descriptorListService.loadDescriptorList(10L));
}
@Test
......@@ -131,7 +131,7 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
descriptorList.setUuid(uuid);
descriptorList = descriptorListService.createDescriptorList(descriptorList);
final DescriptorList result = descriptorListService.getDescriptorList(uuid);
final DescriptorList result = descriptorListService.loadDescriptorList(uuid);
assertThat(result, not(nullValue()));
assertEquals(descriptorList.getId(), result.getId());
assertEquals(descriptorList.getUuid(), result.getUuid());
......@@ -142,7 +142,7 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
DescriptorList descriptorList = setupDescriptorList(DESCRIPTION_LIST_TITLE1, VERSION_1_0, DESCRIPTION_1);
descriptorList = descriptorListService.createDescriptorList(descriptorList);
final DescriptorList result = descriptorListService.getDescriptorList(descriptorList.getId());
final DescriptorList result = descriptorListService.loadDescriptorList(descriptorList.getId());
assertThat(result, not(nullValue()));
assertEquals(descriptorList.getId(), result.getId());
assertEquals(descriptorList.getUuid(), result.getUuid());
......@@ -255,7 +255,7 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
assertThat(result.getDescriptors(), contains(descriptorOne, descriptorTwo));
}
@Test(expected = ConcurrencyFailureException.class)
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFailUpdateWithoutIdentifiers() {
final DescriptorList descriptorList = setupDescriptorList(DESCRIPTION_LIST_TITLE1, VERSION_1_0, DESCRIPTION_1);
......@@ -267,7 +267,7 @@ public class DescriptorListServiceTest extends CatalogServiceTest {
descriptorListService.updateDescriptorList(result);
}
@Test(expected = ConcurrencyFailureException.class)
@Test(expected = InvalidDataAccessApiUsageException.class)
public void testFailUpdateNonExistent() {
final DescriptorList descriptorList = setupDescriptorList(DESCRIPTION_LIST_TITLE1, VERSION_1_0, DESCRIPTION_1);
......
......@@ -39,7 +39,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -148,7 +147,7 @@ public class DescriptorServiceTest extends CatalogServiceTest {
assertThat(vocabularyTermRepository.count(), is(4l));
result = descriptorService.removeDescriptor(result);
descriptorService.getDescriptor(result.getUuid(), result.getVersion());
descriptorService.loadDescriptor(result.getUuid(), result.getVersion());
assertThat(vocabularyTermRepository.count(), is(2l));
}
......@@ -163,7 +162,7 @@ public class DescriptorServiceTest extends CatalogServiceTest {
assertThat(result.getTerms(), not(hasSize(0)));
result = descriptorService.removeDescriptor(result);
descriptorService.getDescriptor(result.getUuid(), result.getVersion());
descriptorService.loadDescriptor(result.getUuid(), result.getVersion());
assertThat(vocabularyTermRepository.count(), is(0l));
}
......@@ -479,7 +478,7 @@ public class DescriptorServiceTest extends CatalogServiceTest {
/**
* Fail to update descriptor when isPublish() = true
*/
@Test(expected = DataIntegrityViolationException.class)
@Test(expected = InvalidApiUsageException.class)
public void testFailOnUpdateDescriptorWithPublished() {
final Descriptor input = descriptorService.createDescriptor(setupDescriptor(null, DESCRIPTOR_TITLE_1, Category.EVALUATION, DataType.NUMERIC, VERSION_1_0, PublishState.DRAFT));
assertThat(input.getState(), is(PublishState.DRAFT));
......@@ -517,7 +516,7 @@ public class DescriptorServiceTest extends CatalogServiceTest {
descriptorService.updateDescriptor(result);
}
@Test(expected = DataRetrievalFailureException.class)
@Test(expected = NotFoundElement.class)
public void testFailUpdateNonExistent() {
final Descriptor input = setupDescriptor(null, DESCRIPTOR_TITLE_1, Category.PASSPORT, DataType.NUMERIC, VERSION_1_0, PublishState.DRAFT);
input.setState(PublishState.PUBLISHED);
......
Markdown is supported
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