From aec98295cbc6efaba5fba6e8be2df4069d6a51e1 Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Fri, 1 Nov 2019 14:36:03 +0100 Subject: [PATCH] Allow resources with multiple mapping values --- ...ngBootBoundedContextDiscoveryStrategy.java | 2 +- .../boot/interfaces/IgnoredResource.java | 27 +++++++++++++++++++ .../interfaces/CustomerInformationHolder.java | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/java/test/application/spring/boot/interfaces/IgnoredResource.java diff --git a/src/main/java/org/contextmapper/discovery/strategies/boundedcontexts/SpringBootBoundedContextDiscoveryStrategy.java b/src/main/java/org/contextmapper/discovery/strategies/boundedcontexts/SpringBootBoundedContextDiscoveryStrategy.java index 5329793..aa345f4 100644 --- a/src/main/java/org/contextmapper/discovery/strategies/boundedcontexts/SpringBootBoundedContextDiscoveryStrategy.java +++ b/src/main/java/org/contextmapper/discovery/strategies/boundedcontexts/SpringBootBoundedContextDiscoveryStrategy.java @@ -64,7 +64,7 @@ private Set discoverAggregates(BoundedContext bc, String packageName) Set resultSet = new HashSet<>(); for (Class type : new AnnotationScanner().scanForAnnotatedType(packageName, RequestMapping.class)) { RequestMapping requestMapping = type.getAnnotation(RequestMapping.class); - if (requestMapping.value().length == 1) { + if (requestMapping.value().length > 0) { Aggregate aggregate = createAggregate(bc, requestMapping.value()[0]); aggregate.addEntities(discoverEntities(aggregate.getName(), type)); resultSet.add(aggregate); diff --git a/src/test/java/test/application/spring/boot/interfaces/IgnoredResource.java b/src/test/java/test/application/spring/boot/interfaces/IgnoredResource.java new file mode 100644 index 0000000..0de6e2e --- /dev/null +++ b/src/test/java/test/application/spring/boot/interfaces/IgnoredResource.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 The Context Mapper Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package test.application.spring.boot.interfaces; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping +public class IgnoredResource { + + // this resource will be ignored, since the @RequestMapping annotation contains no value + +} diff --git a/src/test/java/test/duplicate/entity/name/interfaces/CustomerInformationHolder.java b/src/test/java/test/duplicate/entity/name/interfaces/CustomerInformationHolder.java index be6ce1e..a11b5e2 100644 --- a/src/test/java/test/duplicate/entity/name/interfaces/CustomerInformationHolder.java +++ b/src/test/java/test/duplicate/entity/name/interfaces/CustomerInformationHolder.java @@ -22,7 +22,7 @@ import test.duplicate.entity.name.model.CustomerId; @RestController -@RequestMapping({"/customers"}) +@RequestMapping({"customers", "second-ignored-mapping"}) public class CustomerInformationHolder { @PutMapping({"/{customerId}/address"})