TSK-858: removed unnecessary throws declarations

This commit is contained in:
Holger Hagen 2019-07-22 16:24:15 +02:00 committed by Dennis Lehmann
parent 523e0715c1
commit c216c4c380
3 changed files with 36 additions and 22 deletions

View File

@ -50,21 +50,37 @@ public class ClassificationController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationController.class);
private static final String LIKE = "%"; private static final String LIKE = "%";
private static final String NAME = "name"; private static final String NAME = "name";
private static final String NAME_LIKE = "name-like"; private static final String NAME_LIKE = "name-like";
private static final String KEY = "key"; private static final String KEY = "key";
private static final String DOMAIN = "domain"; private static final String DOMAIN = "domain";
private static final String CATEGORY = "category"; private static final String CATEGORY = "category";
private static final String TYPE = "type"; private static final String TYPE = "type";
private static final String CUSTOM_1_LIKE = "custom-1-like"; 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_2_LIKE = "custom-2-like";
private static final String CUSTOM_3_LIKE = "custom-3-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_4_LIKE = "custom-4-like";
private static final String CUSTOM_5_LIKE = "custom-5-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_6_LIKE = "custom-6-like";
private static final String CUSTOM_7_LIKE = "custom-7-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 CUSTOM_8_LIKE = "custom-8-like";
private static final String SORT_BY = "sort-by"; private static final String SORT_BY = "sort-by";
private static final String SORT_DIRECTION = "order"; private static final String SORT_DIRECTION = "order";
private ClassificationService classificationService; private ClassificationService classificationService;
@ -76,8 +92,7 @@ public class ClassificationController extends AbstractPagingController {
ClassificationController( ClassificationController(
ClassificationService classificationService, ClassificationService classificationService,
ClassificationResourceAssembler classificationResourceAssembler, ClassificationResourceAssembler classificationResourceAssembler,
ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler) {
) {
this.classificationService = classificationService; this.classificationService = classificationService;
this.classificationResourceAssembler = classificationResourceAssembler; this.classificationResourceAssembler = classificationResourceAssembler;
this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler; this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler;
@ -101,7 +116,8 @@ public class ClassificationController extends AbstractPagingController {
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>( ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>(
classificationSummaryResourceAssembler.toResources( classificationSummaryResourceAssembler.toResources(
classificationSummaries, classificationSummaries,
pageMetadata), HttpStatus.OK); pageMetadata),
HttpStatus.OK);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getClassifications(), returning {}", LOGGER.debug("Exit from getClassifications(), returning {}",
new ResponseEntity<>(response, HttpStatus.OK)); new ResponseEntity<>(response, HttpStatus.OK));
@ -133,8 +149,8 @@ public class ClassificationController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<ClassificationResource> createClassification( public ResponseEntity<ClassificationResource> createClassification(
@RequestBody ClassificationResource resource) @RequestBody ClassificationResource resource)
throws NotAuthorizedException, ClassificationNotFoundException, ClassificationAlreadyExistException, throws NotAuthorizedException, ClassificationAlreadyExistException,
ConcurrencyException, DomainNotFoundException, InvalidArgumentException { DomainNotFoundException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to createClassification(resource= {})", resource); LOGGER.debug("Entry to createClassification(resource= {})", resource);
} }
@ -155,7 +171,7 @@ public class ClassificationController extends AbstractPagingController {
public ResponseEntity<ClassificationResource> updateClassification( public ResponseEntity<ClassificationResource> updateClassification(
@PathVariable(value = "classificationId") String classificationId, @RequestBody ClassificationResource resource) @PathVariable(value = "classificationId") String classificationId, @RequestBody ClassificationResource resource)
throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException, throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException,
ClassificationAlreadyExistException, DomainNotFoundException, InvalidArgumentException { InvalidArgumentException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to updateClassification(classificationId= {}, resource= {})", classificationId, LOGGER.debug("Entry to updateClassification(classificationId= {}, resource= {})", classificationId,
resource); resource);

View File

@ -44,7 +44,7 @@ import pro.taskana.rest.resource.ClassificationResourceAssembler;
* Controller for Importing / Exporting classifications. * Controller for Importing / Exporting classifications.
*/ */
@RestController @RestController
@RequestMapping(path = "/v1/classification-definitions", produces = {MediaType.APPLICATION_JSON_VALUE}) @RequestMapping(path = "/v1/classification-definitions", produces = { MediaType.APPLICATION_JSON_VALUE })
public class ClassificationDefinitionController { public class ClassificationDefinitionController {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class);
@ -55,8 +55,7 @@ public class ClassificationDefinitionController {
ClassificationDefinitionController( ClassificationDefinitionController(
ClassificationService classificationService, ClassificationService classificationService,
ClassificationResourceAssembler classificationResourceAssembler ClassificationResourceAssembler classificationResourceAssembler) {
) {
this.classificationService = classificationService; this.classificationService = classificationService;
this.classificationResourceAssembler = classificationResourceAssembler; this.classificationResourceAssembler = classificationResourceAssembler;
} }
@ -65,8 +64,7 @@ public class ClassificationDefinitionController {
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<List<ClassificationResource>> exportClassifications( public ResponseEntity<List<ClassificationResource>> exportClassifications(
@RequestParam(required = false) String domain) @RequestParam(required = false) String domain)
throws ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException, throws ClassificationNotFoundException {
NotAuthorizedException, ConcurrencyException, ClassificationAlreadyExistException {
LOGGER.debug("Entry to exportClassifications(domain= {})", domain); LOGGER.debug("Entry to exportClassifications(domain= {})", domain);
ClassificationQuery query = classificationService.createClassificationQuery(); ClassificationQuery query = classificationService.createClassificationQuery();
@ -115,7 +113,7 @@ public class ClassificationDefinitionController {
} }
private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file) private List<ClassificationResource> extractClassificationResourcesFromFile(MultipartFile file)
throws IOException { throws IOException {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
List<ClassificationResource> classificationsDefinitions = mapper.readValue(file.getInputStream(), List<ClassificationResource> classificationsDefinitions = mapper.readValue(file.getInputStream(),
@ -125,7 +123,8 @@ public class ClassificationDefinitionController {
return classificationsDefinitions; return classificationsDefinitions;
} }
private Map<Classification, String> mapChildrenToParentKeys(List<ClassificationResource> classificationResources, Map<String, String> systemIds) { private Map<Classification, String> mapChildrenToParentKeys(List<ClassificationResource> classificationResources,
Map<String, String> systemIds) {
LOGGER.debug("Entry to mapChildrenToParentKeys()"); LOGGER.debug("Entry to mapChildrenToParentKeys()");
Map<Classification, String> childrenInFile = new HashMap<>(); Map<Classification, String> childrenInFile = new HashMap<>();
Set<String> newKeysWithDomain = new HashSet<>(); Set<String> newKeysWithDomain = new HashSet<>();
@ -180,14 +179,15 @@ public class ClassificationDefinitionController {
} }
private void updateParentChildrenRelations(Map<Classification, String> childrenInFile) private void updateParentChildrenRelations(Map<Classification, String> childrenInFile)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
LOGGER.debug("Entry to updateParentChildrenRelations()"); LOGGER.debug("Entry to updateParentChildrenRelations()");
for (Classification childRes : childrenInFile.keySet()) { for (Classification childRes : childrenInFile.keySet()) {
Classification child = classificationService Classification child = classificationService
.getClassification(childRes.getKey(), childRes.getDomain()); .getClassification(childRes.getKey(), childRes.getDomain());
String parentKey = childrenInFile.get(childRes); 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.setParentKey(parentKey);
child.setParentId(parentId); child.setParentId(parentId);
classificationService.updateClassification(child); classificationService.updateClassification(child);

View File

@ -10,8 +10,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
import pro.taskana.WorkbasketAccessItem; import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.WorkbasketAccessItemImpl; import pro.taskana.impl.WorkbasketAccessItemImpl;
import pro.taskana.rest.TestConfiguration; import pro.taskana.rest.TestConfiguration;
@ -19,18 +17,18 @@ import pro.taskana.rest.TestConfiguration;
* Test for {@link WorkbasketAccessItemResourceAssembler}. * Test for {@link WorkbasketAccessItemResourceAssembler}.
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestConfiguration.class}) @ContextConfiguration(classes = { TestConfiguration.class })
@WebAppConfiguration @WebAppConfiguration
public class WorkbasketAccessItemResourceAssemblerTest { public class WorkbasketAccessItemResourceAssemblerTest {
@Autowired @Autowired
WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler; WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler;
@Autowired @Autowired
WorkbasketService workbasketService; WorkbasketService workbasketService;
@Test @Test
public void workBasketAccessItemToResourcePropertiesEqual() public void workBasketAccessItemToResourcePropertiesEqual() {
throws NotAuthorizedException, WorkbasketNotFoundException {
// given // given
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2");
((WorkbasketAccessItemImpl) accessItem).setWorkbasketKey("workbasketKey"); ((WorkbasketAccessItemImpl) accessItem).setWorkbasketKey("workbasketKey");