From c216c4c3804c2c0d278515bf1d3817cd86badd5f Mon Sep 17 00:00:00 2001 From: Holger Hagen <19706592+holgerhagen@users.noreply.github.com> Date: Mon, 22 Jul 2019 16:24:15 +0200 Subject: [PATCH] TSK-858: removed unnecessary throws declarations --- .../rest/ClassificationController.java | 28 +++++++++++++++---- .../ClassificationDefinitionController.java | 22 +++++++-------- ...basketAccessItemResourceAssemblerTest.java | 8 ++---- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java index 85ed12db6..49f90ced9 100644 --- a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java +++ b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationController.java @@ -50,21 +50,37 @@ public class ClassificationController extends AbstractPagingController { private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final String LIKE = "%"; + private static final String NAME = "name"; + private static final String NAME_LIKE = "name-like"; + private static final String KEY = "key"; + private static final String DOMAIN = "domain"; + private static final String CATEGORY = "category"; + private static final String TYPE = "type"; + private static final String CUSTOM_1_LIKE = "custom-1-like"; + private static final String CUSTOM_2_LIKE = "custom-2-like"; + private static final String CUSTOM_3_LIKE = "custom-3-like"; + private static final String CUSTOM_4_LIKE = "custom-4-like"; + private static final String CUSTOM_5_LIKE = "custom-5-like"; + private static final String CUSTOM_6_LIKE = "custom-6-like"; + private static final String CUSTOM_7_LIKE = "custom-7-like"; + private static final String CUSTOM_8_LIKE = "custom-8-like"; + private static final String SORT_BY = "sort-by"; + private static final String SORT_DIRECTION = "order"; private ClassificationService classificationService; @@ -76,8 +92,7 @@ public class ClassificationController extends AbstractPagingController { ClassificationController( ClassificationService classificationService, ClassificationResourceAssembler classificationResourceAssembler, - ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler - ) { + ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler) { this.classificationService = classificationService; this.classificationResourceAssembler = classificationResourceAssembler; this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler; @@ -101,7 +116,8 @@ public class ClassificationController extends AbstractPagingController { ResponseEntity> response = new ResponseEntity<>( classificationSummaryResourceAssembler.toResources( classificationSummaries, - pageMetadata), HttpStatus.OK); + pageMetadata), + HttpStatus.OK); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from getClassifications(), returning {}", new ResponseEntity<>(response, HttpStatus.OK)); @@ -133,8 +149,8 @@ public class ClassificationController extends AbstractPagingController { @Transactional(rollbackFor = Exception.class) public ResponseEntity createClassification( @RequestBody ClassificationResource resource) - throws NotAuthorizedException, ClassificationNotFoundException, ClassificationAlreadyExistException, - ConcurrencyException, DomainNotFoundException, InvalidArgumentException { + throws NotAuthorizedException, ClassificationAlreadyExistException, + DomainNotFoundException, InvalidArgumentException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to createClassification(resource= {})", resource); } @@ -155,7 +171,7 @@ public class ClassificationController extends AbstractPagingController { public ResponseEntity updateClassification( @PathVariable(value = "classificationId") String classificationId, @RequestBody ClassificationResource resource) throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException, - ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException { + InvalidArgumentException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to updateClassification(classificationId= {}, resource= {})", classificationId, resource); diff --git a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationDefinitionController.java b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationDefinitionController.java index fdca8d598..c41ad6d62 100644 --- a/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationDefinitionController.java +++ b/rest/taskana-rest-spring/src/main/java/pro/taskana/rest/ClassificationDefinitionController.java @@ -44,7 +44,7 @@ import pro.taskana.rest.resource.ClassificationResourceAssembler; * Controller for Importing / Exporting classifications. */ @RestController -@RequestMapping(path = "/v1/classification-definitions", produces = {MediaType.APPLICATION_JSON_VALUE}) +@RequestMapping(path = "/v1/classification-definitions", produces = { MediaType.APPLICATION_JSON_VALUE }) public class ClassificationDefinitionController { private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class); @@ -55,8 +55,7 @@ public class ClassificationDefinitionController { ClassificationDefinitionController( ClassificationService classificationService, - ClassificationResourceAssembler classificationResourceAssembler - ) { + ClassificationResourceAssembler classificationResourceAssembler) { this.classificationService = classificationService; this.classificationResourceAssembler = classificationResourceAssembler; } @@ -65,8 +64,7 @@ public class ClassificationDefinitionController { @Transactional(readOnly = true, rollbackFor = Exception.class) public ResponseEntity> exportClassifications( @RequestParam(required = false) String domain) - throws ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException, - NotAuthorizedException, ConcurrencyException, ClassificationAlreadyExistException { + throws ClassificationNotFoundException { LOGGER.debug("Entry to exportClassifications(domain= {})", domain); ClassificationQuery query = classificationService.createClassificationQuery(); @@ -115,7 +113,7 @@ public class ClassificationDefinitionController { } private List extractClassificationResourcesFromFile(MultipartFile file) - throws IOException { + throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); List classificationsDefinitions = mapper.readValue(file.getInputStream(), @@ -125,7 +123,8 @@ public class ClassificationDefinitionController { return classificationsDefinitions; } - private Map mapChildrenToParentKeys(List classificationResources, Map systemIds) { + private Map mapChildrenToParentKeys(List classificationResources, + Map systemIds) { LOGGER.debug("Entry to mapChildrenToParentKeys()"); Map childrenInFile = new HashMap<>(); Set newKeysWithDomain = new HashSet<>(); @@ -180,14 +179,15 @@ public class ClassificationDefinitionController { } private void updateParentChildrenRelations(Map childrenInFile) - throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, - InvalidArgumentException { + throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, + InvalidArgumentException { LOGGER.debug("Entry to updateParentChildrenRelations()"); for (Classification childRes : childrenInFile.keySet()) { Classification child = classificationService - .getClassification(childRes.getKey(), childRes.getDomain()); + .getClassification(childRes.getKey(), childRes.getDomain()); String parentKey = childrenInFile.get(childRes); - String parentId = (parentKey == null) ? "" : classificationService.getClassification(parentKey, childRes.getDomain()).getId(); + String parentId = (parentKey == null) ? "" + : classificationService.getClassification(parentKey, childRes.getDomain()).getId(); child.setParentKey(parentKey); child.setParentId(parentId); classificationService.updateClassification(child); diff --git a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/WorkbasketAccessItemResourceAssemblerTest.java b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/WorkbasketAccessItemResourceAssemblerTest.java index 07aef2eb3..9051c07d0 100644 --- a/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/WorkbasketAccessItemResourceAssemblerTest.java +++ b/rest/taskana-rest-spring/src/test/java/pro/taskana/rest/resource/WorkbasketAccessItemResourceAssemblerTest.java @@ -10,8 +10,6 @@ import org.springframework.test.context.web.WebAppConfiguration; import pro.taskana.WorkbasketAccessItem; import pro.taskana.WorkbasketService; -import pro.taskana.exceptions.NotAuthorizedException; -import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.impl.WorkbasketAccessItemImpl; import pro.taskana.rest.TestConfiguration; @@ -19,18 +17,18 @@ import pro.taskana.rest.TestConfiguration; * Test for {@link WorkbasketAccessItemResourceAssembler}. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {TestConfiguration.class}) +@ContextConfiguration(classes = { TestConfiguration.class }) @WebAppConfiguration public class WorkbasketAccessItemResourceAssemblerTest { @Autowired WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler; + @Autowired WorkbasketService workbasketService; @Test - public void workBasketAccessItemToResourcePropertiesEqual() - throws NotAuthorizedException, WorkbasketNotFoundException { + public void workBasketAccessItemToResourcePropertiesEqual() { // given WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2"); ((WorkbasketAccessItemImpl) accessItem).setWorkbasketKey("workbasketKey");