From 08a10f77d4a6bdecf4a19a7a539468a77cfc6535 Mon Sep 17 00:00:00 2001 From: latlon team <info@lat-lon.de> Date: Tue, 10 Dec 2024 15:04:43 +0000 Subject: [PATCH] Code drop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - XPLANBOX-3451 minor improvements in user manual about usage of bearer token (61eae56f2) - XPLANBOX-3509 - added missing @Deprecated annotations (3c4bf02d6) - XPLANBOX-3451 - fixed proefile name, improved describtion of the http header Authorization (e044fa9a7) - XPLANBOX-3462 - Enhance JWT Groovy scripts, set variable and update descriptions (26ddb39f0) - XPLANBOX-3461 moved description of usage of JWT into user manual (73b0c0f61) - XPLANBOX-3451 - fixed list items (8d9abd438) - XPLANBOX-3412 - removed test dependencies from xplan-core-gwt (140e74cb8) - XPLANBOX-3412 - migrated juni4 to junit5 (xplan-core-validator) (d4f25accb) - XPLANBOX-3509 - set GetAttachmentHandler to deprecated (701611915) - XPLANBOX-3443 - added references event (6df9a6330) - XPLANBOX-3461 added chapter for secured REST APIs in operations manual (b1efc4c46) - Enumerationswerte für v6 fehlen in Style für SO_Gebiet (318a1b957) - XPLANBOX-3451 - fixed tests-soapui.Jenkinsfile (c3f09750e) - XPLANBOX-3451 - moved @PreAuthorize annotation to xplan-manager-web (61037f2af) - XPLANBOX-3451 - execution of security workflow tests (4a5507f1b) - XPLANBOX-3451 - added new Workflow v2 Security with JWT TestCase (a766caa58) - XPLANBOX-3451 - fixed @PreAuthorize of XPlanGml import (9582c8a52) - XPLANBOX-3451 - conditional AgsAuthorizer (not required in XPlanValidatorAPI and XPlanDokumenteAPI) (b6f15d190) - XPLANBOX-3412 migrate xplan-core-manager to JUnit 5 (eab10db4f) - XPLANBOX-3451 - implemented authorization of edit and delete (7d5e8d99c) - XPLANBOX-3451 - replaced configuration of OAuth2JwtContext with @PreAuthorized in PlanApi and PlanApi2 (e2bac9578) - XPLANBOX-3451 - implemented and integrated AgsParser (e50372b11) - XPLANBOX-3451 - implemented AgsAuthorizer authorizing ags attributes (90c9a401f) - XLANBOX-3451 - authorized role XPLANBOX_ADMIN to methods POST, PUT and DELETE (e5c3cb70d) Co-authored-by: Dirk Stenger <stenger@lat-lon.de> Co-authored-by: Lyn Elisa Goltz <goltz@lat-lon.de> Co-authored-by: Marc Guillemot <guillemot@lat-lon.de> Co-authored-by: Tobias Kraft <tobias.kraft@gv.hamburg.de> Co-authored-by: Torsten Friebe <friebe@lat-lon.de> Co-authored-by: Torsten Friebe <torsten.friebe@gmail.com> Dropped from commit: 2137a0771b44162b718b3869a0145501c5d08bdf --- jenkinsfiles/tests-soapui.Jenkinsfile | 7 +- .../validator/web/shared/ValidationType.java | 2 +- xplan-core/xplan-core-gwt/pom.xml | 10 - xplan-core/xplan-core-manager/pom.xml | 22 +- .../de/latlon/xplan/manager/XPlanManager.java | 6 - .../xplan/manager/XPlanManagerTest.java | 63 +- .../ManagerConfigurationTest.java | 81 +- .../document/XPlanDocumentManagerTest.java | 8 +- .../document/s3/S3DocumentStorageIT.java | 31 +- .../edit/ExternalReferenceUtilsTest.java | 64 +- .../manager/edit/XPlanManipulatorTest.java | 1235 +++++++++-------- .../manager/edit/XPlanToEditFactoryTest.java | 496 ++++--- .../export/XPlanArtefactExporterTest.java | 31 +- .../metadata/MetadataCouplingHandlerTest.java | 26 +- .../ServiceMetadataDocumentWriterTest.java | 68 +- .../metadata/csw/CswClientTestManual.java | 32 +- .../PlanwerkServiceMetadataBuilderTest.java | 55 +- .../s3/S3StorageCleanUpManagerTest.java | 11 +- .../storage/s3/S3StorageTestManual.java | 65 +- .../attachment/AttachmentUrlHandlerTest.java | 85 +- .../raster/RasterConfigurationSorterTest.java | 71 +- .../storage/s3/S3RasterStorageTest.java | 20 +- .../storage/s3/S3RasterStorageTestManual.java | 52 +- .../workspace/WorkspaceReloaderTest.java | 23 +- .../manager/workspace/WorkspaceUtilsTest.java | 101 +- xplan-core/xplan-core-security/pom.xml | 7 +- .../security/authorization/AgsAccessor.java | 13 + ...mAccessJwtGrantedAuthoritiesConverter.java | 41 + .../security/authorization/AgsAuthorizer.java | 63 + .../security/authorization/AgsParser.java | 133 ++ .../security/config/OAuth2JwtContext.java | 32 +- ...essJwtGrantedAuthoritiesConverterTest.java | 74 + .../authorization/AgsAuthorizerTest.java | 91 ++ .../security/authorization/AgsParserTest.java | 36 + .../security/authorization/BPlan001_6-0.gml | 372 +++++ .../security/authorization/BPlan001_6-0.zip | Bin 0 -> 3337 bytes .../xp/XpExterneReferenzFlattener.java | 17 +- .../events/v1/XPlanPublicV1Event.java | 4 + .../events/v1/XPlanPublicV1EventTest.java | 24 + xplan-core/xplan-core-validator/pom.xml | 29 +- .../xplan/validator/XPlanGmlValidation.java | 5 + .../validator/XPlanGmlValidationTest.java | 2 +- .../xplan/validator/XPlanValidatorTest.java | 41 +- .../ValidatorConfigurationParserTest.java | 91 +- .../geometric/GeometricValidatorImplTest.java | 12 +- ...rameterizedGeometricValidatorImplTest.java | 29 +- .../geometric/XPlanGeometryInspectorTest.java | 2 +- .../aenderungen/AenderungenInspectorTest.java | 11 +- .../DoppelbelegungInspectorTest.java | 2 +- ...OptimisedFlaechenschlussInspectorTest.java | 14 +- ...eichInspectorKompensationsbereichTest.java | 21 +- .../GeltungsbereichInspectorTest.java | 4 +- .../planinfo/PlanInfoParserTest.java | 6 +- .../ExternalReferenceEvaluatorTest.java | 2 +- .../validator/report/ReportUtilsTest.java | 4 +- .../validator/report/ReportWriterTest.java | 25 +- .../validator/report/ValidatorDetailTest.java | 28 +- .../report/geojson/GeoJsonBuilderTest.java | 2 +- .../geojson/GeoJsonGeometryBuilderTest.java | 2 +- .../report/html/HtmlReportGeneratorTest.java | 23 +- .../report/pdf/PdfReportGeneratorTest.java | 15 +- .../report/pdf/ReportBuilderTest.java | 32 +- .../report/xml/XmlReportGeneratorTest.java | 23 +- .../DefaultRulesMessagesAccessorTest.java | 2 +- .../FileRulesMessagesAccessorTest.java | 34 +- .../SemanticValidationOptionsTest.java | 12 +- .../SemanticValidatorConfigurationTest.java | 20 +- .../metadata/RulesVersionParserTest.java | 2 +- ...icValidatorConfigurationRetrieverTest.java | 2 +- .../profile/SemanticProfilesCreatorTest.java | 15 +- .../report/SemanticValidatorResultTest.java | 4 +- .../XQuerySemanticValidatorRuleTest.java | 15 +- .../xquery/XQuerySemanticValidatorTest.java | 84 +- .../ParameterizedSyntacticValidatorTest.java | 19 +- .../syntactic/SyntacticValidatorTest.java | 2 +- .../wms/ValidatorWmsManagerTest.java | 12 +- .../wms/storage/SqlPlanStorageTest.java | 14 +- .../src/main/asciidoc/XPlanManager_API.adoc | 29 + .../src/main/asciidoc/XPlanWMS.adoc | 4 +- .../src/main/asciidoc/aktualisierung.adoc | 2 +- .../main/asciidoc/anhang/aktualisierung.adoc | 2 +- .../installation/postinstallation.adoc | 6 +- .../konfiguration/dienste/html_gfi.adoc | 4 +- .../konfiguration/manager/absicherung.adoc | 10 +- .../konfiguration/manager/kartenvorschau.adoc | 2 +- .../asciidoc/konfiguration/manager/main.adoc | 2 +- .../konfiguration/rest-api/absicherung.adoc | 27 + .../konfiguration/rest-api/konfiguration.adoc | 170 +++ .../asciidoc/konfiguration/rest-api/main.adoc | 176 +-- .../validator/kartenvorschau.adoc | 2 +- .../konfiguration/validator/main.adoc | 2 +- .../src/main/asciidoc/migration.adoc | 2 +- .../manager/config/ApplicationContext.java | 3 +- .../api/manager/handler/PlanHandler.java | 10 +- .../manager/openapi/AbstractApiConfig.java | 1 + .../api/manager/v1/PlanAenderungenApi.java | 2 + .../xplanbox/api/manager/v1/PlanApi.java | 6 + .../api/manager/v1/PlanBasisdatenApi.java | 2 + .../api/manager/v1/PlanDokumentApi.java | 4 + .../api/manager/v1/PlanGueltigkeitApi.java | 2 + .../api/manager/v1/PlanRasterbasisApi.java | 4 + .../api/manager/v2/PlanAenderungenApi2.java | 2 + .../xplanbox/api/manager/v2/PlanApi2.java | 6 + .../api/manager/v2/PlanBasisdatenApi2.java | 2 + .../api/manager/v2/PlanDokumentApi2.java | 4 + .../api/manager/v2/PlanRasterbasisApi2.java | 4 + .../xplanbox/api/manager/v2/PlanTextApi2.java | 3 + .../server/service/ManagerServiceImpl.java | 22 +- .../rabbit/manager/ManagerPublicEventsIT.java | 10 + .../validator/ValidationPublicEventsIT.java | 10 + xplan-tests/xplan-tests-soapui/README.md | 6 +- xplan-tests/xplan-tests-soapui/pom.xml | 8 + .../xplan-dokumente-api-soapui-project.xml | 2 +- .../xplan-manager-api-soapui-project.xml | 702 +++++++++- .../plans/BP_6.0_Dortmund.gml | 400 ++++++ .../xplan-validator-api-soapui-project.xml | 8 +- .../EventValidationProcessListener.java | 4 + .../validator/executor/PlanValidatorTest.java | 12 +- .../xplan/wms/GetAttachmentHandler.java | 5 +- .../styles/xplansyn/default/so/so_gebiet.xml | 4 + 120 files changed, 4059 insertions(+), 1863 deletions(-) create mode 100644 xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAccessor.java create mode 100644 xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverter.java create mode 100644 xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAuthorizer.java create mode 100644 xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsParser.java create mode 100644 xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverterTest.java create mode 100644 xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAuthorizerTest.java create mode 100644 xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsParserTest.java create mode 100644 xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.gml create mode 100644 xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.zip create mode 100644 xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/absicherung.adoc create mode 100644 xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/konfiguration.adoc create mode 100644 xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api/plans/BP_6.0_Dortmund.gml diff --git a/jenkinsfiles/tests-soapui.Jenkinsfile b/jenkinsfiles/tests-soapui.Jenkinsfile index 061fefd2a2..5dddc4bf5a 100644 --- a/jenkinsfiles/tests-soapui.Jenkinsfile +++ b/jenkinsfiles/tests-soapui.Jenkinsfile @@ -31,12 +31,15 @@ pipeline { stage('SoapUI-Test XPlanManagerAPI') { steps { withCredentials([ - usernamePassword(credentialsId:"${CREDENTIALS_ID}", passwordVariable: 'Password', usernameVariable: 'Username') + usernamePassword(credentialsId:"${CREDENTIALS_ID}", passwordVariable: 'Password', usernameVariable: 'Username'), + usernamePassword(credentialsId:"${CREDENTIALS_ID}-dortmund", passwordVariable: 'PasswordDortmund', usernameVariable: 'UsernameDortmund'), + usernamePassword(credentialsId:"${CREDENTIALS_ID}-gelsenkirchen", passwordVariable: 'PasswordNotDortmund', usernameVariable: 'UsernameNotDortmund') ]) { sh 'mvn test -pl :xplan-tests-soapui -Psystem-tests -DtestFileName=xplan-manager-api-soapui-project.xml \ -DbaseUrlManagerApi=${BASE_URL_MANAGER_API} -Dusername=$Username -Dpassword=$Password \ -DjwtUrl=$JWT_URL -DjwtClientId=$JWT_CLIENTID \ - -DbaseUrlServices=${BASE_URL_DIENSTE} ' + -DbaseUrlServices=${BASE_URL_DIENSTE} \ + -DusernameDortmund=${UsernameDortmund} -DpasswordDortmund=${PasswordDortmund} -DusernameNotDortmund=${UsernameNotDortmund} -DpasswordNotDortmund=${PasswordNotDortmund}' } } } diff --git a/xplan-core/xplan-core-commons/src/main/java/de/latlon/xplan/validator/web/shared/ValidationType.java b/xplan-core/xplan-core-commons/src/main/java/de/latlon/xplan/validator/web/shared/ValidationType.java index 78d31bd03a..75753597c8 100644 --- a/xplan-core/xplan-core-commons/src/main/java/de/latlon/xplan/validator/web/shared/ValidationType.java +++ b/xplan-core/xplan-core-commons/src/main/java/de/latlon/xplan/validator/web/shared/ValidationType.java @@ -28,7 +28,7 @@ package de.latlon.xplan.validator.web.shared; */ public enum ValidationType { - GEOMETRIC("geometric"), SYNTACTIC("syntactic"), SEMANTIC("semantic"); + SYNTACTIC("syntactic"), REFERENCES("references"), GEOMETRIC("geometric"), SEMANTIC("semantic"); private final String option; diff --git a/xplan-core/xplan-core-gwt/pom.xml b/xplan-core/xplan-core-gwt/pom.xml index 228fadfa26..3aa286acb0 100644 --- a/xplan-core/xplan-core-gwt/pom.xml +++ b/xplan-core/xplan-core-gwt/pom.xml @@ -97,16 +97,6 @@ <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> diff --git a/xplan-core/xplan-core-manager/pom.xml b/xplan-core/xplan-core-manager/pom.xml index ce014be75d..0a465dd965 100644 --- a/xplan-core/xplan-core-manager/pom.xml +++ b/xplan-core/xplan-core-manager/pom.xml @@ -136,11 +136,6 @@ <scope>provided</scope> </dependency> <!-- test --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> @@ -148,22 +143,17 @@ </dependency> <dependency> <groupId>org.xmlunit</groupId> - <artifactId>xmlunit-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.xmlunit</groupId> - <artifactId>xmlunit-matchers</artifactId> + <artifactId>xmlunit-assertj3</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>pl.pragmatists</groupId> - <artifactId>JUnitParams</artifactId> + <groupId>io.findify</groupId> + <artifactId>s3mock_2.13</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>io.findify</groupId> - <artifactId>s3mock_2.13</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> <dependency> @@ -176,7 +166,6 @@ <dependency> <groupId>de.latlon</groupId> <artifactId>deegree-layers-feature</artifactId> - <version>${deegree3.version}</version> <scope>test</scope> </dependency> <dependency> @@ -191,5 +180,4 @@ <scope>compile</scope> </dependency> </dependencies> - </project> \ No newline at end of file diff --git a/xplan-core/xplan-core-manager/src/main/java/de/latlon/xplan/manager/XPlanManager.java b/xplan-core/xplan-core-manager/src/main/java/de/latlon/xplan/manager/XPlanManager.java index 2e28b9f33e..7ce5dc2359 100644 --- a/xplan-core/xplan-core-manager/src/main/java/de/latlon/xplan/manager/XPlanManager.java +++ b/xplan-core/xplan-core-manager/src/main/java/de/latlon/xplan/manager/XPlanManager.java @@ -76,7 +76,6 @@ import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.feature.FeatureCollection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.security.access.prepost.PreAuthorize; /** * An instance of XPlanManager provides the service methods to manage instances of XPlan. @@ -161,7 +160,6 @@ public class XPlanManager { * should be created, <code>false</code> otherwise * @param planStatus the PlanStatus, may be <code>null</code> */ - @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public void importPlan(XPlanArchive archive, boolean force, boolean makeRasterConfig, PlanStatus planStatus) throws Exception { xPlanInsertManager.importPlan(archive, force, makeRasterConfig, null, planStatus); @@ -309,7 +307,6 @@ public class XPlanManager { * @return the {@link XPlanToEdit}, <code>null</code> if not found * @throws Exception */ - @PreAuthorize("hasRole('ROLE_XPLAN_EDITOR') or hasRole('ROLE_XPLAN_SUPERUSER')") public XPlanToEdit getXPlanToEdit(XPlan plan) throws Exception { InputStream originalPlan = null; try { @@ -337,7 +334,6 @@ public class XPlanManager { * never <code>null</code> * @throws Exception */ - @PreAuthorize("hasRole('ROLE_XPLAN_EDITOR') or hasRole('ROLE_XPLAN_SUPERUSER')") public void editPlan(XPlan oldXplan, XPlanToEdit xPlanToEdit, boolean makeRasterConfig, List<File> uploadedArtefacts) throws Exception { xPlanEditManager.editPlan(oldXplan, xPlanToEdit, makeRasterConfig, uploadedArtefacts); @@ -347,7 +343,6 @@ public class XPlanManager { * @param plan plan to delete * @throws Exception */ - @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public void delete(XPlan plan) throws Exception { String planId = plan.getId(); delete(planId); @@ -366,7 +361,6 @@ public class XPlanManager { * INSPIRE Download Service for PLU. * @param plan plan to transform and publish */ - @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public void publishPlu(XPlan plan) throws Exception { if (inspirePluPublisher == null) { LOG.warn("Transformation and publishing INSPIRE PLU datasets is not supported"); diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/XPlanManagerTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/XPlanManagerTest.java index ec56adaab6..bc529ef56f 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/XPlanManagerTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/XPlanManagerTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -22,8 +22,9 @@ package de.latlon.xplan.manager; import static org.apache.commons.io.IOUtils.close; import static org.apache.commons.io.IOUtils.copy; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -45,11 +46,10 @@ import de.latlon.xplanbox.core.raster.evaluation.RasterEvaluation; import de.latlon.xplanbox.core.raster.evaluation.XPlanRasterEvaluation; import de.latlon.xplanbox.core.raster.evaluation.XPlanRasterEvaluator; import org.deegree.commons.utils.Pair; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -61,22 +61,14 @@ import org.junit.rules.TemporaryFolder; // @ContextConfiguration(classes = {CoreTestContext.class, RasterStorageContext.class}) public class XPlanManagerTest { - private static final String CONFIGURED_CRS = "epsg:4326"; - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; private File managerWorkspaceDirectory; - private File wmsWorkspaceDirectory; - - private File dataDirectory; - - @Before - public void createWorkspaceFiles() throws IOException { - managerWorkspaceDirectory = tempFolder.newFolder("manager"); - wmsWorkspaceDirectory = tempFolder.newFolder("wms"); - dataDirectory = tempFolder.newFolder("data"); + @BeforeEach + void createWorkspaceFiles() throws IOException { + managerWorkspaceDirectory = newFolder(tempFolder, "manager"); File themesDir = new File(managerWorkspaceDirectory, "themes"); Files.createDirectory(themesDir.toPath()); File file = new File(themesDir, "bplanraster.xml"); @@ -84,34 +76,34 @@ public class XPlanManagerTest { // TODO build minimal temp workspace } - @After - public void deleteWorkspace() { + @AfterEach + void deleteWorkspace() { managerWorkspaceDirectory.delete(); } @Test - public void testEvaluateRasterdata() throws Exception { + void testEvaluateRasterdata() throws Exception { XPlanManager xPlanManager = createXPlanManager(); String pathToArchive = copyPlan(); List<RasterEvaluationResult> results = xPlanManager.evaluateRasterdata(pathToArchive); - assertThat(results.size(), is(1)); + assertThat(results).hasSize(1); RasterEvaluationResult result = results.get(0); - assertThat(result.isCrsSet(), is(false)); - assertThat(result.isConfiguredCrs(), is(false)); + assertFalse(result.isCrsSet()); + assertFalse(result.isConfiguredCrs()); } @Test - public void testDetermineLegislationStatus() throws Exception { + void determineLegislationStatus() throws Exception { XPlanManager xPlanManager = createXPlanManager(); String pathToArchive = copyPlan(); Pair<Rechtsstand, PlanStatus> legislationStatus = xPlanManager.determineRechtsstand(pathToArchive); - assertThat(legislationStatus.first.getCodeNumber(), is(3000)); - assertThat(legislationStatus.second, is(PlanStatus.FESTGESTELLT)); + assertEquals(3000, legislationStatus.first.getCodeNumber()); + assertEquals(PlanStatus.FESTGESTELLT, legislationStatus.second); } private XPlanManager createXPlanManager() throws Exception { @@ -144,4 +136,13 @@ public class XPlanManagerTest { } } + private static File newFolder(File root, String... subDirs) throws IOException { + String subFolder = String.join("/", subDirs); + File result = new File(root, subFolder); + if (!result.mkdirs()) { + throw new IOException("Couldn't create folders " + root); + } + return result; + } + } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/configuration/ManagerConfigurationTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/configuration/ManagerConfigurationTest.java index cc8ba4e22a..9ac736874e 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/configuration/ManagerConfigurationTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/configuration/ManagerConfigurationTest.java @@ -29,9 +29,10 @@ import static de.latlon.xplan.manager.configuration.ManagerConfiguration.RASTER_ import static de.latlon.xplan.manager.configuration.ManagerConfiguration.WORKSPACE_RELOAD_PASSWORD; import static de.latlon.xplan.manager.configuration.ManagerConfiguration.WORKSPACE_RELOAD_URLS; import static de.latlon.xplan.manager.configuration.ManagerConfiguration.WORKSPACE_RELOAD_USER; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -43,85 +44,89 @@ import de.latlon.xplan.commons.configuration.SemanticConformityLinkConfiguration import de.latlon.xplan.commons.configuration.SortConfiguration; import de.latlon.xplan.manager.web.shared.ConfigurationException; import de.latlon.xplan.manager.workspace.WorkspaceReloaderConfiguration; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ */ -public class ManagerConfigurationTest { +class ManagerConfigurationTest { @Test - public void testGetSortConfiguration() throws Exception { + void testGetSortConfiguration() throws Exception { ManagerConfiguration managerConfiguration = new ManagerConfiguration(mockPropertiesLoader()); SortConfiguration sortConfiguration = managerConfiguration.getSortConfiguration(); - assertThat(sortConfiguration.retrieveFeatureType(BP_Plan, XPLAN_50), is("BP_Plan")); - assertThat(sortConfiguration.retrievePropertyName(BP_Plan, XPLAN_50), is("rechtsverordnungsDatum")); + assertEquals("BP_Plan", sortConfiguration.retrieveFeatureType(BP_Plan, XPLAN_50)); + assertEquals("rechtsverordnungsDatum", sortConfiguration.retrievePropertyName(BP_Plan, XPLAN_50)); } @Test - public void testGetSemanticConformityLinkConfiguration() throws Exception { + void testGetSemanticConformityLinkConfiguration() throws Exception { ManagerConfiguration managerConfiguration = new ManagerConfiguration(mockPropertiesLoader()); SemanticConformityLinkConfiguration semanticConformityLinkConfiguration = managerConfiguration .getSemanticConformityLinkConfiguration(); - assertThat(semanticConformityLinkConfiguration.retrieveLink(XPLAN_50), is("http://link.de/to.pdf")); - assertThat(semanticConformityLinkConfiguration.retrieveLink(XPLAN_51), nullValue()); + assertEquals("http://link.de/to.pdf", semanticConformityLinkConfiguration.retrieveLink(XPLAN_50)); + assertNull(semanticConformityLinkConfiguration.retrieveLink(XPLAN_51)); } @Test - public void testGetWorkspaceReloaderConfiguration() throws Exception { + void testGetWorkspaceReloaderConfiguration() throws Exception { ManagerConfiguration managerConfiguration = new ManagerConfiguration(mockPropertiesLoader()); WorkspaceReloaderConfiguration workspaceReloaderConfiguration = managerConfiguration .getWorkspaceReloaderConfiguration(); - assertThat(workspaceReloaderConfiguration.getUrls().size(), is(2)); - assertThat(workspaceReloaderConfiguration.getUrls().get(0), is("url1")); - assertThat(workspaceReloaderConfiguration.getUrls().get(1), is("url2")); - assertThat(workspaceReloaderConfiguration.getUser(), is("user")); - assertThat(workspaceReloaderConfiguration.getPassword(), is("password")); + assertThat(workspaceReloaderConfiguration.getUrls()).containsExactly("url1", "url2"); + assertEquals("user", workspaceReloaderConfiguration.getUser()); + assertEquals("password", workspaceReloaderConfiguration.getPassword()); } @Test - public void testDefaultScaleDenominators() throws Exception { + void defaultScaleDenominators() throws Exception { ManagerConfiguration managerConfiguration = new ManagerConfiguration(mockPropertiesLoader()); - assertThat(managerConfiguration.getRasterLayerMinScaleDenominator(), is(Double.NaN)); - assertThat(managerConfiguration.getRasterLayerMaxScaleDenominator(), is(Double.NaN)); + assertEquals(Double.NaN, managerConfiguration.getRasterLayerMinScaleDenominator()); + assertEquals(Double.NaN, managerConfiguration.getRasterLayerMaxScaleDenominator()); } @Test - public void testScaleDenominators() throws Exception { + void scaleDenominators() throws Exception { double min = 5; double max = 1000; ManagerConfiguration managerConfiguration = new ManagerConfiguration(mockPropertiesLoader(min, max)); - assertThat(managerConfiguration.getRasterLayerMinScaleDenominator(), is(min)); - assertThat(managerConfiguration.getRasterLayerMaxScaleDenominator(), is(max)); + assertEquals(min, managerConfiguration.getRasterLayerMinScaleDenominator()); + assertEquals(max, managerConfiguration.getRasterLayerMaxScaleDenominator()); } - @Test(expected = IllegalArgumentException.class) - public void testScaleDenominators_maxLessMin() throws Exception { - double min = 5; - double max = 1; - new ManagerConfiguration(mockPropertiesLoader(min, max)); + @Test + void scaleDenominatorsMaxLessMin() throws Exception { + assertThrows(IllegalArgumentException.class, () -> { + double min = 5; + double max = 1; + new ManagerConfiguration(mockPropertiesLoader(min, max)); + }); } - @Test(expected = IllegalArgumentException.class) - public void testScaleDenominators_maxNegative() throws Exception { - double min = 5; - double max = -1; - new ManagerConfiguration(mockPropertiesLoader(min, max)); + @Test + void scaleDenominatorsMaxNegative() throws Exception { + assertThrows(IllegalArgumentException.class, () -> { + double min = 5; + double max = -1; + new ManagerConfiguration(mockPropertiesLoader(min, max)); + }); } - @Test(expected = IllegalArgumentException.class) - public void testScaleDenominators_minNegative() throws Exception { - double min = -5; - double max = 1; - new ManagerConfiguration(mockPropertiesLoader(min, max)); + @Test + void scaleDenominatorsMinNegative() throws Exception { + assertThrows(IllegalArgumentException.class, () -> { + double min = -5; + double max = 1; + new ManagerConfiguration(mockPropertiesLoader(min, max)); + }); } private PropertiesLoader mockPropertiesLoader() throws ConfigurationException { diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/XPlanDocumentManagerTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/XPlanDocumentManagerTest.java index 58b0bd3836..a5c153fb07 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/XPlanDocumentManagerTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/XPlanDocumentManagerTest.java @@ -29,7 +29,7 @@ import de.latlon.xplan.manager.edit.EditedArtefact; import de.latlon.xplan.manager.edit.EditedArtefacts; import de.latlon.xplan.manager.storage.StorageEvent; import org.deegree.feature.FeatureCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEventPublisher; import java.io.InputStream; @@ -51,10 +51,10 @@ import static org.mockito.Mockito.when; * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> * @since 7.0 */ -public class XPlanDocumentManagerTest { +class XPlanDocumentManagerTest { @Test - public void testImportDocuments() throws Exception { + void testImportDocuments() throws Exception { DocumentStorage storage = mock(DocumentStorage.class); ApplicationEventPublisher applicationEventPublisher = mock(ApplicationEventPublisher.class); XPlanDocumentManager xPlanDocumentManager = new XPlanDocumentManager(storage, applicationEventPublisher); @@ -76,7 +76,7 @@ public class XPlanDocumentManagerTest { } @Test - public void testUpdateDocuments() throws Exception { + void testUpdateDocuments() throws Exception { DocumentStorage storage = mock(DocumentStorage.class); ApplicationEventPublisher applicationEventPublisher = mock(ApplicationEventPublisher.class); XPlanDocumentManager xPlanDocumentManager = new XPlanDocumentManager(storage, applicationEventPublisher); diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/s3/S3DocumentStorageIT.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/s3/S3DocumentStorageIT.java index 46cc08216a..f9188d80d9 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/s3/S3DocumentStorageIT.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/document/s3/S3DocumentStorageIT.java @@ -8,20 +8,19 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package de.latlon.xplan.manager.document.s3; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -30,19 +29,20 @@ import java.io.InputStream; import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.commons.s3.StorageException; import de.latlon.xplan.manager.document.config.AmazonS3DocumentStorageContext; import de.latlon.xplan.manager.storage.StorageEvent; import de.latlon.xplan.manager.storage.s3.config.AmazonS3TestContext; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; /** * ATTENTION: Executing this test class can run up the bill for the AWS account @@ -55,17 +55,17 @@ import org.springframework.test.context.junit4.SpringRunner; * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> * @author <a href="mailto:friebe@lat-lon.de">Torsten Friebe</a> */ -@RunWith(SpringRunner.class) @ContextConfiguration(classes = { AmazonS3DocumentStorageContext.class, AmazonS3TestContext.class }) @ActiveProfiles({ "mock" }) @TestPropertySource("classpath:s3Mock.properties") -public class S3DocumentStorageIT { +@ExtendWith(SpringExtension.class) +class S3DocumentStorageIT { @Autowired private S3DocumentStorage s3DocumentStorage; @Test - public void testImportDocuments() throws IOException, StorageException { + void testImportDocuments() throws IOException, StorageException { InputStream inputStream = getClass().getResourceAsStream("/testdata/xplan60/StErhVO_Hamm_60.zip"); XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); XPlanArchive archive = archiveCreator.createXPlanArchiveFromZip("StErhVO_Hamm_60.zip", inputStream); @@ -74,8 +74,7 @@ public class S3DocumentStorageIT { List<String> keys = s3DocumentStorage.importDocuments(1, archive, Collections.singletonList("StErhVO_Hamm.pdf"), storageEvent); - assertThat(keys.size(), is(1)); - assertThat(keys.get(0), is("1_StErhVO_Hamm.pdf")); + assertThat(keys).containsExactly("1_StErhVO_Hamm.pdf"); verify(storageEvent).addInsertedKey("1_StErhVO_Hamm.pdf"); } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/ExternalReferenceUtilsTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/ExternalReferenceUtilsTest.java index b2761d2aa1..5bc361fc7e 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/ExternalReferenceUtilsTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/ExternalReferenceUtilsTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -26,15 +26,15 @@ import de.latlon.xplan.commons.reference.ExternalReferenceInfoBuilder; import de.latlon.xplan.manager.web.shared.edit.RasterBasis; import de.latlon.xplan.manager.web.shared.edit.RasterReference; import de.latlon.xplan.manager.web.shared.edit.XPlanToEdit; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Test; + +import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Predicate; import java.util.stream.Collectors; import static de.latlon.xplan.manager.edit.ArtefactType.NONRASTER; @@ -45,18 +45,16 @@ import static de.latlon.xplan.manager.edit.ExternalReferenceUtils.collectEditedA import static de.latlon.xplan.manager.edit.ExternalReferenceUtils.createExternalRefAddedOrUpdated; import static de.latlon.xplan.manager.web.shared.edit.RasterReferenceType.LEGEND; import static de.latlon.xplan.manager.web.shared.edit.RasterReferenceType.SCAN; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ */ -public class ExternalReferenceUtilsTest { +class ExternalReferenceUtilsTest { @Test - public void testCreateExternalRefAddedOrUpdated_ExternalReferenceInfo() { + void createExternalRefAddedOrUpdatedExternalReferenceInfo() { ExternalReferenceInfo externalRefsOriginalPlan = createExternalReferenceInfo("A.tif", "X.pdf", "C.png", "D.png"); List<File> uploadedArtefacts = createUploadedFileList("A.tif", "B.jpg", "C.png"); @@ -65,13 +63,13 @@ public class ExternalReferenceUtilsTest { uploadedArtefacts); List<ExternalReference> rasterPlanBaseAndUpdateScans = externalReferenceInfo.getRasterPlanBaseAndUpdateScans(); - assertThat(rasterPlanBaseAndUpdateScans.size(), is(2)); - assertThat(rasterPlanBaseAndUpdateScans, hasExternalReference("A.tif")); - assertThat(rasterPlanBaseAndUpdateScans, hasExternalReference("C.png")); + assertThat(rasterPlanBaseAndUpdateScans).hasSize(2); + assertThat(rasterPlanBaseAndUpdateScans).satisfies(hasExternalReference("A.tif")); + assertThat(rasterPlanBaseAndUpdateScans).satisfies(hasExternalReference("C.png")); } @Test - public void testCreateExternalRefAddedOrUpdated_XPlanToEdit() { + void createExternalRefAddedOrUpdatedXPlanToEdit() { XPlanToEdit planToEdit = new XPlanToEdit(); RasterBasis rasterBasis = new RasterBasis(); RasterReference rasterReference1 = new RasterReference("0", "G.tif", null, LEGEND, null, null, null, null, null, @@ -87,12 +85,12 @@ public class ExternalReferenceUtilsTest { ExternalReferenceInfo externalReferenceInfo = createExternalRefAddedOrUpdated(planToEdit, uploadedArtefacts); List<ExternalReference> rasterPlanBaseAndUpdateScans = externalReferenceInfo.getRasterPlanBaseAndUpdateScans(); - assertThat(rasterPlanBaseAndUpdateScans.size(), is(1)); - assertThat(rasterPlanBaseAndUpdateScans, hasExternalReference("A.tif")); + assertThat(rasterPlanBaseAndUpdateScans).hasSize(1); + assertThat(rasterPlanBaseAndUpdateScans).satisfies(hasExternalReference("A.tif")); } @Test - public void testCollectEditedArtefacts() { + void testCollectEditedArtefacts() { List<String> originalFileNames = Arrays.asList("A.tif", "D.png", "D.pgw", "F.png", "F.pgw"); List<String> uploadedFileNames = Arrays.asList("A.tif", "X.pdf", "Z.pdf", "B.png", "C.png", "C.pgw"); ExternalReferenceInfo externalRefsModified = new ExternalReferenceInfoBuilder() @@ -114,20 +112,16 @@ public class ExternalReferenceUtilsTest { originalFileNames, uploadedFileNames); List<String> removedRaster = editedArtefacts.getFileNames(REMOVED, RASTER); - assertThat(removedRaster.size(), is(2)); - assertThat(removedRaster, hasItems("F.png", "F.pgw")); + assertThat(removedRaster).containsExactly("F.png", "F.pgw"); List<String> addedRaster = editedArtefacts.getFileNames(ADDED, RASTER); - assertThat(addedRaster.size(), is(2)); - assertThat(addedRaster, hasItems("C.png", "C.pgw")); + assertThat(addedRaster).containsExactly("C.png", "C.pgw"); List<String> removedNonRaster = editedArtefacts.getFileNames(REMOVED, NONRASTER); - assertThat(removedNonRaster.size(), is(1)); - assertThat(removedNonRaster, hasItems("Y.pdf")); + assertThat(removedNonRaster).containsExactly("Y.pdf"); List<String> addedNonRaster = editedArtefacts.getFileNames(ADDED, NONRASTER); - assertThat(addedNonRaster.size(), is(1)); - assertThat(addedNonRaster, hasItems("Z.pdf")); + assertThat(addedNonRaster).containsExactly("Z.pdf"); } private ExternalReferenceInfo createExternalReferenceInfo(String rasterPlanBaseScan, String nonRasterReference, @@ -150,10 +144,11 @@ public class ExternalReferenceUtilsTest { return uploadedArtifacts; } - private Matcher<List<ExternalReference>> hasExternalReference(final String referenceUrl) { - return new TypeSafeMatcher<List<ExternalReference>>() { + private Condition<? super List<? extends ExternalReference>> hasExternalReference(final String referenceUrl) { + Predicate<? super List<? extends ExternalReference>> predicate = new Predicate<>() { + @Override - protected boolean matchesSafely(List<ExternalReference> externalReferences) { + public boolean test(List<? extends ExternalReference> externalReferences) { for (ExternalReference externalReference : externalReferences) { if (referenceUrl.equals(externalReference.getReferenzUrl())) return true; @@ -161,14 +156,11 @@ public class ExternalReferenceUtilsTest { return false; } - @Override - public void describeTo(Description description) { - description.appendText( - "ExternalReference list shall contain at least one ExternalReference with referenceURL "); - description.appendValue(referenceUrl); - } - }; + + return new Condition<>(predicate, + "ExternalReference list shall contain at least one ExternalReference with referenceURL %s", + referenceUrl); } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanManipulatorTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanManipulatorTest.java index 43fe6421d3..a9a2e79f6d 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanManipulatorTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanManipulatorTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -40,18 +40,13 @@ import static de.latlon.xplan.manager.web.shared.edit.ReferenceType.GRUENORDNUNG import static de.latlon.xplan.manager.web.shared.edit.ReferenceType.RECHTSPLAN; import static de.latlon.xplan.manager.web.shared.edit.TextRechtscharacterType.BP_HINWEIS; import static de.latlon.xplan.manager.web.shared.edit.TextRechtscharacterType.BP_VERMERK; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.xmlunit.matchers.EvaluateXPathMatcher.hasXPath; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamReader; import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Iterator; @@ -59,6 +54,23 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamReader; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.Assertions; +import org.deegree.commons.tom.gml.property.Property; +import org.deegree.commons.tom.primitive.PrimitiveValue; +import org.deegree.feature.Feature; +import org.deegree.feature.FeatureCollection; +import org.deegree.feature.types.AppSchema; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.xmlunit.assertj3.XmlAssert; +import org.xmlunit.builder.Input; + import de.latlon.xplan.commons.XPlanSchemas; import de.latlon.xplan.commons.XPlanVersion; import de.latlon.xplan.commons.archive.XPlanArchive; @@ -73,38 +85,21 @@ import de.latlon.xplan.manager.web.shared.edit.RasterReference; import de.latlon.xplan.manager.web.shared.edit.Reference; import de.latlon.xplan.manager.web.shared.edit.Text; import de.latlon.xplan.manager.web.shared.edit.XPlanToEdit; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.deegree.commons.tom.gml.property.Property; -import org.deegree.commons.tom.primitive.PrimitiveValue; -import org.deegree.feature.Feature; -import org.deegree.feature.FeatureCollection; -import org.deegree.feature.types.AppSchema; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.xmlunit.builder.Input; -import org.xmlunit.matchers.HasXPathMatcher; -import org.xmlunit.matchers.ValidationMatcher; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ */ -@RunWith(JUnitParamsRunner.class) -public class XPlanManipulatorTest { +class XPlanManipulatorTest { private final XPlanToEditFactory factory = new XPlanToEditFactory(); private final XPlanManipulator planManipulator = new XPlanManipulator(); - @Test - @Parameters({ "xplan51/BP2070.gml, XPLAN_51", "xplan50/BP2070.gml, XPLAN_50", - "xplan41/Eidelstedt_4_V4-Blankenese.gml, XPLAN_41" }) - public void testModifyXPlan(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan51/BP2070.gml,XPLAN_51", "xplan50/BP2070.gml,XPLAN_50", + "xplan41/Eidelstedt_4_V4-Blankenese.gml,XPLAN_41" }) + void testModifyXPlan(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -122,24 +117,30 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "name", planName)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "beschreibung", description)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "technHerstellDatum", creationDate)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "untergangsDatum", lossDate)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "rechtsverordnungsDatum", regulationDate)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "rechtsverordnungsDatum", regulationDate)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "rechtsstand", legislationStatusCode)); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "verfahren", methodCode)); - assertThat(featureCollection, hasNoProperty(version, "BP_Plan", "sonstPlanArt")); - assertThat(featureCollection, hasProperty(version, "BP_Plan", "planArt", planTypeCode)); + FeatureCollectionAssert.assertThat(featureCollection).hasProperty(version, "BP_Plan", "name", planName); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "beschreibung", description); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "technHerstellDatum", creationDate); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "untergangsDatum", lossDate); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "rechtsverordnungsDatum", regulationDate); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "rechtsverordnungsDatum", regulationDate); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_Plan", "rechtsstand", legislationStatusCode); + FeatureCollectionAssert.assertThat(featureCollection).hasProperty(version, "BP_Plan", "verfahren", methodCode); + FeatureCollectionAssert.assertThat(featureCollection).hasNoProperty(version, "BP_Plan", "sonstPlanArt"); + FeatureCollectionAssert.assertThat(featureCollection).hasProperty(version, "BP_Plan", "planArt", planTypeCode); assertThatPlanIsSchemaValid(featureCollection, version); } - @Test - @Parameters({ "xplan51/BP2070.gml, XPLAN_51", "xplan50/BP2070.gml, XPLAN_50", - "xplan41/Eidelstedt_4_V4-Blankenese.gml, XPLAN_41" }) - public void testModifyXPlan_Aenderungen(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan51/BP2070.gml,XPLAN_51", "xplan50/BP2070.gml,XPLAN_50", + "xplan41/Eidelstedt_4_V4-Blankenese.gml,XPLAN_41" }) + void modifyXPlanAenderungen(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -151,15 +152,18 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "wurdeGeaendertVon", 1)); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "aendert", 2)); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "BP_Plan", "wurdeGeaendertVon", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "BP_Plan", "wurdeGeaendertVon", 1); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "aendert", 2); assertThatPlanIsSchemaValid(featureCollection, version); } - @Test - @Parameters({ "xplan51/BP2070.gml, XPLAN_51", "xplan50/BP2070.gml, XPLAN_50" }) - public void testModifyXPlan_XPlan5X_Texte(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan51/BP2070.gml,XPLAN_51", "xplan50/BP2070.gml,XPLAN_50" }) + void modifyXPlanXPlan5XTexte(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -172,14 +176,14 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "texte", 2)); - assertThat(featureCollection, hasFeatureCount(version, "BP_TextAbschnitt", 2)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "texte", 2); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(version, "BP_TextAbschnitt", 2); assertThatPlanIsSchemaValid(featureCollection, version); } @Test - public void testModifyXPlan_XPlan51_ModifyTextKeepFeatureId() throws Exception { + void modifyXPlanXPlan51ModifyTextKeepFeatureId() throws Exception { XPlanVersion version = XPLAN_51; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan51/V4_1_ID_103.gml"); @@ -192,14 +196,15 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "texte", 1)); - assertThat(featureCollection, hasFeatureWithId(version, "BP_TextAbschnitt", featureIdUnderTest)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "texte", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(version, "BP_TextAbschnitt", featureIdUnderTest); assertThatPlanIsSchemaValid(featureCollection, version); } @Test - public void testModifyXPlan_XPlan41_Texte() throws Exception { + void modifyXPlanXPlan41Texte() throws Exception { XPlanVersion version = XPLAN_41; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan41/V4_1_ID_103.gml"); @@ -210,15 +215,15 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "texte", 2)); - assertThat(featureCollection, hasFeatureCount(version, "XP_TextAbschnitt", 2)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "texte", 2); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(version, "XP_TextAbschnitt", 2); assertThatPlanIsSchemaValid(featureCollection, version); } - @Test - @Parameters({ "xplan51/BP2070.gml, XPLAN_51", "xplan50/BP2070.gml, XPLAN_50" }) - public void testModifyXPlan_XPlan50_TextWerte(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan51/BP2070.gml,XPLAN_51", "xplan50/BP2070.gml,XPLAN_50" }) + void modifyXPlanXPlan50TextWerte(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -229,21 +234,24 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "texte", 1)); - assertThat(featureCollection, hasFeatureCount(version, "BP_TextAbschnitt", 1)); - assertThat(featureCollection, hasProperty(version, "BP_TextAbschnitt", "schluessel", text.getKey())); - assertThat(featureCollection, - hasProperty(version, "BP_TextAbschnitt", "gesetzlicheGrundlage", text.getBasis())); - assertThat(featureCollection, hasProperty(version, "BP_TextAbschnitt", "text", text.getText())); - assertThat(featureCollection, - hasProperty(version, "BP_TextAbschnitt", "rechtscharakter", text.getRechtscharakter().getCode())); - assertThat(featureCollection, hasPropertyCount(version, "BP_TextAbschnitt", "refText", 1)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "texte", 1); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(version, "BP_TextAbschnitt", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_TextAbschnitt", "schluessel", text.getKey()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_TextAbschnitt", "gesetzlicheGrundlage", text.getBasis()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_TextAbschnitt", "text", text.getText()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "BP_TextAbschnitt", "rechtscharakter", text.getRechtscharakter().getCode()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "BP_TextAbschnitt", "refText", 1); assertThatPlanIsSchemaValid(featureCollection, version); } @Test - public void testModifyXPlan_XPlan41_TextWerte() throws Exception { + void modifyXPlanXPlan41TextWerte() throws Exception { XPlanVersion version = XPLAN_41; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan41/V4_1_ID_103.gml"); @@ -254,20 +262,23 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "texte", 1)); - assertThat(featureCollection, hasFeatureCount(version, "XP_TextAbschnitt", 1)); - assertThat(featureCollection, hasProperty(version, "XP_TextAbschnitt", "schluessel", text.getKey())); - assertThat(featureCollection, - hasProperty(version, "XP_TextAbschnitt", "gesetzlicheGrundlage", text.getBasis())); - assertThat(featureCollection, hasProperty(version, "XP_TextAbschnitt", "text", text.getText())); - assertThat(featureCollection, hasPropertyCount(version, "XP_TextAbschnitt", "refText", 1)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "texte", 1); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(version, "XP_TextAbschnitt", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "XP_TextAbschnitt", "schluessel", text.getKey()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "XP_TextAbschnitt", "gesetzlicheGrundlage", text.getBasis()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(version, "XP_TextAbschnitt", "text", text.getText()); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "XP_TextAbschnitt", "refText", 1); assertThatPlanIsSchemaValid(featureCollection, version); } - @Test - @Parameters({ "xplan51/BP2070.gml, XPLAN_51", "xplan50/BP2070.gml, XPLAN_50" }) - public void testModifyXPlan_XPlan50_Referenzen(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan51/BP2070.gml,XPLAN_51", "xplan50/BP2070.gml,XPLAN_50" }) + void modifyXPlanXPlan50Referenzen(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -279,13 +290,14 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "externeReferenz", 3)); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "BP_Plan", "externeReferenz", 3); assertThatPlanIsSchemaValid(featureCollection, version); } @Test - public void testModifyXPlan_XPlan41_Referenzen() throws Exception { + void modifyXPlanXPlan41Referenzen() throws Exception { XPlanVersion version = XPLAN_41; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan41/Eidelstedt_4_V4-Blankenese.gml"); @@ -298,15 +310,16 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "refBegruendung", 1)); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "refRechtsplan", 1)); - assertThat(featureCollection, hasPropertyCount(version, "BP_Plan", "refGruenordnungsplan", 1)); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "refBegruendung", 1); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(version, "BP_Plan", "refRechtsplan", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(version, "BP_Plan", "refGruenordnungsplan", 1); assertThatPlanIsSchemaValid(featureCollection, version); } @Test - public void testModifyXPlan_RasterReferences() throws Exception { + void modifyXPlanRasterReferences() throws Exception { XPlanVersion version = XPLAN_50; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan50/BPlan004_5-0.zip"); @@ -325,46 +338,56 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("1")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_Rasterdarstellung)", is("1")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL", - is(rasterBasisReference.getGeoReference())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefMimeType", - is(rasterBasisReference.getGeorefMimeType().getCode())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:art", - is(rasterBasisReference.getArt().getCode())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:informationssystemURL", - is(rasterBasisReference.getInformationssystemURL())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzName", - is(rasterBasisReference.getReferenzName())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL", - is(rasterBasisReference.getReference())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzMimeType", - is(rasterBasisReference.getReferenzMimeType().getCode())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:beschreibung", - is(rasterBasisReference.getBeschreibung())) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:datum", is("2018-03-01")) - .withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_Rasterdarstellung)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL") + .isEqualTo(rasterBasisReference.getGeoReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefMimeType") + .isEqualTo(rasterBasisReference.getGeorefMimeType().getCode()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:art") + .isEqualTo(rasterBasisReference.getArt().getCode()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:informationssystemURL") + .isEqualTo(rasterBasisReference.getInformationssystemURL()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzName") + .isEqualTo(rasterBasisReference.getReferenzName()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL") + .isEqualTo(rasterBasisReference.getReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzMimeType") + .isEqualTo(rasterBasisReference.getReferenzMimeType().getCode()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:beschreibung") + .isEqualTo(rasterBasisReference.getBeschreibung()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:datum") + .isEqualTo("2018-03-01"); assertThatPlanIsSchemaValid(exportedPlan, version); } @Test - public void testModifyXPlan_XPlan50_delete_RasterReferences() throws Exception { + void modifyXPlanXPlan50DeleteRasterReferences() throws Exception { XPlanVersion xPlanVersion = XPLAN_50; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(xPlanVersion); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan50/BPlan002_5-0.zip"); @@ -376,15 +399,19 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, xPlanVersion); - assertThat(exportedPlan, hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("0")) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_Rasterdarstellung)", is("0")).withNamespaceContext(nsContext(xPlanVersion))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:XP_Rasterdarstellung)") + .isEqualTo("0"); assertThatPlanIsSchemaValid(exportedPlan, xPlanVersion); } @Test - public void testModifyXPlan_XPlan50_new_RasterReferences() throws Exception { + void modifyXPlanXPlan50NewRasterReferences() throws Exception { XPlanVersion xPlanVersion = XPLAN_50; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(xPlanVersion); FeatureCollection featureCollection = readXPlanGml(xPlanVersion, "xplan50/BP2070.gml"); @@ -406,50 +433,58 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, xPlanVersion); assertThatPlanIsSchemaValid(exportedPlan, xPlanVersion); - assertThat(exportedPlan, hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("1")) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_Rasterdarstellung)", is("1")).withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL", - is(scan.getReference())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL", - is(scan.getGeoReference())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - not(HasXPathMatcher - .hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:georefMimeType") - .withNamespaceContext(nsContext(xPlanVersion)))); - assertThat(exportedPlan, hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:art", - is(legend.getArt().getCode())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:informationssystemURL", - is(legend.getInformationssystemURL())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzName", - is(legend.getReferenzName())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzURL", - is(legend.getReference())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzMimeType", - is(legend.getReferenzMimeType().getCode())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:beschreibung", - is(legend.getBeschreibung())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:datum", is("2018-03-01")) - .withNamespaceContext(nsContext(xPlanVersion))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:XP_Rasterdarstellung)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL") + .isEqualTo(scan.getReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL") + .isEqualTo(scan.getGeoReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:georefMimeType") + .isEmpty(); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:art") + .isEqualTo(legend.getArt().getCode()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:informationssystemURL") + .isEqualTo(legend.getInformationssystemURL()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzName") + .isEqualTo(legend.getReferenzName()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzURL") + .isEqualTo(legend.getReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:referenzMimeType") + .isEqualTo(legend.getReferenzMimeType().getCode()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:beschreibung") + .isEqualTo(legend.getBeschreibung()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_Rasterdarstellung/xp:refLegende/xp:XP_ExterneReferenz/xp:datum") + .isEqualTo("2018-03-01"); } @Test - public void testModifyXPlan_XPlan41_RasterReferences() throws Exception { + void modifyXPlanXPlan41RasterReferences() throws Exception { XPlanVersion xPlanVersion = XPLAN_41; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(xPlanVersion); FeatureCollection featureCollection = readXPlanGml(xPlanVersion, "xplan41/V4_1_ID_103.gml"); @@ -467,22 +502,28 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, xPlanVersion); - assertThat(exportedPlan, hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("1")) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_RasterplanBasis)", is("1")).withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, hasXPath("//xp:XP_RasterplanBasis/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL", - is(rasterBasisReference.getGeoReference())) - .withNamespaceContext(nsContext(xPlanVersion))); - assertThat(exportedPlan, hasXPath("//xp:XP_RasterplanBasis/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL", - is(rasterBasisReference.getReference())) - .withNamespaceContext(nsContext(xPlanVersion))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("count(//xp:XP_RasterplanBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_RasterplanBasis/xp:refScan/xp:XP_ExterneReferenz/xp:georefURL") + .isEqualTo(rasterBasisReference.getGeoReference()); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(xPlanVersion)) + .valueByXPath("//xp:XP_RasterplanBasis/xp:refScan/xp:XP_ExterneReferenz/xp:referenzURL") + .isEqualTo(rasterBasisReference.getReference()); assertThatPlanIsSchemaValid(exportedPlan, xPlanVersion); } - @Test - @Parameters({ "xplan50/BP2070.gml, XPLAN_50", "xplan41/Eidelstedt_4_V4-Blankenese.gml, XPLAN_41" }) - public void testModifyXPlan_XPlan41_NullAndEmptyValue(String planResource, String xplanVersion) throws Exception { + @ParameterizedTest + @CsvSource({ "xplan50/BP2070.gml,XPLAN_50", "xplan41/Eidelstedt_4_V4-Blankenese.gml,XPLAN_41" }) + void modifyXPlanXPlan41NullAndEmptyValue(String planResource, String xplanVersion) throws Exception { XPlanVersion version = XPlanVersion.valueOf(xplanVersion); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, planResource); @@ -492,16 +533,16 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); - assertThat(featureCollection, hasNoProperty(version, "BP_Plan", "beschreibung")); - assertThat(featureCollection, hasNoProperty(version, "BP_Plan", "untergangsDatum")); - assertThat(featureCollection, hasNoProperty(version, "BP_Plan", "verfahren")); + FeatureCollectionAssert.assertThat(featureCollection).hasNoProperty(version, "BP_Plan", "beschreibung"); + FeatureCollectionAssert.assertThat(featureCollection).hasNoProperty(version, "BP_Plan", "untergangsDatum"); + FeatureCollectionAssert.assertThat(featureCollection).hasNoProperty(version, "BP_Plan", "verfahren"); assertThatPlanIsSchemaValid(featureCollection, version); } // #3288 @Test - public void testModifyXPlan_XPlan41_ValidReferences() throws Exception { + void modifyXPlanXPlan41ValidReferences() throws Exception { AppSchema schema = XPlanSchemas.getInstance().getAppSchema(XPLAN_41); FeatureCollection featureCollection = readXPlanGml(XPLAN_41, "xplan41/V4_1_ID_103_references.gml"); @@ -514,7 +555,7 @@ public class XPlanManipulatorTest { } @Test - public void testModifyXPlan_XPlan41_TextValues_MultipleReferences_Modify() throws Exception { + void modifyXPlanXPlan41TextValuesMultipleReferencesModify() throws Exception { AppSchema schema = XPlanSchemas.getInstance().getAppSchema(XPLAN_41); FeatureCollection featureCollection = readXPlanGml(XPLAN_41, "xplan41/V4_1_ID_103_texts.gml"); @@ -524,27 +565,31 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, XPLAN_41, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 2)); - assertThat(featureCollection, - hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, - hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); - assertThat(featureCollection, hasPropertyCount(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", 1)); - assertThat(featureCollection, hasHrefAttribue(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", - "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 2)); - assertThat(featureCollection, hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "newText1")); - assertThat(featureCollection, hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "newText2")); - assertThat(featureCollection, - hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, - hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 2); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", + "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 2); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "newText1"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "newText2"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); assertThatPlanIsSchemaValid(featureCollection, XPLAN_41); } @Test - public void testModifyXPlan_XPlan41_TextValues_MultipleReferences_Remove() throws Exception { + void modifyXPlanXPlan41TextValuesMultipleReferencesRemove() throws Exception { AppSchema schema = XPlanSchemas.getInstance().getAppSchema(XPLAN_41); FeatureCollection featureCollection = readXPlanGml(XPLAN_41, "xplan41/V4_1_ID_103_texts.gml"); @@ -553,20 +598,21 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, XPLAN_41, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 1)); - assertThat(featureCollection, - hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); - assertThat(featureCollection, hasNoProperty(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt")); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasNoProperty(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt"); - assertThat(featureCollection, hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 1)); - assertThat(featureCollection, - hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); assertThatPlanIsSchemaValid(featureCollection, XPLAN_41); } @Test - public void testModifyXPlan_XPlan41_TextValues_MultipleReferences_New() throws Exception { + void modifyXPlanXPlan41TextValuesMultipleReferencesNew() throws Exception { AppSchema schema = XPlanSchemas.getInstance().getAppSchema(XPLAN_41); FeatureCollection featureCollection = readXPlanGml(XPLAN_41, "xplan41/V4_1_ID_103_texts.gml"); @@ -576,28 +622,32 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, XPLAN_41, BP_Plan, schema); - assertThat(featureCollection, hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 3)); - assertThat(featureCollection, - hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, - hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); - assertThat(featureCollection, hasPropertyCount(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", 1)); - assertThat(featureCollection, hasHrefAttribue(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", - "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 3)); - assertThat(featureCollection, hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "Wiese")); - assertThat(featureCollection, hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "Weide")); - assertThat(featureCollection, hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "text")); - assertThat(featureCollection, - hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b")); - assertThat(featureCollection, - hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c")); + FeatureCollectionAssert.assertThat(featureCollection).hasPropertyCount(XPLAN_41, "BP_Plan", "texte", 3); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_Plan", "texte", "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasPropertyCount(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", 1); + FeatureCollectionAssert.assertThat(featureCollection) + .hasHrefAttribue(XPLAN_41, "BP_BaugebietsTeilFlaeche", "refTextInhalt", + "#FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection).hasFeatureCount(XPLAN_41, "XP_TextAbschnitt", 3); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "Wiese"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "Weide"); + FeatureCollectionAssert.assertThat(featureCollection).hasProperty(XPLAN_41, "XP_TextAbschnitt", "text", "text"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6b"); + FeatureCollectionAssert.assertThat(featureCollection) + .hasFeatureWithId(XPLAN_41, "XP_TextAbschnitt", "FEATURE_0453f54f-620f-40d7-8c1b-d842c6291a6c"); assertThatPlanIsSchemaValid(featureCollection, XPLAN_41); } @Test - public void testModifyXPlan_RasterBasis_refScan() throws Exception { + void modifyXPlanRasterBasisRefScan() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_51; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan51/V4_1_ID_103.gml"); @@ -615,16 +665,22 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("0")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_Rasterdarstellung)", is("0")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("count(//xp:BP_Bereich/xp:refScan)", is("1")).withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_Rasterdarstellung)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich/xp:refScan)") + .isEqualTo("1"); } @Test - public void testModifyXPlan_RasterBasis_refScan_remove() throws Exception { + void modifyXPlanRasterBasisRefScanRemove() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_51; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGml(version, "xplan51/V4_1_ID_103.gml"); @@ -635,19 +691,25 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("count(//xp:BP_Bereich/xp:rasterBasis)", is("0")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("count(//xp:BP_Bereich/xp:refScan)", is("0")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("count(//xp:XP_Rasterdarstellung)", is("0")).withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich/xp:rasterBasis)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich/xp:refScan)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_Rasterdarstellung)") + .isEqualTo("0"); } /** * https://www.jira.geoportal-hamburg.de/browse/XPLANBOX-961 (Testfall 1) */ @Test - public void testModifyXPlan_RasterBasis_Bereiche() throws Exception { + void modifyXPlanRasterBasisBereiche() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_41; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan41/BPlan001_4-1_Bereiche.zip"); @@ -668,16 +730,26 @@ public class XPlanManipulatorTest { String exportedPlanUpdate1 = exportPlan(featureCollection, version); - assertThat(exportedPlanUpdate1, hasXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:rasterBasis)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate1, hasXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:refScan)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate1, hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:rasterBasis)", is("1")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate1, hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate1, - hasXPath("count(//xp:XP_RasterplanBasis)", is("1")).withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlanUpdate1) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:rasterBasis)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate1) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:refScan)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate1) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:rasterBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlanUpdate1) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate1) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_RasterplanBasis)") + .isEqualTo("1"); assertThatPlanIsSchemaValid(featureCollection, version); @@ -698,25 +770,37 @@ public class XPlanManipulatorTest { String exportedPlanUpdate2 = exportPlan(featureCollection, version); - assertThat(exportedPlanUpdate2, hasXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:rasterBasis)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate2, hasXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:refScan)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate2, hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:rasterBasis)", is("1")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate2, hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)", is("0")) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate2, - hasXPath("count(//xp:XP_RasterplanBasis)", is("1")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlanUpdate2, hasXPath("count(//xp:XP_RasterplanBasis/xp:refScan)", is("2")) - .withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:rasterBasis)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '0']/xp:refScan)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:rasterBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)") + .isEqualTo("0"); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_RasterplanBasis)") + .isEqualTo("1"); + XmlAssert.assertThat(exportedPlanUpdate2) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:XP_RasterplanBasis/xp:refScan)") + .isEqualTo("2"); assertThatPlanIsSchemaValid(featureCollection, version); } @SuppressWarnings("unchecked") @Test - public void testModifyXPlan_FP() throws Exception { + void modifyXPlanFP() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_60; FeatureCollection featureCollection = readXPlanGmlFromZip("xplan60/FNP_Test_60.zip"); AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); @@ -735,29 +819,45 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("//xp:FP_Plan/xp:name", is(planName)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:FP_Plan/xp:beschreibung", is(description)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:FP_Plan/xp:technHerstellDatum", is(asString(creationDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:FP_Plan/xp:untergangsDatum", is(asString(lossDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:FP_Plan/xp:rechtsstand", is(Integer.toString(legislationStatusCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:FP_Plan/xp:verfahren").withNamespaceContext(nsContext(version)))); - assertThat(exportedPlan, hasXPath("//xp:FP_Plan/xp:planArt", is(Integer.toString(planTypeCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:FP_Plan/xp:sonstPlanArt").withNamespaceContext(nsContext(version)))); - - assertThat(exportedPlan, ValidationMatcher.valid(Input.fromURI(version.getSchemaUrl().toURI()))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:name") + .isEqualTo(planName); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:beschreibung") + .isEqualTo(description); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:technHerstellDatum") + .isEqualTo(asString(creationDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:untergangsDatum") + .isEqualTo(asString(lossDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:rechtsstand") + .isEqualTo(Integer.toString(legislationStatusCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:verfahren") + .isEmpty(); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:planArt") + .isEqualTo(Integer.toString(planTypeCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:FP_Plan/xp:sonstPlanArt") + .isEmpty(); + + XmlAssert.assertThat(exportedPlan).isValidAgainst(Input.fromURI(version.getSchemaUrl().toURI())); } @SuppressWarnings("unchecked") @Test - public void testModifyXPlan_LP() throws Exception { + void modifyXPlanLP() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_60; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan60/LP-Test_60.zip"); @@ -776,29 +876,45 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("//xp:LP_Plan/xp:name", is(planName)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:LP_Plan/xp:beschreibung", is(description)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:LP_Plan/xp:technHerstellDatum", is(asString(creationDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:LP_Plan/xp:untergangsDatum", is(asString(lossDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:LP_Plan/xp:rechtsstand", is(Integer.toString(legislationStatusCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:LP_Plan/xp:verfahren").withNamespaceContext(nsContext(version)))); - assertThat(exportedPlan, hasXPath("//xp:LP_Plan/xp:planArt", is(Integer.toString(planTypeCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:LP_Plan/xp:sonstPlanArt").withNamespaceContext(nsContext(version)))); - - assertThat(exportedPlan, ValidationMatcher.valid(Input.fromURI(version.getSchemaUrl().toURI()))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:name") + .isEqualTo(planName); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:beschreibung") + .isEqualTo(description); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:technHerstellDatum") + .isEqualTo(asString(creationDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:untergangsDatum") + .isEqualTo(asString(lossDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:rechtsstand") + .isEqualTo(Integer.toString(legislationStatusCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:verfahren") + .isEmpty(); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:planArt") + .isEqualTo(Integer.toString(planTypeCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:LP_Plan/xp:sonstPlanArt") + .isEmpty(); + + XmlAssert.assertThat(exportedPlan).isValidAgainst(Input.fromURI(version.getSchemaUrl().toURI())); } @SuppressWarnings("unchecked") @Test - public void testModifyXPlan_RP() throws Exception { + void modifyXPlanRP() throws Exception { XPlanVersion version = XPLAN_51; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan51/RROP_Landkreis_Test_51.zip"); @@ -817,29 +933,45 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("//xp:RP_Plan/xp:name", is(planName)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:RP_Plan/xp:beschreibung", is(description)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:RP_Plan/xp:technHerstellDatum", is(asString(creationDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:RP_Plan/xp:untergangsDatum", is(asString(lossDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:RP_Plan/xp:rechtsstand", is(Integer.toString(legislationStatusCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:RP_Plan/xp:verfahren", is(Integer.toString(methodCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:RP_Plan/xp:planArt", is(Integer.toString(planTypeCode))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:RP_Plan/xp:sonstPlanArt").withNamespaceContext(nsContext(version)))); - - assertThat(exportedPlan, ValidationMatcher.valid(Input.fromURI(version.getSchemaUrl().toURI()))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:name") + .isEqualTo(planName); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:beschreibung") + .isEqualTo(description); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:technHerstellDatum") + .isEqualTo(asString(creationDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:untergangsDatum") + .isEqualTo(asString(lossDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:rechtsstand") + .isEqualTo(Integer.toString(legislationStatusCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:verfahren") + .isEqualTo(Integer.toString(methodCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:planArt") + .isEqualTo(Integer.toString(planTypeCode)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:RP_Plan/xp:sonstPlanArt") + .isEmpty(); + + XmlAssert.assertThat(exportedPlan).isValidAgainst(Input.fromURI(version.getSchemaUrl().toURI())); } @SuppressWarnings("unchecked") @Test - public void testModifyXPlan_SO() throws Exception { + void modifyXPlanSO() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_60; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan60/StErhVO_Hamm_60.zip"); @@ -856,31 +988,47 @@ public class XPlanManipulatorTest { String exportedPlan = exportPlan(featureCollection, version); - assertThat(exportedPlan, - hasXPath("//xp:SO_Plan/xp:name", is(planName)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - hasXPath("//xp:SO_Plan/xp:beschreibung", is(description)).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:SO_Plan/xp:technHerstellDatum", is(asString(creationDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, hasXPath("//xp:SO_Plan/xp:untergangsDatum", is(asString(lossDate))) - .withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:SO_Plan/xp:rechtsstand").withNamespaceContext(nsContext(version)))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:SO_Plan/xp:verfahren").withNamespaceContext(nsContext(version)))); - assertThat(exportedPlan, - hasXPath("//xp:SO_Plan/xp:planArt", is("17200")).withNamespaceContext(nsContext(version))); - assertThat(exportedPlan, - not(HasXPathMatcher.hasXPath("//xp:SO_Plan/xp:sonstPlanArt").withNamespaceContext(nsContext(version)))); - - assertThat(exportedPlan, ValidationMatcher.valid(Input.fromURI(version.getSchemaUrl().toURI()))); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:name") + .isEqualTo(planName); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:beschreibung") + .isEqualTo(description); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:technHerstellDatum") + .isEqualTo(asString(creationDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:untergangsDatum") + .isEqualTo(asString(lossDate)); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:rechtsstand") + .isEmpty(); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:verfahren") + .isEmpty(); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:planArt") + .isEqualTo("17200"); + XmlAssert.assertThat(exportedPlan) + .withNamespaceContext(nsContext(version)) + .valueByXPath("//xp:SO_Plan/xp:sonstPlanArt") + .isEmpty(); + + XmlAssert.assertThat(exportedPlan).isValidAgainst(Input.fromURI(version.getSchemaUrl().toURI())); } /** * https://www.jira.geoportal-hamburg.de/browse/XPLANBOX-961 (Testfall 1) */ @Test - public void testModifyXPlan_RasterBasis_BP_60() throws Exception { + void modifyXPlanRasterBasisBP60() throws Exception { XPlanVersion version = XPlanVersion.XPLAN_60; AppSchema schema = XPlanSchemas.getInstance().getAppSchema(version); FeatureCollection featureCollection = readXPlanGmlFromZip("xplan60/BPlan001_6-0.zip"); @@ -899,8 +1047,10 @@ public class XPlanManipulatorTest { planManipulator.modifyXPlan(featureCollection, editedXplan, version, BP_Plan, schema); String exportedPlanAddRasterBasis = exportPlan(featureCollection, version); - assertThat(exportedPlanAddRasterBasis, hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)", is("1")) - .withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlanAddRasterBasis) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)") + .isEqualTo("1"); assertThatPlanIsSchemaValid(featureCollection, version); @@ -910,9 +1060,10 @@ public class XPlanManipulatorTest { String exportedPlanRemoveRasterBasis = exportPlan(featureCollection, version); - assertThat(exportedPlanRemoveRasterBasis, - hasXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)", is("0")) - .withNamespaceContext(nsContext(version))); + XmlAssert.assertThat(exportedPlanRemoveRasterBasis) + .withNamespaceContext(nsContext(version)) + .valueByXPath("count(//xp:BP_Bereich[xp:nummer = '1']/xp:refScan)") + .isEqualTo("0"); assertThatPlanIsSchemaValid(featureCollection, version); } @@ -947,7 +1098,7 @@ public class XPlanManipulatorTest { @SuppressWarnings("unchecked") private void assertThatPlanIsSchemaValid(String exportedPlan, XPlanVersion version) throws Exception { - assertThat(exportedPlan, ValidationMatcher.valid(Input.fromURI(version.getSchemaUrl().toURI()))); + XmlAssert.assertThat(exportedPlan).isValidAgainst(Input.fromURI(version.getSchemaUrl().toURI())); } private String exportPlan(FeatureCollection featureCollection, XPlanVersion version) throws Exception { @@ -965,274 +1116,222 @@ public class XPlanManipulatorTest { return nsContext; } - private Matcher<? super FeatureCollection> hasFeatureCount(final XPlanVersion version, final String expectedFeature, - final int numberOfOccurences) { - return new TypeSafeMatcher<FeatureCollection>() { - - @Override - protected boolean matchesSafely(FeatureCollection featureCollection) { - Iterator<Feature> iterator = featureCollection.iterator(); - int numberOfExpectedFeatures = 0; - while (iterator.hasNext()) { - Feature feature = iterator.next(); - if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) - numberOfExpectedFeatures++; - } - return numberOfExpectedFeatures == numberOfOccurences; - } - - @Override - public void describeTo(Description description) { - description.appendText("Expcted are "); - description.appendValue(numberOfOccurences); - description.appendText(" features with name "); - description.appendValue(expectedFeature); - } - }; + private FeatureCollection readXPlanGml(XPlanVersion xplanVersion, String plan) throws Exception { + InputStream xplanGml = this.getClass().getResourceAsStream(plan); + XMLStreamReader reader = XmlUtils.createXMLInputFactory().createXMLStreamReader(xplanGml); + return XPlanGmlParserBuilder.newBuilder().build().parseFeatureCollection(reader, xplanVersion); } - private Matcher<FeatureCollection> hasPropertyCount(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final int numberOfOccurences) { - return new TypeSafeMatcher<FeatureCollection>() { - - @Override - protected boolean matchesSafely(FeatureCollection featureCollection) { - Iterator<Feature> iterator = featureCollection.iterator(); - while (iterator.hasNext()) { - Feature feature = iterator.next(); - if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { - List<Property> properties = feature - .getProperties(new QName(version.getNamespace(), expectedProperty)); - return properties.size() == numberOfOccurences; - } - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("Expcted is a feature with name "); - description.appendValue(expectedFeature); - description.appendText(" with exact "); - description.appendValue(numberOfOccurences); - description.appendText(" property/properties with name "); - description.appendValue(expectedProperty); - } - - }; + private FeatureCollection readXPlanGmlFromZip(String resource) throws Exception { + InputStream resourceAsStream = getClass().getResourceAsStream("/testdata/" + resource); + XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); + XPlanArchive xPlanArchive = archiveCreator.createXPlanArchiveFromZip(resource, resourceAsStream); + return XPlanGmlParserBuilder.newBuilder().build().parseFeatureCollection(xPlanArchive); } - private Matcher<FeatureCollection> hasProperty(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final int expectedValue) { - return hasProperty(version, expectedFeature, expectedProperty, new PropertyMatcher() { - - @Override - public boolean matches(List<Property> properties) { - if (properties.size() != 1) - return false; - PrimitiveValue value = (PrimitiveValue) properties.get(0).getValue(); - return expectedValue == Integer.parseInt(value.getAsText()); - } - - @Override - public Object getExpectedValue() { - return expectedValue; - } - }); + private Text retrieveText(XPlanToEdit xplanToEdit, String featureId) { + for (Text text : xplanToEdit.getTexts()) { + if (featureId.equals(text.getFeatureId())) + return text; + } + return null; } - private Matcher<FeatureCollection> hasProperty(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final Date expectedValue) { - return hasProperty(version, expectedFeature, expectedProperty, new PropertyMatcher() { + private XPlan mockXPlan(XPlanVersion version) { + XPlan mock = mock(XPlan.class); + when(mock.getVersion()).thenReturn(version.toString()); + return mock; + } - @Override - public boolean matches(List<Property> properties) { - if (properties.size() != 1) - return false; - PrimitiveValue value = (PrimitiveValue) properties.get(0).getValue(); - org.deegree.commons.tom.datetime.Date propertyValue = (org.deegree.commons.tom.datetime.Date) value - .getValue(); - return expectedValue.equals(new Date(propertyValue.getTimeInMilliseconds())); - } + private Date asDate(String string) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + return simpleDateFormat.parse(string); + } - @Override - public Object getExpectedValue() { - return expectedValue; - } - }); + private String asString(Date date) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + return simpleDateFormat.format(date); } - private Matcher<FeatureCollection> hasProperty(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final String expectedValue) { - return hasProperty(version, expectedFeature, expectedProperty, new PropertyMatcher() { + static class FeatureCollectionAssert extends AbstractAssert<FeatureCollectionAssert, FeatureCollection> { - @Override - public boolean matches(List<Property> properties) { - if (properties.size() != 1) - return false; - String propertyValue = properties.get(0).getValue().toString(); - return propertyValue.equals(expectedValue); - } + private interface PropertyMatcher { - @Override - public Object getExpectedValue() { - return expectedValue; - } - }); - } + boolean matches(List<Property> properties); - private Matcher<? super FeatureCollection> hasNoProperty(final XPlanVersion version, final String expectedFeature, - final String expectedProperty) { - return new TypeSafeMatcher<FeatureCollection>() { - - @Override - protected boolean matchesSafely(FeatureCollection featureCollection) { - Iterator<Feature> iterator = featureCollection.iterator(); - while (iterator.hasNext()) { - Feature feature = iterator.next(); - if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { - List<Property> properties = feature - .getProperties(new QName(version.getNamespace(), expectedProperty)); - return properties.isEmpty(); - } - } - return false; - } + } - @Override - public void describeTo(Description description) { - description.appendText("Expcted is that the feature with name "); - description.appendValue(expectedFeature); - description.appendText(" does not have a property "); - description.appendValue(expectedProperty); - } + protected FeatureCollectionAssert(FeatureCollection actual) { + super(actual, FeatureCollectionAssert.class); + } - }; - } + public void hasHrefAttribue(final XPlanVersion version, final String expectedFeature, + final String expectedProperty, final String expectedHrefValue) { - private Matcher<FeatureCollection> hasProperty(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final PropertyMatcher propertyMatcher) { - return new TypeSafeMatcher<FeatureCollection>() { + hasProperty(version, expectedFeature, expectedProperty, new PropertyMatcher() { - @Override - protected boolean matchesSafely(FeatureCollection featureCollection) { - for (Feature feature : featureCollection) { - if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { + private final QName xlinkHrefAttribute = new QName("http://www.w3.org/1999/xlink", "href"); - List<Property> properties = feature - .getProperties(new QName(version.getNamespace(), expectedProperty)); - if (propertyMatcher.matches(properties)) + @Override + public boolean matches(List<Property> properties) { + for (Property property : properties) { + PrimitiveValue hrefValue = property.getAttributes().get(xlinkHrefAttribute); + if (hrefValue != null && hrefValue.toString().equals(expectedHrefValue)) return true; } + return false; } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("Expcted is a feature with name "); - description.appendValue(expectedFeature); - description.appendText(" with a property/attribute "); - description.appendValue(expectedProperty); - description.appendText(" and value "); - description.appendValue(propertyMatcher.getExpectedValue()); - } - - }; - } + }); + } - private Matcher<FeatureCollection> hasFeatureWithId(final XPlanVersion version, final String expectedFeature, - final String expectedFeatureId) { - return new TypeSafeMatcher<FeatureCollection>() { + public void hasFeatureWithId(final XPlanVersion version, final String expectedFeature, + final String expectedFeatureId) { - @Override - protected boolean matchesSafely(FeatureCollection featureCollection) { - for (Feature feature : featureCollection) { - if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { - String id = feature.getId(); - if (expectedFeatureId.equals(id)) - return true; - } + QName qname = new QName(version.getNamespace(), expectedFeature); + for (Feature feature : actual) { + if (feature.getName().equals(qname)) { + String id = feature.getId(); + if (expectedFeatureId.equals(id)) + return; } - return false; } + failure("Expected feature with name %s and id %s not found", expectedFeature, expectedFeatureId); + } - @Override - public void describeTo(Description description) { - description.appendText("Expcted is a feature with name "); - description.appendValue(expectedFeature); - description.appendText(" with id"); - description.appendValue(expectedFeatureId); - } + public void hasFeatureCount(final XPlanVersion version, final String expectedFeature, + final int numberOfOccurences) { - }; - } + QName qname = new QName(version.getNamespace(), expectedFeature); + Iterator<Feature> iterator = actual.iterator(); + int numberOfExpectedFeatures = 0; + while (iterator.hasNext()) { + Feature feature = iterator.next(); + if (feature.getName().equals(qname)) + numberOfExpectedFeatures++; + } - private Matcher<FeatureCollection> hasHrefAttribue(final XPlanVersion version, final String expectedFeature, - final String expectedProperty, final String expectedHrefValue) { - return hasProperty(version, expectedFeature, expectedProperty, new PropertyMatcher() { + if (numberOfExpectedFeatures != numberOfOccurences) { + failureWithActualExpected(numberOfOccurences, numberOfExpectedFeatures, + "Unexpected number of feature with name %s", expectedFeature); + } + } - private final QName xlinkHrefAttribute = new QName("http://www.w3.org/1999/xlink", "href"); + private boolean hasProperty(final XPlanVersion version, final String expectedFeature, + final String expectedProperty, final PropertyMatcher propertyMatcher) { - @Override - public boolean matches(List<Property> properties) { - for (Property property : properties) { - PrimitiveValue hrefValue = property.getAttributes().get(xlinkHrefAttribute); - if (hrefValue != null && hrefValue.toString().equals(expectedHrefValue)) + for (Feature feature : actual) { + if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { + List<Property> properties = feature + .getProperties(new QName(version.getNamespace(), expectedProperty)); + if (propertyMatcher.matches(properties)) return true; } - return false; } + return false; + } - @Override - public Object getExpectedValue() { - return expectedHrefValue; + public void hasProperty(final XPlanVersion version, final String expectedFeature, final String expectedProperty, + final Date expectedValue) { + + PropertyMatcher matcher = new PropertyMatcher() { + @Override + public boolean matches(List<Property> properties) { + if (properties.size() != 1) + return false; + PrimitiveValue value = (PrimitiveValue) properties.get(0).getValue(); + org.deegree.commons.tom.datetime.Date propertyValue = (org.deegree.commons.tom.datetime.Date) value + .getValue(); + return expectedValue.equals(new Date(propertyValue.getTimeInMilliseconds())); + } + + }; + if (!hasProperty(version, expectedFeature, expectedProperty, matcher)) { + throw failure("No feature %s found with property %s having value %s", expectedFeature, expectedProperty, + expectedValue); } - }); - } - private FeatureCollection readXPlanGml(XPlanVersion xplanVersion, String plan) throws Exception { - InputStream xplanGml = this.getClass().getResourceAsStream(plan); - XMLStreamReader reader = XmlUtils.createXMLInputFactory().createXMLStreamReader(xplanGml); - return XPlanGmlParserBuilder.newBuilder().build().parseFeatureCollection(reader, xplanVersion); - } + } - private FeatureCollection readXPlanGmlFromZip(String resource) throws Exception { - InputStream resourceAsStream = getClass().getResourceAsStream("/testdata/" + resource); - XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); - XPlanArchive xPlanArchive = archiveCreator.createXPlanArchiveFromZip(resource, resourceAsStream); - return XPlanGmlParserBuilder.newBuilder().build().parseFeatureCollection(xPlanArchive); - } + public void hasProperty(final XPlanVersion version, final String expectedFeature, final String expectedProperty, + final int expectedValue) { + PropertyMatcher matcher = new PropertyMatcher() { - private Text retrieveText(XPlanToEdit xplanToEdit, String featureId) { - for (Text text : xplanToEdit.getTexts()) { - if (featureId.equals(text.getFeatureId())) - return text; + @Override + public boolean matches(List<Property> properties) { + if (properties.size() != 1) + return false; + PrimitiveValue value = (PrimitiveValue) properties.get(0).getValue(); + return expectedValue == Integer.parseInt(value.getAsText()); + } + + }; + if (!hasProperty(version, expectedFeature, expectedProperty, matcher)) { + throw failure("No feature %s found with property %s having value %s", expectedFeature, expectedProperty, + expectedValue); + } } - return null; - } - private XPlan mockXPlan(XPlanVersion version) { - XPlan mock = mock(XPlan.class); - when(mock.getVersion()).thenReturn(version.toString()); - return mock; - } + public void hasNoProperty(final XPlanVersion version, final String expectedFeature, + final String expectedProperty) { + Iterator<Feature> iterator = actual.iterator(); + while (iterator.hasNext()) { + Feature feature = iterator.next(); + if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { + List<Property> properties = feature + .getProperties(new QName(version.getNamespace(), expectedProperty)); + if (!properties.isEmpty()) { + throw failureWithActualExpected(Collections.emptyList(), properties, + "Found properties %s for feature %s", expectedProperty, expectedFeature); + } + else { + return; + } + } + } + ; + } - private Date asDate(String string) throws ParseException { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - return simpleDateFormat.parse(string); - } + public void hasProperty(final XPlanVersion version, final String expectedFeature, final String expectedProperty, + final String expectedValue) { - private String asString(Date date) throws ParseException { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - return simpleDateFormat.format(date); - } + PropertyMatcher matcher = new PropertyMatcher() { + @Override + public boolean matches(List<Property> properties) { + if (properties.size() != 1) + return false; + String propertyValue = properties.get(0).getValue().toString(); + return propertyValue.equals(expectedValue); + } - private interface PropertyMatcher { + }; - Object getExpectedValue(); + if (!hasProperty(version, expectedFeature, expectedProperty, matcher)) { + throw failure("No feature %s found with property %s having value %s", expectedFeature, expectedProperty, + expectedValue); + } + } - boolean matches(List<Property> properties); + public void hasPropertyCount(XPlanVersion version, final String expectedFeature, final String expectedProperty, + final int numberOfOccurences) { + + Iterator<Feature> iterator = actual.iterator(); + while (iterator.hasNext()) { + Feature feature = iterator.next(); + if (feature.getName().equals(new QName(version.getNamespace(), expectedFeature))) { + List<Property> properties = feature + .getProperties(new QName(version.getNamespace(), expectedProperty)); + Assertions.assertThat(properties) + .as("Property %s of feature %s", expectedProperty, expectedFeature) + .hasSize(numberOfOccurences); + return; + } + } + throw failure("No feature >%s< found with property >%s<", expectedFeature, expectedProperty); + } + + public static FeatureCollectionAssert assertThat(FeatureCollection featureCollection) { + return new FeatureCollectionAssert(featureCollection); + } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanToEditFactoryTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanToEditFactoryTest.java index 35f3372105..dfcb2252d5 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanToEditFactoryTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/edit/XPlanToEditFactoryTest.java @@ -8,47 +8,18 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package de.latlon.xplan.manager.edit; -import de.latlon.xplan.commons.XPlanType; -import de.latlon.xplan.commons.XPlanVersion; -import de.latlon.xplan.commons.archive.XPlanArchive; -import de.latlon.xplan.commons.archive.XPlanArchiveCreator; -import de.latlon.xplan.commons.feature.XPlanGmlParserBuilder; -import de.latlon.xplan.manager.web.shared.XPlan; -import de.latlon.xplan.manager.web.shared.edit.BaseData; -import de.latlon.xplan.manager.web.shared.edit.Change; -import de.latlon.xplan.manager.web.shared.edit.RasterBasis; -import de.latlon.xplan.manager.web.shared.edit.RasterReference; -import de.latlon.xplan.manager.web.shared.edit.RasterReferenceType; -import de.latlon.xplan.manager.web.shared.edit.Reference; -import de.latlon.xplan.manager.web.shared.edit.Text; -import de.latlon.xplan.manager.web.shared.edit.XPlanToEdit; -import junitparams.JUnitParamsRunner; -import org.deegree.cs.exceptions.UnknownCRSException; -import org.deegree.feature.FeatureCollection; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.xml.stream.XMLStreamException; -import java.io.IOException; -import java.io.InputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Optional; - import static de.latlon.xplan.commons.XPlanType.BP_Plan; import static de.latlon.xplan.commons.XPlanType.FP_Plan; import static de.latlon.xplan.commons.XPlanType.LP_Plan; @@ -75,439 +46,465 @@ import static de.latlon.xplan.manager.web.shared.edit.ReferenceType.RECHTSPLAN; import static de.latlon.xplan.manager.web.shared.edit.ReferenceType.VERORDNUNG; import static de.latlon.xplan.manager.web.shared.edit.TextRechtscharacterType.SO_SONSTIGES; import static de.latlon.xplan.manager.web.shared.edit.TextRechtscharacterType.XP_FESTSETZUNGBPLAN; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import org.deegree.feature.FeatureCollection; +import org.junit.jupiter.api.Test; + +import de.latlon.xplan.commons.XPlanType; +import de.latlon.xplan.commons.XPlanVersion; +import de.latlon.xplan.commons.archive.XPlanArchive; +import de.latlon.xplan.commons.archive.XPlanArchiveCreator; +import de.latlon.xplan.commons.feature.XPlanGmlParserBuilder; +import de.latlon.xplan.manager.web.shared.XPlan; +import de.latlon.xplan.manager.web.shared.edit.BaseData; +import de.latlon.xplan.manager.web.shared.edit.Change; +import de.latlon.xplan.manager.web.shared.edit.RasterBasis; +import de.latlon.xplan.manager.web.shared.edit.RasterReference; +import de.latlon.xplan.manager.web.shared.edit.RasterReferenceType; +import de.latlon.xplan.manager.web.shared.edit.Reference; +import de.latlon.xplan.manager.web.shared.edit.Text; +import de.latlon.xplan.manager.web.shared.edit.XPlanToEdit; + /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> */ -@RunWith(JUnitParamsRunner.class) -public class XPlanToEditFactoryTest { +class XPlanToEditFactoryTest { private XPlanToEditFactory factory = new XPlanToEditFactory(); @Test - public void testCreateXPlanToEdit_XPlan52_multipleBereiche() throws Exception { + void createXPlanToEditXPlan52MultipleBereiche() throws Exception { FeatureCollection featureCollection = readXPlanArchive(XPLAN_52, "xplan52/BPlan001_5-2_Bereiche.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_52, BP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); List<RasterBasis> rasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(rasterBasis.size(), is(2)); + assertThat(rasterBasis).hasSize(2); // Bereich 0 String bereichNummer0 = "0"; RasterBasis rasterBasis0 = getByBereichNummer(rasterBasis, bereichNummer0); List<RasterReference> rasterReferences0 = rasterBasis0.getRasterReferences(); - assertThat(rasterBasis0.getFeatureId(), is(nullValue())); - assertThat(rasterReferences0.size(), is(1)); - assertThat(rasterReferences0.get(0).getBereichNummer(), is(bereichNummer0)); - assertThat(rasterReferences0.get(0).getReference(), is("BPlan001_5-2_Bereich0.png")); + assertNull(rasterBasis0.getFeatureId()); + assertThat(rasterReferences0).hasSize(1); + assertEquals(bereichNummer0, rasterReferences0.get(0).getBereichNummer()); + assertEquals("BPlan001_5-2_Bereich0.png", rasterReferences0.get(0).getReference()); // Bereich 1 String bereichNummer1 = "1"; RasterBasis rasterBasis1 = getByBereichNummer(rasterBasis, bereichNummer1); List<RasterReference> rasterReferences1 = rasterBasis1.getRasterReferences(); - assertThat(rasterBasis1.getFeatureId(), is(nullValue())); - assertThat(rasterReferences1.size(), is(1)); - assertThat(rasterReferences1.get(0).getBereichNummer(), is(bereichNummer1)); - assertThat(rasterReferences1.get(0).getReference(), is("BPlan001_5-2_Bereich1.png")); + assertNull(rasterBasis1.getFeatureId()); + assertThat(rasterReferences1).hasSize(1); + assertEquals(bereichNummer1, rasterReferences1.get(0).getBereichNummer()); + assertEquals("BPlan001_5-2_Bereich1.png", rasterReferences1.get(0).getReference()); } @Test - public void testCreateXPlanToEdit_XPlan51_refScan() throws Exception { + void createXPlanToEditXPlan51RefScan() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_51, "xplan51/V4_1_ID_103_refScan.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_51, BP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); String bereichNummer = "0"; List<RasterBasis> allRasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(allRasterBasis.size(), is(1)); + assertThat(allRasterBasis).hasSize(1); RasterBasis rasterBasis = allRasterBasis.get(0); - assertThat(rasterBasis.getFeatureId(), is(nullValue())); - assertThat(rasterBasis.getBereichNummer(), is(bereichNummer)); + assertNull(rasterBasis.getFeatureId()); + assertEquals(bereichNummer, rasterBasis.getBereichNummer()); List<RasterReference> rasterReferences = rasterBasis.getRasterReferences(); - assertThat(rasterReferences.size(), is(1)); - assertThat(rasterReferences.get(0).getBereichNummer(), is(bereichNummer)); - assertThat(rasterReferences.get(0).getReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tif")); - assertThat(rasterReferences.get(0).getGeoReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tfw")); + assertThat(rasterReferences).hasSize(1); + assertEquals(bereichNummer, rasterReferences.get(0).getBereichNummer()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tif", rasterReferences.get(0).getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tfw", rasterReferences.get(0).getGeoReference()); } @Test - public void testCreateXPlanToEdit_XPlan51_rasterdarstellung() throws Exception { + void createXPlanToEditXPlan51Rasterdarstellung() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_51, "xplan51/V4_1_ID_103.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_51, BP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); String bereichNummer = "0"; List<RasterBasis> allRasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(allRasterBasis.size(), is(1)); + assertThat(allRasterBasis).hasSize(1); RasterBasis rasterBasis = allRasterBasis.get(0); - assertThat(rasterBasis.getFeatureId(), is("FEATURE_c2a83b1c-05f4-4dc0-a1b6-feb1a43328d6")); - assertThat(rasterBasis.getBereichNummer(), is(bereichNummer)); + assertEquals("FEATURE_c2a83b1c-05f4-4dc0-a1b6-feb1a43328d6", rasterBasis.getFeatureId()); + assertEquals(bereichNummer, rasterBasis.getBereichNummer()); List<RasterReference> rasterReferences = rasterBasis.getRasterReferences(); - assertThat(rasterReferences.size(), is(1)); - assertThat(rasterReferences.get(0).getBereichNummer(), is(bereichNummer)); - assertThat(rasterReferences.get(0).getReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tif")); - assertThat(rasterReferences.get(0).getGeoReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tfw")); + assertThat(rasterReferences).hasSize(1); + assertEquals(bereichNummer, rasterReferences.get(0).getBereichNummer()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tif", rasterReferences.get(0).getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tfw", rasterReferences.get(0).getGeoReference()); - assertThat(xPlanToEdit.getTexts().size(), is(2)); - assertThat(xPlanToEdit.getReferences().size(), is(4)); + assertThat(xPlanToEdit.getTexts()).hasSize(2); + assertThat(xPlanToEdit.getReferences()).hasSize(4); } @Test - public void testCreateXPlanToEdit_XPlan50_BaseData_Changes() throws Exception { + void createXPlanToEditXPlan50BaseDataChanges() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_50, "xplan50/BP2070.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_50, BP_Plan), featureCollection); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("BP2070")); - assertThat(baseData.getDescription(), is("Testdatensatz XPlabGML")); + assertEquals("BP2070", baseData.getPlanName()); + assertEquals("Testdatensatz XPlabGML", baseData.getDescription()); - assertThat(baseData.getLegislationStatusCode(), is(-1)); - assertThat(baseData.getPlanTypeCode(), is(1000)); - assertThat(baseData.getMethodCode(), is(-1)); - assertThat(baseData.getOtherPlanTypeCode(), is(-1)); + assertEquals(-1, baseData.getLegislationStatusCode()); + assertEquals(1000, baseData.getPlanTypeCode()); + assertEquals(-1, baseData.getMethodCode()); + assertEquals(-1, baseData.getOtherPlanTypeCode()); - assertThat(baseData.getCreationDate(), is(asDate("2001-08-06"))); - assertThat(baseData.getLossDate(), nullValue()); - assertThat(baseData.getRegulationDate(), nullValue()); + assertEquals(asDate("2001-08-06"), baseData.getCreationDate()); + assertNull(baseData.getLossDate()); + assertNull(baseData.getRegulationDate()); List<Change> changes = xPlanToEdit.getChanges(); - assertThat(changes.size(), is(0)); + assertThat(changes).hasSize(0); } @Test - public void testCreateXPlanToEdit_XPlan41_BaseData_Changes() throws Exception { + void createXPlanToEditXPlan41BaseDataChanges() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_41, "xplan41/Eidelstedt_4_V4-Blankenese.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_41, BP_Plan), featureCollection); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("Eidelstedt 4")); - assertThat(baseData.getDescription(), is("Beschreibung von Eidelstedt 4")); + assertEquals("Eidelstedt 4", baseData.getPlanName()); + assertEquals("Beschreibung von Eidelstedt 4", baseData.getDescription()); - assertThat(baseData.getLegislationStatusCode(), is(4000)); - assertThat(baseData.getPlanTypeCode(), is(1000)); - assertThat(baseData.getMethodCode(), is(2000)); - assertThat(baseData.getOtherPlanTypeCode(), is(-1)); + assertEquals(4000, baseData.getLegislationStatusCode()); + assertEquals(1000, baseData.getPlanTypeCode()); + assertEquals(2000, baseData.getMethodCode()); + assertEquals(-1, baseData.getOtherPlanTypeCode()); - assertThat(baseData.getCreationDate(), is(asDate("2010-10-07"))); - assertThat(baseData.getLossDate(), is(asDate("2020-10-07"))); - assertThat(baseData.getRegulationDate(), is(asDate("1970-01-01"))); + assertEquals(asDate("2010-10-07"), baseData.getCreationDate()); + assertEquals(asDate("2020-10-07"), baseData.getLossDate()); + assertEquals(asDate("1970-01-01"), baseData.getRegulationDate()); List<Change> changes = xPlanToEdit.getChanges(); - assertThat(changes.size(), is(2)); + assertThat(changes).hasSize(2); Change firstChange = changes.get(0); - assertThat(firstChange.getPlanName(), is("Eidelstedt 3 (alt)")); - assertThat(firstChange.getLegalNatureCode(), is(1100)); - assertThat(firstChange.getNumber(), is("3")); - assertThat(firstChange.getType(), is(CHANGES)); + assertEquals("Eidelstedt 3 (alt)", firstChange.getPlanName()); + assertEquals(1100, firstChange.getLegalNatureCode()); + assertEquals("3", firstChange.getNumber()); + assertEquals(CHANGES, firstChange.getType()); Change secondChange = changes.get(1); - assertThat(secondChange.getPlanName(), is("Eidelstedt 4 (textliche Änderung)")); - assertThat(secondChange.getLegalNatureCode(), is(1000)); - assertThat(secondChange.getNumber(), is(nullValue())); - assertThat(secondChange.getType(), is(CHANGED_BY)); + assertEquals("Eidelstedt 4 (textliche Änderung)", secondChange.getPlanName()); + assertEquals(1000, secondChange.getLegalNatureCode()); + assertNull(secondChange.getNumber()); + assertEquals(CHANGED_BY, secondChange.getType()); } @Test - public void testCreateXPlanToEdit_References_Texts_V4_1_ID_103_41() throws Exception { + void createXPlanToEditReferencesTextsV41ID10341() throws Exception { XPlanVersion version = XPLAN_41; FeatureCollection featureCollection = readXPlanGml(version, "xplan41/V4_1_ID_103.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(version, BP_Plan), featureCollection); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("\"Heideweg\"")); - assertThat(baseData.getLegislationStatusCode(), is(4000)); - assertThat(baseData.getPlanTypeCode(), is(1000)); - assertThat(baseData.getCreationDate(), is(asDate("2001-08-27"))); + assertEquals("\"Heideweg\"", baseData.getPlanName()); + assertEquals(4000, baseData.getLegislationStatusCode()); + assertEquals(1000, baseData.getPlanTypeCode()); + assertEquals(asDate("2001-08-27"), baseData.getCreationDate()); List<Change> changes = xPlanToEdit.getChanges(); - assertThat(changes.size(), is(0)); + assertThat(changes).hasSize(0); List<Reference> references = xPlanToEdit.getReferences(); - assertThat(references.size(), is(3)); + assertThat(references).hasSize(3); Reference firstReference = references.get(0); - assertThat(firstReference.getGeoReference(), is(nullValue())); - assertThat(firstReference.getReference(), is("B-Plan_Klingmuehl_Heideweg_Leg.pdf")); - assertThat(firstReference.getReferenzName(), is("B-Plan_Klingmuehl_Heideweg_Leg")); - assertThat(firstReference.getType(), is(BEGRUENDUNG)); + assertNull(firstReference.getGeoReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Leg.pdf", firstReference.getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Leg", firstReference.getReferenzName()); + assertEquals(BEGRUENDUNG, firstReference.getType()); Reference secondReference = references.get(1); - assertThat(secondReference.getGeoReference(), is(nullValue())); - assertThat(secondReference.getReference(), is("B-Plan_Klingmuehl_Heideweg.tif")); - assertThat(secondReference.getReferenzName(), is("B-Plan_Klingmuehl_Heideweg")); - assertThat(secondReference.getType(), is(RECHTSPLAN)); + assertNull(secondReference.getGeoReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg.tif", secondReference.getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg", secondReference.getReferenzName()); + assertEquals(RECHTSPLAN, secondReference.getType()); Reference thirdReference = references.get(2); - assertThat(thirdReference.getGeoReference(), is("B-Plan_Klingmuehl_Heideweg_Gruen.pgw")); - assertThat(thirdReference.getReference(), is("B-Plan_Klingmuehl_Heideweg_Gruen.png")); - assertThat(thirdReference.getReferenzName(), is("B-Plan_Klingmuehl_Heideweg_Gruen")); - assertThat(thirdReference.getType(), is(GRUENORDNUNGSPLAN)); + assertEquals("B-Plan_Klingmuehl_Heideweg_Gruen.pgw", thirdReference.getGeoReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Gruen.png", thirdReference.getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Gruen", thirdReference.getReferenzName()); + assertEquals(GRUENORDNUNGSPLAN, thirdReference.getType()); List<Text> texts = xPlanToEdit.getTexts(); - assertThat(texts.size(), is(1)); + assertThat(texts).hasSize(1); Text text = texts.get(0); - assertThat(text.getFeatureId(), is("FEATURE_0f870967-bd6f-4367-9150-8a255f0290ad")); - assertThat(text.getKey(), is("key")); - assertThat(text.getBasis(), is("base")); - assertThat(text.getText(), is("Beschreibungstext")); - assertThat(text.getGeoReference(), is(nullValue())); - assertThat(text.getReference(), is("B-Plan_Klingmuehl_Heideweg_Text.pdf")); + assertEquals("FEATURE_0f870967-bd6f-4367-9150-8a255f0290ad", text.getFeatureId()); + assertEquals("key", text.getKey()); + assertEquals("base", text.getBasis()); + assertEquals("Beschreibungstext", text.getText()); + assertNull(text.getGeoReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Text.pdf", text.getReference()); String bereichNummer = "0"; List<RasterBasis> allRasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(allRasterBasis.size(), is(1)); + assertThat(allRasterBasis).hasSize(1); RasterBasis rasterBasis = allRasterBasis.get(0); - assertThat(rasterBasis.getBereichNummer(), is(bereichNummer)); - assertThat(rasterBasis.getFeatureId(), is("FEATURE_c2a83b1c-05f4-4dc0-a1b6-feb1a43328d6")); + assertEquals(bereichNummer, rasterBasis.getBereichNummer()); + assertEquals("FEATURE_c2a83b1c-05f4-4dc0-a1b6-feb1a43328d6", rasterBasis.getFeatureId()); List<RasterReference> rasterBasisReferences = rasterBasis.getRasterReferences(); - assertThat(rasterBasisReferences.size(), is(2)); + assertThat(rasterBasisReferences).hasSize(2); RasterReference scan = getByType(rasterBasisReferences, SCAN); - assertThat(scan, is(notNullValue())); - assertThat(scan.getFeatureId(), nullValue()); - assertThat(scan.getBereichNummer(), is(bereichNummer)); - assertThat(scan.getGeoReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tfw")); - assertThat(scan.getReference(), is("B-Plan_Klingmuehl_Heideweg_Karte.tif")); - assertThat(scan.getReferenzName(), is("B-Plan_Klingmuehl_Heideweg_Karte")); - assertThat(scan.getArt(), is(PLANMITGEOREFERENZ)); + assertNotNull(scan); + assertNull(scan.getFeatureId()); + assertEquals(bereichNummer, scan.getBereichNummer()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tfw", scan.getGeoReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte.tif", scan.getReference()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Karte", scan.getReferenzName()); + assertEquals(PLANMITGEOREFERENZ, scan.getArt()); RasterReference legend = getByType(rasterBasisReferences, LEGEND); - assertThat(legend, is(notNullValue())); - assertThat(legend.getFeatureId(), nullValue()); - assertThat(legend.getBereichNummer(), is(bereichNummer)); - assertThat(legend.getReference(), is("B-Plan_Klingmuehl_Heideweg_Legende.png")); - assertThat(legend.getReferenzMimeType(), is(IMAGE_PNG)); - assertThat(legend.getGeoReference(), is(nullValue())); - assertThat(legend.getGeorefMimeType(), is(nullValue())); - assertThat(legend.getInformationssystemURL(), is("informationssystemURL")); - assertThat(legend.getReferenzName(), is("B-Plan_Klingmuehl_Heideweg_Legende")); - assertThat(legend.getBeschreibung(), is("beschreibung")); - assertThat(legend.getDatum(), is(asDate("2018-03-01"))); - assertThat(legend.getArt(), is(DOKUMENT)); + assertNotNull(legend); + assertNull(legend.getFeatureId()); + assertEquals(bereichNummer, legend.getBereichNummer()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Legende.png", legend.getReference()); + assertEquals(IMAGE_PNG, legend.getReferenzMimeType()); + assertNull(legend.getGeoReference()); + assertNull(legend.getGeorefMimeType()); + assertEquals("informationssystemURL", legend.getInformationssystemURL()); + assertEquals("B-Plan_Klingmuehl_Heideweg_Legende", legend.getReferenzName()); + assertEquals("beschreibung", legend.getBeschreibung()); + assertEquals(asDate("2018-03-01"), legend.getDatum()); + assertEquals(DOKUMENT, legend.getArt()); } @Test - public void testCreateXPlanToEdit_References_Texts_BPlan004_50() throws Exception { + void createXPlanToEditReferencesTextsBPlan00450() throws Exception { XPlanVersion version = XPLAN_50; FeatureCollection featureCollection = readXPlanArchive(version, "xplan50/BPlan004_5-0.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(version, BP_Plan), featureCollection); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("BPlan004_5-0")); - assertThat(baseData.getLegislationStatusCode(), is(3000)); - assertThat(baseData.getPlanTypeCode(), is(3000)); - assertThat(baseData.getCreationDate(), is(asDate("2017-03-20"))); + assertEquals("BPlan004_5-0", baseData.getPlanName()); + assertEquals(3000, baseData.getLegislationStatusCode()); + assertEquals(3000, baseData.getPlanTypeCode()); + assertEquals(asDate("2017-03-20"), baseData.getCreationDate()); List<Change> changes = xPlanToEdit.getChanges(); - assertThat(changes.size(), is(0)); + assertThat(changes).hasSize(0); List<Reference> references = xPlanToEdit.getReferences(); - assertThat(references.size(), is(1)); + assertThat(references).hasSize(1); Reference firstReference = references.get(0); - assertThat(firstReference.getGeoReference(), is(nullValue())); - assertThat(firstReference.getReference(), is("BPlan004_5-0.pdf")); - assertThat(firstReference.getReferenzName(), is(nullValue())); - assertThat(firstReference.getType(), is(INFORMELL)); + assertNull(firstReference.getGeoReference()); + assertEquals("BPlan004_5-0.pdf", firstReference.getReference()); + assertNull(firstReference.getReferenzName()); + assertEquals(INFORMELL, firstReference.getType()); List<Text> texts = xPlanToEdit.getTexts(); - assertThat(texts.size(), is(9)); + assertThat(texts).hasSize(9); String featureIdOfText = "GML_c27ab7dd-8e16-4f88-abae-6b23d49e7a90"; Text text = texts.stream().filter(t -> featureIdOfText.equals(t.getFeatureId())).findFirst().get(); - assertThat(text.getFeatureId(), is(featureIdOfText)); - assertThat(text.getKey(), is("§2 Nr.4")); - assertThat(text.getBasis(), is(nullValue())); - assertThat(text.getText(), is( - "Im allgemeinen Wohngebiet darf die festgesetzte Grundflächenzahl\nfür Tiefgaragen bis zu einer Grundflächenzahl\nvon 1,0 überschritten werden.")); + assertEquals(featureIdOfText, text.getFeatureId()); + assertEquals("§2 Nr.4", text.getKey()); + assertNull(text.getBasis()); + assertEquals( + "Im allgemeinen Wohngebiet darf die festgesetzte Grundflächenzahl\nfür Tiefgaragen bis zu einer Grundflächenzahl\nvon 1,0 überschritten werden.", + text.getText()); String bereichNummer = "0"; List<RasterBasis> allRasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(allRasterBasis.size(), is(1)); + assertThat(allRasterBasis).hasSize(1); RasterBasis rasterBasis = allRasterBasis.get(0); - assertThat(rasterBasis.getBereichNummer(), is(bereichNummer)); - assertThat(rasterBasis.getFeatureId(), is("Gml_FEC4F42F-5D66-4A59-9A47-6E03D1A3139A")); + assertEquals(bereichNummer, rasterBasis.getBereichNummer()); + assertEquals("Gml_FEC4F42F-5D66-4A59-9A47-6E03D1A3139A", rasterBasis.getFeatureId()); List<RasterReference> rasterBasisReferences = rasterBasis.getRasterReferences(); - assertThat(rasterBasisReferences.size(), is(1)); + assertThat(rasterBasisReferences).hasSize(1); RasterReference scan = getByType(rasterBasisReferences, SCAN); - assertThat(scan, is(notNullValue())); - assertThat(scan.getFeatureId(), nullValue()); - assertThat(scan.getBereichNummer(), is(bereichNummer)); - assertThat(scan.getGeoReference(), is("BPlan004_5-0.pgw")); - assertThat(scan.getReference(), is("BPlan004_5-0.png")); + assertNotNull(scan); + assertNull(scan.getFeatureId()); + assertEquals(bereichNummer, scan.getBereichNummer()); + assertEquals("BPlan004_5-0.pgw", scan.getGeoReference()); + assertEquals("BPlan004_5-0.png", scan.getReference()); } @Test - public void testCreateXPlanToEdit_XPlan53_withoutBereich() throws Exception { + void createXPlanToEditXPlan53WithoutBereich() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_53, "xplan53/BPlan_ohneBereich.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_53, BP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(false)); + assertFalse(xPlanToEdit.isHasBereich()); } @Test - public void testCreateXPlanToEdit_XPlan51_FPlan() throws Exception { + void createXPlanToEditXPlan51FPlan() throws Exception { FeatureCollection featureCollection = readXPlanArchive(XPLAN_51, "xplan51/FPlan.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_51, FP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("FPlan Bad Liebenwerda")); - assertThat(baseData.getPlanTypeCode(), is(9999)); - assertThat(baseData.getCreationDate(), is(asDate("2004-12-01"))); - - assertThat(xPlanToEdit.getRasterBasis().size(), is(1)); - assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences().size(), is(0)); - assertThat(xPlanToEdit.getTexts().size(), is(0)); - assertThat(xPlanToEdit.getReferences().size(), is(0)); - assertThat(xPlanToEdit.getChanges().size(), is(0)); + assertEquals("FPlan Bad Liebenwerda", baseData.getPlanName()); + assertEquals(9999, baseData.getPlanTypeCode()); + assertEquals(asDate("2004-12-01"), baseData.getCreationDate()); + + assertThat(xPlanToEdit.getRasterBasis()).hasSize(1); + assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences()).hasSize(0); + assertThat(xPlanToEdit.getTexts()).hasSize(0); + assertThat(xPlanToEdit.getReferences()).hasSize(0); + assertThat(xPlanToEdit.getChanges()).hasSize(0); } @Test - public void testCreateXPlanToEdit_XPlan60_LPlan() throws Exception { + void createXPlanToEditXPlan60LPlan() throws Exception { FeatureCollection featureCollection = readXPlanArchive(XPLAN_60, "xplan60/LP-Test_60.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_60, LP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("LP-Test 60")); - assertThat(baseData.getPlanTypeCode(), is(3000)); + assertEquals("LP-Test 60", baseData.getPlanName()); + assertEquals(3000, baseData.getPlanTypeCode()); - assertThat(xPlanToEdit.getRasterBasis().size(), is(1)); - assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences().size(), is(0)); + assertThat(xPlanToEdit.getRasterBasis()).hasSize(1); + assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences()).hasSize(0); List<Text> texts = xPlanToEdit.getTexts(); - assertThat(texts.size(), is(1)); + assertThat(texts).hasSize(1); Text text = texts.get(0); - assertThat(text.getFeatureId(), is("Gml_1234")); - assertThat(text.getText(), is("Test")); - assertThat(text.getRechtscharakter(), is(XP_FESTSETZUNGBPLAN)); + assertEquals("Gml_1234", text.getFeatureId()); + assertEquals("Test", text.getText()); + assertEquals(XP_FESTSETZUNGBPLAN, text.getRechtscharakter()); - assertThat(xPlanToEdit.getReferences().size(), is(0)); - assertThat(xPlanToEdit.getChanges().size(), is(0)); + assertThat(xPlanToEdit.getReferences()).hasSize(0); + assertThat(xPlanToEdit.getChanges()).hasSize(0); } @Test - public void testCreateXPlanToEdit_XPlan51_SOPlan() throws Exception { + void createXPlanToEditXPlan51SOPlan() throws Exception { FeatureCollection featureCollection = readXPlanArchive(XPLAN_51, "xplan51/StErhVO_Heidberg_51.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(XPLAN_51, SO_Plan, featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("StErhVO_Heidberg")); - assertThat(baseData.getDescription(), is("siehe Lageplan")); - assertThat(baseData.getPlanTypeCode(), is(17200)); - assertThat(baseData.getCreationDate(), is(asDate("2019-06-07"))); + assertEquals("StErhVO_Heidberg", baseData.getPlanName()); + assertEquals("siehe Lageplan", baseData.getDescription()); + assertEquals(17200, baseData.getPlanTypeCode()); + assertEquals(asDate("2019-06-07"), baseData.getCreationDate()); - assertThat(xPlanToEdit.getRasterBasis().size(), is(1)); - assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences().size(), is(0)); + assertThat(xPlanToEdit.getRasterBasis()).hasSize(1); + assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences()).hasSize(0); List<Text> texts = xPlanToEdit.getTexts(); - assertThat(texts.size(), is(3)); + assertThat(texts).hasSize(3); Text firstText = texts.get(0); - assertThat(firstText.getFeatureId(), is("Gml_2413F6CD-7CCF-4F69-B2A9-9C34D6FB5EFA")); - assertThat(firstText.getKey(), is("1")); - assertThat(firstText.getText(), containsString( - "Diese Verordnung gilt für die in der anliegenden Karte durch eine schwarze Linie abgegrenzte")); - assertThat(firstText.getGeoReference(), is(nullValue())); - assertThat(firstText.getRechtscharakter(), is(SO_SONSTIGES)); + assertEquals("Gml_2413F6CD-7CCF-4F69-B2A9-9C34D6FB5EFA", firstText.getFeatureId()); + assertEquals("1", firstText.getKey()); + assertThat(firstText.getText()) + .contains("Diese Verordnung gilt für die in der anliegenden Karte durch eine schwarze Linie abgegrenzte"); + assertNull(firstText.getGeoReference()); + assertEquals(SO_SONSTIGES, firstText.getRechtscharakter()); Text secondText = texts.get(1); - assertThat(secondText.getFeatureId(), is("Gml_A903B546-00F6-47CD-8627-E50D9B0DD250")); - assertThat(secondText.getKey(), is("2")); - assertThat(secondText.getText(), containsString( - "die Errichtung baulicher Anlagen der Genehmigung, und zwar auch dann, wenn nach den bauordnungsrechtlichen Vorschriften")); - assertThat(secondText.getGeoReference(), is(nullValue())); - assertThat(secondText.getRechtscharakter(), is(SO_SONSTIGES)); + assertEquals("Gml_A903B546-00F6-47CD-8627-E50D9B0DD250", secondText.getFeatureId()); + assertEquals("2", secondText.getKey()); + assertThat(secondText.getText()).contains( + "die Errichtung baulicher Anlagen der Genehmigung, und zwar auch dann, wenn nach den bauordnungsrechtlichen Vorschriften"); + assertNull(secondText.getGeoReference()); + assertEquals(SO_SONSTIGES, secondText.getRechtscharakter()); Text thirdText = texts.get(2); - assertThat(thirdText.getFeatureId(), is("Gml_C5992598-EF43-4EA2-AA00-2D431081A4F7")); - assertThat(thirdText.getKey(), is("3")); - assertThat(thirdText.getText(), containsString("Es wird auf Folgendes hingewiesen:")); - assertThat(thirdText.getGeoReference(), is(nullValue())); - assertThat(thirdText.getRechtscharakter(), is(SO_SONSTIGES)); + assertEquals("Gml_C5992598-EF43-4EA2-AA00-2D431081A4F7", thirdText.getFeatureId()); + assertEquals("3", thirdText.getKey()); + assertThat(thirdText.getText()).contains("Es wird auf Folgendes hingewiesen:"); + assertNull(thirdText.getGeoReference()); + assertEquals(SO_SONSTIGES, thirdText.getRechtscharakter()); List<Reference> references = xPlanToEdit.getReferences(); - assertThat(references.size(), is(1)); + assertThat(references).hasSize(1); Reference reference = references.get(0); - assertThat(reference.getGeoReference(), is(nullValue())); - assertThat(reference.getReference(), is("StErhVO_Heidberg.pdf")); - assertThat(reference.getReferenzName(), is(nullValue())); - assertThat(reference.getType(), is(VERORDNUNG)); + assertNull(reference.getGeoReference()); + assertEquals("StErhVO_Heidberg.pdf", reference.getReference()); + assertNull(reference.getReferenzName()); + assertEquals(VERORDNUNG, reference.getType()); - assertThat(xPlanToEdit.getChanges().size(), is(0)); + assertThat(xPlanToEdit.getChanges()).hasSize(0); } @Test - public void testCreateXPlanToEdit_XPlan51_RPlan() throws Exception { + void createXPlanToEditXPlan51RPlan() throws Exception { FeatureCollection featureCollection = readXPlanArchive(XPLAN_51, "xplan51/RROP_Landkreis_Test_51.zip"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_51, RP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); BaseData baseData = xPlanToEdit.getBaseData(); - assertThat(baseData.getPlanName(), is("Regionales Raumordnungsprogramm Landkreis Test 2019")); - assertThat(baseData.getDescription(), is(nullValue())); - assertThat(baseData.getPlanTypeCode(), is(1000)); - assertThat(baseData.getCreationDate(), is(nullValue())); - assertThat(baseData.getMethodCode(), is(3000)); - - assertThat(xPlanToEdit.getRasterBasis().size(), is(1)); - assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences().size(), is(0)); - assertThat(xPlanToEdit.getTexts().size(), is(0)); - assertThat(xPlanToEdit.getReferences().size(), is(0)); - assertThat(xPlanToEdit.getChanges().size(), is(0)); + assertEquals("Regionales Raumordnungsprogramm Landkreis Test 2019", baseData.getPlanName()); + assertNull(baseData.getDescription()); + assertEquals(1000, baseData.getPlanTypeCode()); + assertNull(baseData.getCreationDate()); + assertEquals(3000, baseData.getMethodCode()); + + assertThat(xPlanToEdit.getRasterBasis()).hasSize(1); + assertThat(xPlanToEdit.getRasterBasis().get(0).getRasterReferences()).hasSize(0); + assertThat(xPlanToEdit.getTexts()).hasSize(0); + assertThat(xPlanToEdit.getReferences()).hasSize(0); + assertThat(xPlanToEdit.getChanges()).hasSize(0); } @Test - public void testCreateXPlanToEdit_XPlan54_incompleteRefScan() throws Exception { + void createXPlanToEditXPlan54IncompleteRefScan() throws Exception { FeatureCollection featureCollection = readXPlanGml(XPLAN_54, "xplan54/BPlan002_5-4.gml"); XPlanToEdit xPlanToEdit = factory.createXPlanToEdit(mockXPlan(XPLAN_54, BP_Plan), featureCollection); - assertThat(xPlanToEdit.isHasBereich(), is(true)); + assertTrue(xPlanToEdit.isHasBereich()); List<RasterBasis> rasterBasis = xPlanToEdit.getRasterBasis(); - assertThat(rasterBasis.size(), is(1)); - assertThat(rasterBasis.get(0).getRasterReferences().size(), is(0)); + assertThat(rasterBasis).hasSize(1); + assertThat(rasterBasis.get(0).getRasterReferences()).hasSize(0); } private RasterReference getByType(List<RasterReference> rasterBasisReferences, RasterReferenceType type) { @@ -530,8 +527,7 @@ public class XPlanToEditFactoryTest { return XPlanGmlParserBuilder.newBuilder().build().parseFeatureCollection(xplanGml, xplanVersion); } - private FeatureCollection readXPlanArchive(XPlanVersion xplanVersion, String resource) - throws IOException, XMLStreamException, UnknownCRSException { + private FeatureCollection readXPlanArchive(XPlanVersion xplanVersion, String resource) throws Exception { XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); InputStream inputStream = getClass().getResourceAsStream("/testdata/" + resource); XPlanArchive xPlanArchiveFromZip = archiveCreator.createXPlanArchiveFromZip(resource, inputStream); diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/export/XPlanArtefactExporterTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/export/XPlanArtefactExporterTest.java index 62416e0455..7754ade860 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/export/XPlanArtefactExporterTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/export/XPlanArtefactExporterTest.java @@ -21,9 +21,7 @@ package de.latlon.xplan.manager.export; import static org.apache.commons.io.IOUtils.copyLarge; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -37,45 +35,44 @@ import java.util.zip.GZIPOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import org.deegree.cs.coordinatesystems.ICRS; +import org.deegree.cs.persistence.CRSManager; +import org.deegree.feature.FeatureCollection; +import org.junit.jupiter.api.Test; + import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.commons.feature.XPlanFeatureCollection; import de.latlon.xplan.commons.feature.XPlanGmlParserBuilder; import de.latlon.xplan.core.manager.db.model.Artefact; import de.latlon.xplan.core.manager.db.model.ArtefactId; -import org.deegree.cs.coordinatesystems.ICRS; -import org.deegree.cs.persistence.CRSManager; -import org.deegree.feature.FeatureCollection; -import org.junit.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ */ -public class XPlanArtefactExporterTest { +class XPlanArtefactExporterTest { @Test - public void testExport() throws Exception { + void testExport() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); List<Artefact> artefacts = createArtefacts(); XPlanArtefactExporter.export(outputStream, artefacts); List<String> exportedFiles = readExportedContent(outputStream); - assertEquals(2, exportedFiles.size()); - assertThat(exportedFiles, hasItems("1.xml", "2.xml")); + assertThat(exportedFiles).containsExactlyInAnyOrder("1.xml", "2.xml"); } @Test - public void testExportWithNullManagerConfiguration() throws Exception { + void exportWithNullManagerConfiguration() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); List<Artefact> artefacts = createArtefacts(); XPlanArtefactExporter.export(outputStream, artefacts); List<String> exportedFiles = readExportedContent(outputStream); - assertEquals(2, exportedFiles.size()); - assertThat(exportedFiles, hasItems("1.xml", "2.xml")); + assertThat(exportedFiles).containsExactlyInAnyOrder("1.xml", "2.xml"); } private List<Artefact> createArtefacts() throws Exception { @@ -104,12 +101,6 @@ public class XPlanArtefactExporterTest { return exportedFiles; } - private FeatureCollection readFeatureCollection(String archiveName) throws Exception { - XPlanArchive archive = createArchive(archiveName); - XPlanFeatureCollection xplanFc = readFeatures(archive); - return xplanFc.getFeatures(); - } - private XPlanArchive createArchive(String testArchiveName) throws IOException { XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); InputStream archiveResource = getClass().getResourceAsStream("/testdata/" + testArchiveName); diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/MetadataCouplingHandlerTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/MetadataCouplingHandlerTest.java index c7d2ff4fc2..d29810d5a5 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/MetadataCouplingHandlerTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/MetadataCouplingHandlerTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -30,8 +30,8 @@ import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.cs.persistence.CRSManager; import org.deegree.geometry.Envelope; import org.deegree.geometry.SimpleGeometryFactory; -import org.junit.Test; -import org.xmlunit.matchers.HasXPathMatcher; +import org.junit.jupiter.api.Test; +import org.xmlunit.assertj3.XmlAssert; import java.io.IOException; import java.io.InputStream; @@ -41,8 +41,7 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.Map; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -55,10 +54,10 @@ import static org.mockito.Mockito.when; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class MetadataCouplingHandlerTest { +class MetadataCouplingHandlerTest { @Test - public void testProcessMetadataCoupling() throws Exception { + void testProcessMetadataCoupling() throws Exception { PlanRecordMetadata planRecordMetadata = new PlanRecordMetadata("id", "http://test.de/id"); String planName = "TestPlan1"; CoupledResourceConfiguration config = createConfig(); @@ -70,17 +69,18 @@ public class MetadataCouplingHandlerTest { metadataCouplingHandler.processMetadataCoupling(planId, planName, mockPlanwerkServiceMetadata(planName)); Path directoryToStoreMetadata = config.getDirectoryToStoreMetadata(); - assertThat(numberOfCreatedRecords(directoryToStoreMetadata), is(1l)); + assertEquals(1l, numberOfCreatedRecords(directoryToStoreMetadata)); - assertThat(theRecordIn(directoryToStoreMetadata), - HasXPathMatcher.hasXPath("//gmd:MD_Metadata/gmd:dateStamp/gco:Date").withNamespaceContext(nsContext())); + XmlAssert.assertThat(theRecordIn(directoryToStoreMetadata)) + .withNamespaceContext(nsContext()) + .hasXPath("//gmd:MD_Metadata/gmd:dateStamp/gco:Date"); verify(xPlanDao, times(1)).insertOrReplacePlanWerkWmsMetadata(eq(planId), eq(planName), anyString(), isNull(), isNull()); } @Test - public void testProcessMetadataCoupling_UnavailableRecord() throws Exception { + void processMetadataCouplingUnavailableRecord() throws Exception { String planName = "TestPlan2"; CoupledResourceConfiguration config = createConfig(); XPlanManagerDao xPlanDao = mock(XPlanManagerDao.class); @@ -91,7 +91,7 @@ public class MetadataCouplingHandlerTest { metadataCouplingHandler.processMetadataCoupling(planId, planName, mockPlanwerkServiceMetadata(planName)); Path directoryToStoreMetadata = config.getDirectoryToStoreMetadata(); - assertThat(numberOfCreatedRecords(directoryToStoreMetadata), is(0l)); + assertEquals(0l, numberOfCreatedRecords(directoryToStoreMetadata)); verify(xPlanDao, times(1)).insertOrReplacePlanWerkWmsMetadata(anyInt(), anyString(), isNull(), isNull(), isNull()); } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/ServiceMetadataDocumentWriterTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/ServiceMetadataDocumentWriterTest.java index 402c3b5274..eada663912 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/ServiceMetadataDocumentWriterTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/ServiceMetadataDocumentWriterTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -21,21 +21,18 @@ package de.latlon.xplan.manager.metadata; import org.apache.commons.io.IOUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.xmlunit.assertj3.XmlAssert; import java.io.ByteArrayOutputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.xmlunit.matchers.EvaluateXPathMatcher.hasXPath; - /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class ServiceMetadataDocumentWriterTest { +class ServiceMetadataDocumentWriterTest { private static final String DATE = "2017-01-03"; @@ -44,7 +41,7 @@ public class ServiceMetadataDocumentWriterTest { private static final String TITLE = "Alsterdorf20"; @Test - public void testWriteServiceMetadataDocument() throws Exception { + void testWriteServiceMetadataDocument() throws Exception { byte[] template = IOUtils.toByteArray(ServiceMetadataDocumentWriterTest.class .getResourceAsStream("iso-service-metadata-example-template.xml")); @@ -53,29 +50,36 @@ public class ServiceMetadataDocumentWriterTest { ServiceMetadataDocumentWriter serviceMetadataDocumentWriter = new ServiceMetadataDocumentWriter(template); serviceMetadataDocumentWriter.writeServiceMetadataDocument(properties(), serviceMetadataInstance); - assertThat(serviceMetadataInstance.toString(), - hasXPath("//gmd:MD_Metadata/gmd:dateStamp/gco:Date", is(DATE)).withNamespaceContext(nsContext())); - - assertThat(serviceMetadataInstance.toString(), - hasXPath("//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode", is(TYPE)) - .withNamespaceContext(nsContext())); - - assertThat(serviceMetadataInstance.toString(), - hasXPath("//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode/@codeListValue", is(TYPE)) - .withNamespaceContext(nsContext())); - - assertThat(serviceMetadataInstance.toString(), - hasXPath("//gmd:MD_Metadata/gmd:hierarchyLevelName/gco:CharacterString", is(TYPE)) - .withNamespaceContext(nsContext())); - - assertThat(serviceMetadataInstance.toString(), - hasXPath("//gmd:MD_Metadata/gmd:metadataStandardName/gco:CharacterString", is("NOVALUE")) - .withNamespaceContext(nsContext())); - - assertThat(serviceMetadataInstance.toString(), hasXPath( - "//gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString", - is("WMS Bebauungsplan " + TITLE)) - .withNamespaceContext(nsContext())); + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath("//gmd:MD_Metadata/gmd:dateStamp/gco:Date") + .isEqualTo(DATE); + + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath("//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode") + .isEqualTo(TYPE); + + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath("//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode/@codeListValue") + .isEqualTo(TYPE); + + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath("//gmd:MD_Metadata/gmd:hierarchyLevelName/gco:CharacterString") + .isEqualTo(TYPE); + + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath("//gmd:MD_Metadata/gmd:metadataStandardName/gco:CharacterString") + .isEqualTo("NOVALUE"); + + XmlAssert.assertThat(serviceMetadataInstance.toString()) + .withNamespaceContext(nsContext()) + .valueByXPath( + "//gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString") + .isEqualTo("WMS Bebauungsplan " + TITLE); } private Properties properties() { diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/csw/CswClientTestManual.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/csw/CswClientTestManual.java index 44e7b16088..8f7ff08917 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/csw/CswClientTestManual.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/metadata/csw/CswClientTestManual.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -21,45 +21,45 @@ package de.latlon.xplan.manager.metadata.csw; import de.latlon.xplan.manager.metadata.DataServiceCouplingException; -import org.hamcrest.CoreMatchers; -import org.junit.Test; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class CswClientTestManual { +class CswClientTestManual { private static final String CSW_GET_CAPABILITIESURL = "https://metaver.de/csw?SERVICE=CSW&REQUEST=GetCapabilities"; @Test - public void testRequestMetadataRecord() throws DataServiceCouplingException { + void testRequestMetadataRecord() throws DataServiceCouplingException { CswClient cswClient = new CswClient(CSW_GET_CAPABILITIESURL); PlanRecordMetadata planRecordMetadata = cswClient.requestMetadataRecord("Alsterdorf20"); - assertThat(planRecordMetadata.getRecordId(), is("CC9E9E0D-07AD-4C77-ADAB-AFDA37585633")); - assertThat(planRecordMetadata.getResourceIdentifier(), - is("https://registry.gdi-de.org/id/de.hh/1ad52a0e-9e8b-4a91-b4b3-cf60703cb91b")); + assertEquals("CC9E9E0D-07AD-4C77-ADAB-AFDA37585633", planRecordMetadata.getRecordId()); + assertEquals("https://registry.gdi-de.org/id/de.hh/1ad52a0e-9e8b-4a91-b4b3-cf60703cb91b", + planRecordMetadata.getResourceIdentifier()); } @Test - public void testRequestMetadataRecord_Unknown() throws DataServiceCouplingException { + void requestMetadataRecordUnknown() throws DataServiceCouplingException { CswClient cswClient = new CswClient(CSW_GET_CAPABILITIESURL); PlanRecordMetadata planRecordMetadata = cswClient.requestMetadataRecord("GIBT ES NICHT"); - assertThat(planRecordMetadata, is(CoreMatchers.nullValue())); + assertNull(planRecordMetadata); } @Test - public void testCreateGetRecordByIdRequest() throws DataServiceCouplingException { + void testCreateGetRecordByIdRequest() throws DataServiceCouplingException { CswClient cswClient = new CswClient(CSW_GET_CAPABILITIESURL); String recordId = "CC9E9E0D-07AD-4C77-ADAB-AFDA37585633"; String getRecordByIdRequest = cswClient.createGetRecordByIdRequest(recordId); - assertThat(getRecordByIdRequest, containsString("ID=" + recordId)); + assertThat(getRecordByIdRequest).contains("ID=" + recordId); } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/planwerkwms/PlanwerkServiceMetadataBuilderTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/planwerkwms/PlanwerkServiceMetadataBuilderTest.java index d1e874235b..c82609e8f5 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/planwerkwms/PlanwerkServiceMetadataBuilderTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/planwerkwms/PlanwerkServiceMetadataBuilderTest.java @@ -26,8 +26,8 @@ import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.cs.persistence.CRSManager; import org.deegree.geometry.Envelope; import org.deegree.geometry.SimpleGeometryFactory; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URLEncoder; @@ -36,15 +36,13 @@ import java.nio.file.Files; import java.nio.file.Path; import static de.latlon.xplan.commons.XPlanType.BP_Plan; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class PlanwerkServiceMetadataBuilderTest { +class PlanwerkServiceMetadataBuilderTest { private static final SimpleGeometryFactory GEOMETRY_FACTORY = new SimpleGeometryFactory(); @@ -62,14 +60,14 @@ public class PlanwerkServiceMetadataBuilderTest { private final String style = ""; - @BeforeClass - public static void initCrs() throws UnknownCRSException { + @BeforeAll + static void initCrs() throws UnknownCRSException { EPSG25832 = CRSManager.lookup("EPSG:25832"); EPSG4326 = CRSManager.lookup("EPSG:4326"); } @Test - public void testBuild() throws Exception { + void testBuild() throws Exception { Envelope envelope = GEOMETRY_FACTORY.createEnvelope(10.0, 53.5, 10.5, 54.0, EPSG4326); CoupledResourceConfiguration configuration = createConfig(); @@ -77,25 +75,26 @@ public class PlanwerkServiceMetadataBuilderTest { planName, description, envelope, configuration); PlanwerkServiceMetadata planwerkServiceMetadata = planwerkServiceMetadataBuilder.build(EPSG25832); - assertThat(planwerkServiceMetadata.getTitle(), is(planName)); - assertThat(planwerkServiceMetadata.getDescription(), is(description)); - assertThat(planwerkServiceMetadata.getEnvelope(), is(envelope)); - assertThat(planwerkServiceMetadata.getPlanwerkWmsGetCapabilitiesUrl(), - is(planWerkBaseUrl + "/services/planwerkwms/planname/" + assertEquals(planName, planwerkServiceMetadata.getTitle()); + assertEquals(description, planwerkServiceMetadata.getDescription()); + assertEquals(envelope, planwerkServiceMetadata.getEnvelope()); + assertEquals( + planWerkBaseUrl + "/services/planwerkwms/planname/" + URLEncoder.encode(planName, StandardCharsets.UTF_8.toString()) - + "?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities")); + + "?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities", + planwerkServiceMetadata.getPlanwerkWmsGetCapabilitiesUrl()); String getMapUrl = planwerkServiceMetadata.getPlanwerkWmsGetMapUrl(); - assertThat(getMapUrl, startsWith(planWerkBaseUrl + "/services/planwerkwms/planname/" - + URLEncoder.encode(planName, StandardCharsets.UTF_8.toString()) + "?")); - assertThat(getMapUrl, containsString("LAYERS=" + layer)); - assertThat(getMapUrl, containsString("STYLES=" + style)); - assertThat(getMapUrl, containsString("WIDTH=" + configuration.getPlanWerkWmsGetMapWidth())); - assertThat(getMapUrl, containsString("HEIGHT=" + configuration.getPlanWerkWmsGetMapHeight())); + assertThat(getMapUrl).startsWith(planWerkBaseUrl + "/services/planwerkwms/planname/" + + URLEncoder.encode(planName, StandardCharsets.UTF_8.toString()) + "?"); + assertThat(getMapUrl).contains("LAYERS=" + layer); + assertThat(getMapUrl).contains("STYLES=" + style); + assertThat(getMapUrl).contains("WIDTH=" + configuration.getPlanWerkWmsGetMapWidth()); + assertThat(getMapUrl).contains("HEIGHT=" + configuration.getPlanWerkWmsGetMapHeight()); } @Test - public void testBuild_GetMap_FittingBbox() throws Exception { + void buildGetMapFittingBbox() throws Exception { Envelope envelope = GEOMETRY_FACTORY.createEnvelope(10.0, 53.5, 10.5, 54.0, EPSG4326); CoupledResourceConfiguration configuration = createConfig(); @@ -104,11 +103,11 @@ public class PlanwerkServiceMetadataBuilderTest { PlanwerkServiceMetadata planwerkServiceMetadata = planwerkServiceMetadataBuilder.build(EPSG4326); String getMapUrl = planwerkServiceMetadata.getPlanwerkWmsGetMapUrl(); - assertThat(getMapUrl, containsString("BBOX=" + asString(envelope))); + assertThat(getMapUrl).contains("BBOX=" + asString(envelope)); } @Test - public void testBuild_GetMap_BboxToHeight() throws Exception { + void buildGetMapBboxToHeight() throws Exception { Envelope envelope = GEOMETRY_FACTORY.createEnvelope(10.0, 53.0, 10.5, 54.0, EPSG4326); CoupledResourceConfiguration configuration = createConfig(); @@ -119,11 +118,11 @@ public class PlanwerkServiceMetadataBuilderTest { Envelope expectedBBox = GEOMETRY_FACTORY.createEnvelope(9.75, 53.0, 10.75, 54.0, EPSG4326); String getMapUrl = planwerkServiceMetadata.getPlanwerkWmsGetMapUrl(); - assertThat(getMapUrl, containsString("BBOX=" + asString(expectedBBox))); + assertThat(getMapUrl).contains("BBOX=" + asString(expectedBBox)); } @Test - public void testBuild_GetMap_BboxToWidth() throws Exception { + void buildGetMapBboxToWidth() throws Exception { Envelope envelope = GEOMETRY_FACTORY.createEnvelope(10.0, 53.5, 11, 54.0, EPSG4326); CoupledResourceConfiguration configuration = createConfig(); @@ -134,7 +133,7 @@ public class PlanwerkServiceMetadataBuilderTest { Envelope expectedBBox = GEOMETRY_FACTORY.createEnvelope(10, 53.25, 11, 54.25, EPSG4326); String getMapUrl = planwerkServiceMetadata.getPlanwerkWmsGetMapUrl(); - assertThat(getMapUrl, containsString("BBOX=" + asString(expectedBBox))); + assertThat(getMapUrl).contains("BBOX=" + asString(expectedBBox)); } private String asString(Envelope envelope) { diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageCleanUpManagerTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageCleanUpManagerTest.java index 07ced67fa9..3c627f20d2 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageCleanUpManagerTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageCleanUpManagerTest.java @@ -27,15 +27,14 @@ import com.amazonaws.services.s3.model.S3Object; import com.amazonaws.services.s3.model.S3ObjectInputStream; import com.amazonaws.services.s3.model.S3ObjectSummary; import de.latlon.xplan.manager.storage.StorageEvent; +import org.junit.jupiter.api.Test; import de.latlon.xplan.commons.s3.StorageException; -import org.junit.Test; import org.mockito.ArgumentCaptor; import java.util.Collections; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -45,12 +44,12 @@ import static org.mockito.Mockito.when; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class S3StorageCleanUpManagerTest { +class S3StorageCleanUpManagerTest { private static final String BUCKET_NAME = "xplanbox"; @Test - public void testDeleteRasterFiles() throws StorageException { + void deleteRasterFiles() throws StorageException { AmazonS3 client = spy(AmazonS3.class); ObjectListing objectListing = mock(ObjectListing.class); S3Object object = mock(S3Object.class); @@ -77,7 +76,7 @@ public class S3StorageCleanUpManagerTest { ArgumentCaptor<de.latlon.xplan.commons.s3.S3Object> argument = ArgumentCaptor .forClass(de.latlon.xplan.commons.s3.S3Object.class); verify(storageEvent).addDeletedKey(argument.capture()); - assertThat(argument.getValue().getS3Metadata().getKey(), is("1_test.png")); + assertEquals("1_test.png", argument.getValue().getS3Metadata().getKey()); } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageTestManual.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageTestManual.java index ccb5ce3abc..3fafe25914 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageTestManual.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/storage/s3/S3StorageTestManual.java @@ -8,39 +8,40 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package de.latlon.xplan.manager.storage.s3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.IOException; +import java.io.InputStream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + import de.latlon.xplan.commons.archive.XPlanArchiveContentAccess; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.commons.s3.S3Metadata; import de.latlon.xplan.commons.s3.S3Object; import de.latlon.xplan.commons.s3.S3Storage; +import de.latlon.xplan.commons.s3.StorageException; import de.latlon.xplan.manager.storage.s3.config.AmazonS3TestContext; import de.latlon.xplan.manager.storage.s3.config.S3StorageTestContext; -import de.latlon.xplan.commons.s3.StorageException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; -import java.io.InputStream; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; /** * ATTENTION: Executing this test class can run up the bill for the AWS account @@ -52,42 +53,46 @@ import static org.hamcrest.MatcherAssert.assertThat; * * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -@RunWith(SpringRunner.class) @ContextConfiguration(classes = { AmazonS3TestContext.class, S3StorageTestContext.class }) @ActiveProfiles({ "mock" }) @TestPropertySource("classpath:s3Mock.properties") -public class S3StorageTestManual { +@ExtendWith(SpringExtension.class) +class S3StorageTestManual { @Autowired private S3Storage s3Storage; @Test - public void testInsertObjectAndGetObject() throws IOException, StorageException { + void insertObjectAndGetObject() throws IOException, StorageException { InputStream inputStream = getClass().getResourceAsStream("/testdata/xplan60/Blankenese29_Test_60.zip"); XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); XPlanArchiveContentAccess archive = archiveCreator.createXPlanArchiveFromZip("Blankenese29_Test_60.zip", inputStream); String key = s3Storage.insertObject(1, "Blankenese29.png", archive); - assertThat(key, is("1_Blankenese29.png")); + assertEquals("1_Blankenese29.png", key); S3Metadata metadata = s3Storage.getObjectMetadata(key); - assertThat(metadata.getContentLength(), is(2180090l)); - assertThat(metadata.getContentType(), is("image/png")); + assertEquals(2180090l, metadata.getContentLength()); + assertEquals("image/png", metadata.getContentType()); S3Object object = s3Storage.getObject(key); - assertThat(object.getS3Metadata().getContentLength(), is(2180090l)); - assertThat(object.getS3Metadata().getContentType(), is("image/png")); + assertEquals(2180090l, object.getS3Metadata().getContentLength()); + assertEquals("image/png", object.getS3Metadata().getContentType()); } - @Test(expected = StorageException.class) - public void testGetObject_InvalidKey() throws StorageException { - s3Storage.getObject("invalid"); + @Test + void getObjectInvalidKey() throws StorageException { + assertThrows(StorageException.class, () -> { + s3Storage.getObject("invalid"); + }); } - @Test(expected = StorageException.class) - public void testGetObjectMetadata_InvalidKey() throws StorageException { - s3Storage.getObjectMetadata("invalid"); + @Test + void getObjectMetadataInvalidKey() throws StorageException { + assertThrows(StorageException.class, () -> { + s3Storage.getObjectMetadata("invalid"); + }); } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/transaction/attachment/AttachmentUrlHandlerTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/transaction/attachment/AttachmentUrlHandlerTest.java index 8ddc8e6d21..eb5cb4b8e6 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/transaction/attachment/AttachmentUrlHandlerTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/transaction/attachment/AttachmentUrlHandlerTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -37,23 +37,22 @@ import org.deegree.commons.tom.gml.property.Property; import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.feature.Feature; import org.deegree.feature.FeatureCollection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.xml.stream.XMLStreamException; import java.io.IOException; import java.io.InputStream; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class AttachmentUrlHandlerTest { +class AttachmentUrlHandlerTest { @Test - public void testReplaceRelativeUrls_Xplan40() throws Exception { + void replaceRelativeUrlsXplan40() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan40/BPlan004_4-0.zip"); @@ -64,7 +63,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-0.png" .equals(externalReference.getReferenzUrl()))); @@ -73,12 +72,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl_4(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-0.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-0.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_Xplan41() throws Exception { + void replaceRelativeUrlsXplan41() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan41/BPlan004_4-1.zip"); @@ -89,7 +88,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-1.png" .equals(externalReference.getReferenzUrl()))); @@ -98,12 +97,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl_4(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-1.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_4-1.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_Xplan50() throws Exception { + void replaceRelativeUrlsXplan50() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan50/BPlan004_5-0.zip"); @@ -114,7 +113,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-0.png" .equals(externalReference.getReferenzUrl()))); @@ -123,12 +122,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-0.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-0.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_Xplan51() throws Exception { + void replaceRelativeUrlsXplan51() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan51/BPlan004_5-1.zip"); @@ -139,7 +138,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-1.png" .equals(externalReference.getReferenzUrl()))); @@ -148,12 +147,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-1.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-1.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_Xplan52() throws Exception { + void replaceRelativeUrlsXplan52() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan52/BPlan004_5-2.zip"); @@ -164,7 +163,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-2.png" .equals(externalReference.getReferenzUrl()))); @@ -173,12 +172,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-2.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_5-2.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_Xplan60() throws Exception { + void replaceRelativeUrlsXplan60() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan60/BPlan004_6-0.zip"); @@ -189,7 +188,7 @@ public class AttachmentUrlHandlerTest { List<ExternalReference> externalReferences = externalReferenceScanner.scan(xPlanFeatureCollection.getFeatures()) .getAllReferences(); - assertTrue(externalReferences.size() == 2); + assertEquals(2, externalReferences.size()); assertTrue(externalReferences.stream() .anyMatch(externalReference -> "http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.png" .equals(externalReference.getReferenzUrl()))); @@ -198,12 +197,12 @@ public class AttachmentUrlHandlerTest { .equals(externalReference.getGeoRefUrl()))); GenericXMLElement referenzURL = findExterneReferenzUrl(xPlanFeatureCollection); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pdf" - .equals((referenzURL.getValue()).getAsText())); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pdf", + (referenzURL.getValue()).getAsText()); } @Test - public void testReplaceRelativeUrls_XPlanToEdit() throws Exception { + void replaceRelativeUrlsXPlanToEdit() throws Exception { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); XPlanFeatureCollection xPlanFeatureCollection = getXPlanFeatureCollection("xplan60/BPlan004_6-0.zip"); @@ -212,31 +211,31 @@ public class AttachmentUrlHandlerTest { attachmentUrlHandler.replaceRelativeUrls(10, xPlanToEdit); List<RasterBasis> rasterBasis = xPlanToEdit.getRasterBasis(); - assertTrue(rasterBasis.size() == 1); + assertEquals(1, rasterBasis.size()); List<RasterReference> rasterReferences = rasterBasis.get(0).getRasterReferences(); - assertTrue(rasterReferences.size() == 1); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.png" - .equals(rasterReferences.get(0).getReference())); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pgw" - .equals(rasterReferences.get(0).getGeoReference())); + assertEquals(1, rasterReferences.size()); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.png", + rasterReferences.get(0).getReference()); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pgw", + rasterReferences.get(0).getGeoReference()); List<Reference> references = xPlanToEdit.getReferences(); - assertTrue(references.size() == 1); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pdf" - .equals((references.get(0).getReference()))); + assertEquals(1, references.size()); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/BPlan004_6-0.pdf", + (references.get(0).getReference())); } @Test - public void testReplaceRelativeUrl() { + void testReplaceRelativeUrl() { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); String replacedRelativeUrl = attachmentUrlHandler.replaceRelativeUrl("10", "test.pdf"); - assertTrue("http://test.de/xdokumente/api/v1/dokument/10/test.pdf".equals(replacedRelativeUrl)); + assertEquals("http://test.de/xdokumente/api/v1/dokument/10/test.pdf", replacedRelativeUrl); } @Test - public void testIsSameReference() { + void testIsSameReference() { AttachmentUrlHandler attachmentUrlHandler = new AttachmentUrlHandler( "http://test.de/xdokumente/api/v1/dokument/{planId}/{fileName}"); boolean isSameReference = attachmentUrlHandler.isSameReference("10", "test.pdf", diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/RasterConfigurationSorterTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/RasterConfigurationSorterTest.java index f6fab4a4da..b65d4125c7 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/RasterConfigurationSorterTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/RasterConfigurationSorterTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -21,8 +21,7 @@ package de.latlon.xplan.manager.wmsconfig.raster; import static java.util.Arrays.asList; -import static java.util.Collections.sort; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -36,22 +35,19 @@ import java.util.List; import java.util.Map; import org.deegree.theme.persistence.standard.jaxb.ThemeType.Layer; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> */ -public class RasterConfigurationSorterTest { +class RasterConfigurationSorterTest { private final DateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); private final RasterConfigurationSorter rasterConfigurationSorter = new RasterConfigurationSorter(); @Test - public void testSortByDateInDeegreeOrder() throws Exception { + void testSortByDateInDeegreeOrder() throws Exception { Map<String, Date> unsortedMap = new HashMap<String, Date>(); unsortedMap.put("4", date("2015-03-01")); unsortedMap.put("1", null); @@ -61,12 +57,12 @@ public class RasterConfigurationSorterTest { unsortedMap.put("3", date("1999-01-01")); List<String> sortedStrings = rasterConfigurationSorter.sortByDateInDeegreeOrder(unsortedMap); - assertThat(sortedStrings, hasIdsInOrder()); + assertThat(sortedStrings).isSorted(); } @Test - public void testSortLayers() { - List<Layer> layers = new ArrayList<Layer>(); + void testSortLayers() { + List<Layer> layers = new ArrayList<>(); layers.add(mockLayer("5")); layers.add(mockLayer("7")); layers.add(mockLayer("2")); @@ -74,11 +70,11 @@ public class RasterConfigurationSorterTest { List<String> sortedPlanIds = asList(new String[] { "1", "2", "3", "4", "5", "6", "7" }); rasterConfigurationSorter.sortLayers(layers, sortedPlanIds); - assertThat(layers, hasLayersInOrder()); + assertThat(layers.stream().map(Layer::getValue)).isSorted(); } @Test - public void testSortLayers_MissingEntryInSortedList() { + void sortLayersMissingEntryInSortedList() { List<Layer> layers = new ArrayList<Layer>(); layers.add(mockLayer("7")); layers.add(mockLayer("6")); @@ -87,7 +83,7 @@ public class RasterConfigurationSorterTest { List<String> sortedPlanIds = asList(new String[] { "2", "3", "4", "5", "6", "7" }); rasterConfigurationSorter.sortLayers(layers, sortedPlanIds); - assertThat(layers, hasLayersInOrder()); + assertThat(layers.stream().map(Layer::getValue)).isSorted(); } private Layer mockLayer(String id) { @@ -97,49 +93,6 @@ public class RasterConfigurationSorterTest { return layer; } - private Matcher<? super List<String>> hasIdsInOrder() { - return new TypeSafeMatcher<List<String>>() { - - @Override - public void describeTo(Description description) { - description.appendText("assert items in order"); - } - - @Override - protected boolean matchesSafely(List<String> sortedList) { - ArrayList<String> copy = new ArrayList<String>(sortedList); - sort(copy); - return sortedList.equals(copy); - } - }; - } - - private Matcher<? super List<Layer>> hasLayersInOrder() { - return new TypeSafeMatcher<List<Layer>>() { - - @Override - public void describeTo(Description description) { - description.appendText("assert items in order"); - } - - @Override - protected boolean matchesSafely(List<Layer> sortedList) { - ArrayList<String> values = extractValues(sortedList); - ArrayList<String> copy = new ArrayList<String>(values); - sort(copy); - return values.equals(copy); - } - - private ArrayList<String> extractValues(List<Layer> sortedList) { - ArrayList<String> copy = new ArrayList<String>(); - for (Layer layer : sortedList) { - copy.add(layer.getValue()); - } - return copy; - } - }; - } - private Date date(String date) throws ParseException { return FORMATTER.parse(date); } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTest.java index 1f8e76df11..e26f9c4504 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTest.java @@ -20,10 +20,8 @@ */ package de.latlon.xplan.manager.wmsconfig.raster.storage.s3; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.ArgumentMatchers.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; import java.io.InputStream; @@ -36,18 +34,18 @@ import de.latlon.xplan.commons.archive.ArchiveEntry; import de.latlon.xplan.commons.archive.XPlanArchiveContentAccess; import de.latlon.xplan.commons.s3.StorageException; import de.latlon.xplan.manager.storage.StorageEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -public class S3RasterStorageTest { +class S3RasterStorageTest { private static final String BUCKET_NAME = "xplanbox"; @Test - public void testAddRasterFile() throws StorageException { + void testAddRasterFile() throws StorageException { AmazonS3 client = spy(AmazonS3.class); S3RasterStorage s3RasterStorage = new S3RasterStorage(client, BUCKET_NAME); XPlanArchiveContentAccess archive = mockArchive(); @@ -55,17 +53,17 @@ public class S3RasterStorageTest { StorageEvent storageEvent = mock(StorageEvent.class); String key = s3RasterStorage.addRasterFile(1, "test.png", "test.png.aux.xml", archive, storageEvent); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); - assertThat(key, is("1_test.png")); + assertEquals("1_test.png", key); verify(client, times(2)).doesBucketExistV2(eq(BUCKET_NAME)); verify(client, times(2)).putObject(eq(BUCKET_NAME), captor.capture(), nullable(InputStream.class), any(ObjectMetadata.class)); - assertThat(captor.getAllValues(), hasItems("1_test.png", "1_test.png.aux.xml")); + assertThat(captor.getAllValues()).contains("1_test.png", "1_test.png.aux.xml"); verify(storageEvent).addInsertedKey(eq("1_test.png")); } @Test - public void testDeleteRasterFile() throws StorageException { + void testDeleteRasterFile() throws StorageException { AmazonS3 client = spy(AmazonS3.class); ObjectListing objectListing = mock(ObjectListing.class); S3Object object = mock(S3Object.class); @@ -91,7 +89,7 @@ public class S3RasterStorageTest { ArgumentCaptor<de.latlon.xplan.commons.s3.S3Object> argument = ArgumentCaptor .forClass(de.latlon.xplan.commons.s3.S3Object.class); verify(storageEvent).addDeletedKey(argument.capture()); - assertThat(argument.getValue().getS3Metadata().getKey(), is("1_test.png")); + assertEquals("1_test.png", argument.getValue().getS3Metadata().getKey()); } private XPlanArchiveContentAccess mockArchive() { diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTestManual.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTestManual.java index 09d679f862..9b6b3f457f 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTestManual.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/wmsconfig/raster/storage/s3/S3RasterStorageTestManual.java @@ -8,42 +8,42 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package de.latlon.xplan.manager.wmsconfig.raster.storage.s3; -import de.latlon.xplan.commons.archive.XPlanArchiveContentAccess; -import de.latlon.xplan.commons.archive.XPlanArchiveCreator; -import de.latlon.xplan.manager.storage.StorageEvent; -import de.latlon.xplan.commons.s3.S3Object; -import de.latlon.xplan.manager.storage.s3.config.AmazonS3TestContext; -import de.latlon.xplan.commons.s3.StorageException; -import de.latlon.xplan.manager.wmsconfig.raster.storage.s3.config.AmazonS3RasterStorageContext; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.io.IOException; +import java.io.InputStream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; -import java.io.InputStream; +import org.springframework.test.context.junit.jupiter.SpringExtension; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; +import de.latlon.xplan.commons.archive.XPlanArchiveContentAccess; +import de.latlon.xplan.commons.archive.XPlanArchiveCreator; +import de.latlon.xplan.commons.s3.S3Object; +import de.latlon.xplan.commons.s3.StorageException; +import de.latlon.xplan.manager.storage.StorageEvent; +import de.latlon.xplan.manager.storage.s3.config.AmazonS3TestContext; +import de.latlon.xplan.manager.wmsconfig.raster.storage.s3.config.AmazonS3RasterStorageContext; /** * ATTENTION: Executing this test class can run up the bill for the AWS account @@ -56,17 +56,17 @@ import static org.mockito.Mockito.verify; * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> * @author <a href="mailto:friebe@lat-lon.de">Torsten Friebe</a> */ -@RunWith(SpringRunner.class) @ContextConfiguration(classes = { AmazonS3RasterStorageContext.class, AmazonS3TestContext.class }) @ActiveProfiles({ "mock" }) @TestPropertySource("classpath:s3Mock.properties") -public class S3RasterStorageTestManual { +@ExtendWith(SpringExtension.class) +class S3RasterStorageTestManual { @Autowired private S3RasterStorage s3RasterStorage; @Test - public void testAddRasterFile() throws IOException, StorageException { + void testAddRasterFile() throws IOException, StorageException { InputStream inputStream = getClass().getResourceAsStream("/testdata/xplan60/Blankenese29_Test_60.zip"); XPlanArchiveCreator archiveCreator = new XPlanArchiveCreator(); XPlanArchiveContentAccess archive = archiveCreator.createXPlanArchiveFromZip("Blankenese29_Test_60.zip", @@ -75,12 +75,12 @@ public class S3RasterStorageTestManual { StorageEvent storageEvent = mock(StorageEvent.class); String key = s3RasterStorage.addRasterFile(1, "Blankenese29.png", null, archive, storageEvent); - assertThat(key, is("1_Blankenese29.png")); + assertEquals("1_Blankenese29.png", key); verify(storageEvent).addInsertedKey(eq("1_Blankenese29.png")); } @Test - public void testDeleteRasterFile() throws StorageException, IOException { + void testDeleteRasterFile() throws StorageException, IOException { importRasterFile(); StorageEvent storageEvent = mock(StorageEvent.class); diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceReloaderTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceReloaderTest.java index 610ffb01a0..032eb76223 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceReloaderTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceReloaderTest.java @@ -22,12 +22,11 @@ package de.latlon.xplan.manager.workspace; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link WorkspaceReloader}. @@ -35,48 +34,48 @@ import org.junit.Test; * @author <a href="mailto:stenger@lat-lon.de">Dirk Stenger</a> * @version $Revision: $, $Date: $ */ -public class WorkspaceReloaderTest { +class WorkspaceReloaderTest { @Test - public void testReloadWorkspaceWithInvalidConfigurationShouldFail() { + void reloadWorkspaceWithInvalidConfigurationShouldFail() { WorkspaceReloaderConfiguration configuration = new WorkspaceReloaderConfiguration(); WorkspaceReloader workspaceReloader = new WorkspaceReloader(configuration); boolean isReloadSuccessful = workspaceReloader.reloadWorkspace(1); - assertThat(isReloadSuccessful, is(false)); + assertFalse(isReloadSuccessful); } @Test - public void testReloadWorkspaceWithInvalidUrlShouldFail() { + void reloadWorkspaceWithInvalidUrlShouldFail() { List<String> urlList = singletonList("http://invalid-url"); WorkspaceReloaderConfiguration configuration = new WorkspaceReloaderConfiguration(urlList, null, "user", "password"); WorkspaceReloader workspaceReloader = new WorkspaceReloader(configuration); boolean isReloadSuccessful = workspaceReloader.reloadWorkspace(1); - assertThat(isReloadSuccessful, is(false)); + assertFalse(isReloadSuccessful); } @Test - public void testReloadWorkspaceWithTwoInvalidUrlsShouldFail() { + void reloadWorkspaceWithTwoInvalidUrlsShouldFail() { List<String> urlList = asList("http://invalid-url1", "http://invalid-url2"); WorkspaceReloaderConfiguration configuration = new WorkspaceReloaderConfiguration(urlList, null, "user", "password"); WorkspaceReloader workspaceReloader = new WorkspaceReloader(configuration); boolean isReloadSuccessful = workspaceReloader.reloadWorkspace(1); - assertThat(isReloadSuccessful, is(false)); + assertFalse(isReloadSuccessful); } @Test - public void testReloadWorkspaceWithThreeInvalidUrlsShouldFail() { + void reloadWorkspaceWithThreeInvalidUrlsShouldFail() { List<String> urlList = asList("http://invalid-url1", "http://invalid-url2", "http://invalid-url3"); WorkspaceReloaderConfiguration configuration = new WorkspaceReloaderConfiguration(urlList, "apiKey", "user", "password"); WorkspaceReloader workspaceReloader = new WorkspaceReloader(configuration); boolean isReloadSuccessful = workspaceReloader.reloadWorkspace(1); - assertThat(isReloadSuccessful, is(false)); + assertFalse(isReloadSuccessful); } } diff --git a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceUtilsTest.java b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceUtilsTest.java index 914e0af124..396c9f5804 100644 --- a/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceUtilsTest.java +++ b/xplan-core/xplan-core-manager/src/test/java/de/latlon/xplan/manager/workspace/WorkspaceUtilsTest.java @@ -23,8 +23,9 @@ package de.latlon.xplan.manager.workspace; import static de.latlon.xplan.manager.workspace.WorkspaceUtils.DEFAULT_XPLANSYN_WMS_WORKSPACE; import static de.latlon.xplan.manager.workspace.WorkspaceUtils.findWorkspaceDirectory; import static de.latlon.xplan.manager.workspace.WorkspaceUtils.instantiateWorkspace; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.io.IOException; @@ -32,17 +33,13 @@ import java.nio.file.Files; import java.nio.file.Path; import org.deegree.commons.config.DeegreeWorkspace; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.*; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ */ -public class WorkspaceUtilsTest { +class WorkspaceUtilsTest { private static final String SERVICES = "services"; @@ -60,21 +57,21 @@ public class WorkspaceUtilsTest { private String workspaceName; - @BeforeClass - public static void storeWorkspaceProperty() throws IOException { + @BeforeAll + static void storeWorkspaceProperty() throws IOException { oldWorkspaceRoot = System.getProperty(VAR_WORKSPACE_ROOT); } - @AfterClass - public static void resetWorkspaceRoot() { + @AfterAll + static void resetWorkspaceRoot() { if (oldWorkspaceRoot != null) System.setProperty(VAR_WORKSPACE_ROOT, oldWorkspaceRoot); else System.getProperties().remove(VAR_WORKSPACE_ROOT); } - @Before - public void createTestWorkspaceFrame() throws IOException { + @BeforeEach + void createTestWorkspaceFrame() throws IOException { Path workspaceRoot = createWorkspaceRoot(); Path workspaceDir = createTmpWorkspace(workspaceRoot); Path wmsWorkspaceDir = createWmsWorkspace(workspaceRoot); @@ -87,90 +84,98 @@ public class WorkspaceUtilsTest { } @Test - @Ignore - public void testInstantiateWorkspaceByDirectory() throws Exception { + @Disabled + void instantiateWorkspaceByDirectory() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(workspaceDirectory); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - public void testInstantiateWorkspaceByName() throws Exception { + void instantiateWorkspaceByName() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(workspaceName); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - public void testInstantiateWorkspaceFromDirectory() throws Exception { + void instantiateWorkspaceFromDirectory() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(workspaceName, workspaceDirectory); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - public void testInstantiateWorkspaceFromNameWithUnknownDirectory() throws Exception { + void instantiateWorkspaceFromNameWithUnknownDirectory() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(workspaceName, new File("/UNKOWN/PATH")); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - public void testInstantiateWorkspaceFromNameWithNullDirectory() throws Exception { + void instantiateWorkspaceFromNameWithNullDirectory() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(workspaceName, null); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - @Ignore - public void testInstantiateWorkspaceFromDirectoryWithUnknownName() throws Exception { + @Disabled + void instantiateWorkspaceFromDirectoryWithUnknownName() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace("workspaceName-2", workspaceDirectory); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } @Test - @Ignore - public void testInstantiateWorkspaceFromDirectoryWithNullName() throws Exception { + @Disabled + void instantiateWorkspaceFromDirectoryWithNullName() throws Exception { DeegreeWorkspace workspace = instantiateWorkspace(null, workspaceDirectory); - assertThat(workspace.getLocation(), is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspace.getLocation()); } - @Test(expected = Exception.class) - public void testInstantiateWorkspaceByDirectoryWithNotExistingPath() throws Exception { - instantiateWorkspace(new File("/UNKOWN/PATH")); + @Test + void instantiateWorkspaceByDirectoryWithNotExistingPath() throws Exception { + assertThrows(Exception.class, () -> { + instantiateWorkspace(new File("/UNKOWN/PATH")); + }); } - @Test(expected = Exception.class) - public void testInstantiateWorkspaceByNameWithUnknownName() throws Exception { - instantiateWorkspace("workspaceName-2"); + @Test + void instantiateWorkspaceByNameWithUnknownName() throws Exception { + assertThrows(Exception.class, () -> { + instantiateWorkspace("workspaceName-2"); + }); } - @Test(expected = Exception.class) - public void testInstantiateWorkspaceWithUnknownNameAndNullDirectory() throws Exception { - instantiateWorkspace("workspaceName-2", null); + @Test + void instantiateWorkspaceWithUnknownNameAndNullDirectory() throws Exception { + assertThrows(Exception.class, () -> { + instantiateWorkspace("workspaceName-2", null); + }); } @Test - @Ignore - public void testFindWorkspaceByDirectory() throws Exception { + @Disabled + void findWorkspaceByDirectory() throws Exception { File workspaceDir = findWorkspaceDirectory(workspaceDirectory); - assertThat(workspaceDir, is(workspaceDirectory)); + assertEquals(workspaceDirectory, workspaceDir); } @Test - public void testFindWorkspaceFromNameWithNullDirectory() throws Exception { + void findWorkspaceFromNameWithNullDirectory() throws Exception { File workspaceDir = findWorkspaceDirectory(null); - assertThat(workspaceDir, is(wmsWorkspaceDirectory)); + assertEquals(wmsWorkspaceDirectory, workspaceDir); } - @Test(expected = Exception.class) - public void testFindWorkspaceWithNotExistingPath() throws Exception { - findWorkspaceDirectory(new File("/UNKOWN/PATH")); + @Test + void findWorkspaceWithNotExistingPath() throws Exception { + assertThrows(Exception.class, () -> { + findWorkspaceDirectory(new File("/UNKOWN/PATH")); + }); } private Path createWorkspaceRoot() throws IOException { diff --git a/xplan-core/xplan-core-security/pom.xml b/xplan-core/xplan-core-security/pom.xml index d2391cfb8d..0c1be562b1 100644 --- a/xplan-core/xplan-core-security/pom.xml +++ b/xplan-core/xplan-core-security/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>xplan-core-security</artifactId> @@ -44,6 +45,10 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>de.latlon.product.xplanbox</groupId> + <artifactId>xplan-core-commons</artifactId> + </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-models-jakarta</artifactId> diff --git a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAccessor.java b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAccessor.java new file mode 100644 index 0000000000..40c14d8e0e --- /dev/null +++ b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAccessor.java @@ -0,0 +1,13 @@ +package de.latlon.xplanbox.security.authorization; + +import java.util.Set; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + * @since 8.0 + */ +public interface AgsAccessor { + + Set<String> retrieveAgsFromPlan(String planId); + +} diff --git a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverter.java b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverter.java new file mode 100644 index 0000000000..18ce592c1e --- /dev/null +++ b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverter.java @@ -0,0 +1,41 @@ +package de.latlon.xplanbox.security.authorization; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.core.user.OAuth2UserAuthority; +import org.springframework.security.oauth2.jwt.Jwt; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + * @since 8.0 + */ +public final class AgsAndRealmAccessJwtGrantedAuthoritiesConverter + implements Converter<Jwt, Collection<GrantedAuthority>> { + + @Override + public Collection<GrantedAuthority> convert(Jwt jwt) { + Map<String, List<String>> realmAccess = jwt.getClaim("realm_access"); + + Map<String, Object> attributes = createAttributesWithAgs(jwt); + return realmAccess.get("roles").stream().map(role -> { + if (attributes != null) + return new OAuth2UserAuthority("ROLE_" + role, attributes); + return new SimpleGrantedAuthority("ROLE_" + role); + }).collect(Collectors.toList()); + } + + private Map<String, Object> createAttributesWithAgs(Jwt jwt) { + List<String> agsList = jwt.getClaimAsStringList("ags"); + if (agsList == null || agsList.isEmpty()) + return null; + return Collections.singletonMap("ags", agsList); + } + +} \ No newline at end of file diff --git a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAuthorizer.java b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAuthorizer.java new file mode 100644 index 0000000000..978298c80a --- /dev/null +++ b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsAuthorizer.java @@ -0,0 +1,63 @@ +package de.latlon.xplanbox.security.authorization; + +import javax.xml.stream.XMLStreamException; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.oauth2.core.user.OAuth2UserAuthority; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.stereotype.Component; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + * @since 8.0 + */ +@Component +@ConditionalOnBean(AgsAccessor.class) +public class AgsAuthorizer { + + @Autowired + private AgsAccessor agsAccessor; + + public enum OriginFileType { + + ZIP, GML + + } + + public boolean hasAgs(File body, String fileType, JwtAuthenticationToken authentication) + throws XMLStreamException, IOException { + Set<String> agsFromPlan = parseAgs(body, OriginFileType.valueOf(fileType)); + return hasAgs(agsFromPlan, authentication); + } + + public boolean hasAgs(String planId, JwtAuthenticationToken authentication) { + Set<String> agsFromPlan = agsAccessor.retrieveAgsFromPlan(planId); + return hasAgs(agsFromPlan, authentication); + } + + private static boolean hasAgs(Set<String> agsFromPlan, JwtAuthenticationToken authentication) { + Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities(); + return authorities.stream() + .anyMatch(authority -> authority instanceof OAuth2UserAuthority + && ((OAuth2UserAuthority) authority).getAttributes().containsKey("ags") + && ((List<String>) ((OAuth2UserAuthority) authority).getAttributes().get("ags")).stream() + .anyMatch(agsFromPlan::contains)); + } + + private static Set<String> parseAgs(File gmlOrArchive, OriginFileType originalFileType) + throws XMLStreamException, IOException { + try (FileInputStream archiveOfGmlStream = new FileInputStream(gmlOrArchive)) { + AgsParser agsParser = new AgsParser(); + return agsParser.parseAgs(archiveOfGmlStream, originalFileType); + } + } + +} \ No newline at end of file diff --git a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsParser.java b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsParser.java new file mode 100644 index 0000000000..48a705b97b --- /dev/null +++ b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/authorization/AgsParser.java @@ -0,0 +1,133 @@ +package de.latlon.xplanbox.security.authorization; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.events.XMLEvent; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import de.latlon.xplan.commons.util.XmlUtils; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + */ +public class AgsParser { + + private static final String MAIN_FILE = "xplan.gml"; + + private boolean foundPlan = false; + + private boolean foundXpGemeinde = false; + + private boolean foundAgs = false; + + private int startedElementsFromPlan = 0; + + private int startedElementsFromXpGemeinde = 0; + + private final Set<String> ags = new HashSet<>(); + + public Set<String> parseAgs(InputStream gmlOrArchiveStream, AgsAuthorizer.OriginFileType originFile) + throws XMLStreamException { + try { + switch (originFile) { + case GML -> parseAgsFromGml(gmlOrArchiveStream); + case ZIP -> parseAgsFromArchive(gmlOrArchiveStream); + } + } + catch (IOException e) { + throw new RuntimeException(e); + } + return ags; + } + + private void parseAgsFromArchive(InputStream gmlOrArchiveStream) throws IOException, XMLStreamException { + ZipInputStream zipInputStream = new ZipInputStream(gmlOrArchiveStream, StandardCharsets.UTF_8); + ZipEntry entry; + while ((entry = zipInputStream.getNextEntry()) != null) { + if (MAIN_FILE.equals(entry.getName())) { + parseAgsFromGml(zipInputStream); + } + } + } + + private void parseAgsFromGml(InputStream stream) throws XMLStreamException { + XMLStreamReader reader = null; + try { + reader = XmlUtils.createXMLInputFactory().createXMLStreamReader(stream); + while (reader.hasNext()) { + parse(reader); + reader.next(); + } + } + finally { + closeQuietly(reader); + } + } + + private void parse(XMLStreamReader reader) { + switch (reader.getEventType()) { + case XMLEvent.START_ELEMENT: + foundStartElement(reader.getLocalName()); + break; + case XMLEvent.END_ELEMENT: + foundEndElement(); + break; + case XMLEvent.SPACE: + case XMLEvent.CHARACTERS: + String text = new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()); + foundCharacters(text); + break; + } + } + + private void foundStartElement(String localName) { + if (localName.endsWith("_Plan")) + foundPlan = true; + if (foundPlan) + startedElementsFromPlan++; + if ("XP_Gemeinde".equals(localName)) + foundXpGemeinde = true; + if (foundPlan && foundXpGemeinde && "ags".equals(localName)) + foundAgs = true; + if (foundXpGemeinde) + startedElementsFromXpGemeinde++; + } + + private void foundEndElement() { + if (foundXpGemeinde) + if (startedElementsFromXpGemeinde == 0) + foundXpGemeinde = false; + else + startedElementsFromXpGemeinde--; + if (foundPlan) + if (startedElementsFromPlan == 0) + foundPlan = false; + else + startedElementsFromPlan--; + } + + private void foundCharacters(String text) { + if (foundAgs) { + ags.add(text); + foundAgs = false; + } + } + + private void closeQuietly(XMLStreamReader xmlReader) { + if (xmlReader != null) { + try { + xmlReader.close(); + } + catch (XMLStreamException e) { + // nothing to do + } + } + } + +} diff --git a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/config/OAuth2JwtContext.java b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/config/OAuth2JwtContext.java index 0baa23f902..d790b7f11a 100644 --- a/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/config/OAuth2JwtContext.java +++ b/xplan-core/xplan-core-security/src/main/java/de/latlon/xplanbox/security/config/OAuth2JwtContext.java @@ -20,15 +20,23 @@ */ package de.latlon.xplanbox.security.config; +import static jakarta.servlet.DispatcherType.ERROR; +import static jakarta.servlet.DispatcherType.FORWARD; + +import de.latlon.xplanbox.security.authorization.AgsAndRealmAccessJwtGrantedAuthoritiesConverter; import de.latlon.xplanbox.security.openapi.BearerSecurityOpenApiWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter; import org.springframework.security.web.SecurityFilterChain; /** @@ -36,21 +44,37 @@ import org.springframework.security.web.SecurityFilterChain; * @since 8.0 */ @EnableWebSecurity +@EnableMethodSecurity @Configuration @Profile("enableOAuth2JWT") +@ComponentScan(basePackages = { "de.latlon.xplanbox.security.authorization" }) public class OAuth2JwtContext { private static final Logger LOG = LoggerFactory.getLogger(OAuth2JwtContext.class); + @Autowired + private ApplicationContext applicationContext; + + @Bean + public JwtAuthenticationConverter jwtAuthenticationConverter() { + JwtAuthenticationConverter converter = new JwtAuthenticationConverter(); + converter.setJwtGrantedAuthoritiesConverter(new AgsAndRealmAccessJwtGrantedAuthoritiesConverter()); + return converter; + } + @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthenticationConverter jwtAuthenticationConverter) + throws Exception { LOG.info("Configure security."); - http.authorizeHttpRequests(authorize -> authorize + http.authorizeHttpRequests(authorize -> authorize.dispatcherTypeMatchers(FORWARD, ERROR) + .permitAll() .requestMatchers("/xmanager/api/v1", "/xvalidator/api/v1", "/xdokumente/api/v1", "/api/v2", "/actuator/**", "/internal/api/traceInfo") .permitAll() .anyRequest() - .authenticated()).oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults())); + .authenticated()) + .oauth2ResourceServer( + (oauth2) -> oauth2.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter))); return http.build(); } diff --git a/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverterTest.java b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverterTest.java new file mode 100644 index 0000000000..e41c503cbf --- /dev/null +++ b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAndRealmAccessJwtGrantedAuthoritiesConverterTest.java @@ -0,0 +1,74 @@ +package de.latlon.xplanbox.security.authorization; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.core.user.OAuth2UserAuthority; +import org.springframework.security.oauth2.jwt.Jwt; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + * @since 8.0 + */ +public class AgsAndRealmAccessJwtGrantedAuthoritiesConverterTest { + + public static final String AGS = "0569432"; + + private final AgsAndRealmAccessJwtGrantedAuthoritiesConverter converter = new AgsAndRealmAccessJwtGrantedAuthoritiesConverter(); + + @Test + public void testConvert_notAdminAndNoAgs() { + Jwt jwt = Mockito.mock(Jwt.class); + Map<String, List<String>> realmAccessClaims = Collections.singletonMap("roles", + List.of("default-roles-xplanbox")); + when(jwt.getClaim("realm_access")).thenReturn(realmAccessClaims); + + Collection<GrantedAuthority> authorities = converter.convert(jwt); + assertThat(authorities.size()).isEqualTo(1); + GrantedAuthority authority = authorities.stream().findFirst().get(); + assertThat(authority).isInstanceOf(SimpleGrantedAuthority.class); + assertThat(authority.getAuthority()).isEqualTo("ROLE_default-roles-xplanbox"); + } + + @Test + public void testConvert_AdminAndNoAgs() { + Jwt jwt = Mockito.mock(Jwt.class); + Map<String, List<String>> realmAccessClaims = Collections.singletonMap("roles", + List.of("XPLANBOX_ADMIN", "default-roles-xplanbox")); + when(jwt.getClaim("realm_access")).thenReturn(realmAccessClaims); + + Collection<GrantedAuthority> authorities = converter.convert(jwt); + assertThat(authorities.size()).isEqualTo(2); + authorities.forEach(authority -> assertThat(authority).isInstanceOf(SimpleGrantedAuthority.class)); + authorities.forEach(authority -> assertThat(authority.getAuthority()) + .matches("ROLE_default-roles-xplanbox|ROLE_XPLANBOX_ADMIN")); + } + + @Test + public void testConvert_notAdminAndAgs() { + Jwt jwt = Mockito.mock(Jwt.class); + Map<String, List<String>> realmAccessClaim = Collections.singletonMap("roles", + List.of("default-roles-xplanbox")); + when(jwt.getClaim("realm_access")).thenReturn(realmAccessClaim); + List<String> agsClaim = Collections.singletonList(AGS); + when(jwt.getClaimAsStringList("ags")).thenReturn(agsClaim); + + Collection<GrantedAuthority> authorities = converter.convert(jwt); + assertThat(authorities.size()).isEqualTo(1); + GrantedAuthority authority = authorities.stream().findFirst().get(); + assertThat(authority).isInstanceOf(OAuth2UserAuthority.class); + assertThat(authority.getAuthority()).isEqualTo("ROLE_default-roles-xplanbox"); + assertThat(((List) ((OAuth2UserAuthority) authority).getAttributes().get("ags"))).contains(AGS); + + } + +} diff --git a/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAuthorizerTest.java b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAuthorizerTest.java new file mode 100644 index 0000000000..06a6571afd --- /dev/null +++ b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsAuthorizerTest.java @@ -0,0 +1,91 @@ +package de.latlon.xplanbox.security.authorization; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Collections; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.security.oauth2.core.user.OAuth2UserAuthority; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + * @since 8.0 + */ +@Import(AgsAuthorizerTest.AgsAuthorizerTestContext.class) +@SpringBootTest(classes = AgsAuthorizer.class) +public class AgsAuthorizerTest { + + @Autowired + private AgsAuthorizer agsAuthorizer; + + @TestConfiguration + public static class AgsAuthorizerTestContext { + + @Bean + public AgsAccessor agsAccessor() { + AgsAccessor agsAccessor = mock(AgsAccessor.class); + when(agsAccessor.retrieveAgsFromPlan("1")).thenReturn(Collections.singleton("02000000")); + when(agsAccessor.retrieveAgsFromPlan("2")).thenReturn(Collections.singleton("088623416")); + return agsAccessor; + } + + } + + @Test + public void testHasAgs_gml_matchingAgs() throws Exception { + File file = new File(getClass().getResource("BPlan001_6-0.gml").toURI()); + JwtAuthenticationToken authentication = createAuthentication("02000000"); + boolean hasAgs = agsAuthorizer.hasAgs(file, "GML", authentication); + + assertThat(hasAgs).isTrue(); + } + + @Test + public void testHasAgs_gml_nonMatchingAgs() throws Exception { + File file = new File(getClass().getResource("BPlan001_6-0.gml").toURI()); + JwtAuthenticationToken authentication = createAuthentication("088623416"); + boolean hasAgs = agsAuthorizer.hasAgs(file, "GML", authentication); + + assertThat(hasAgs).isFalse(); + } + + @Test + public void testHasAgs_gml_emptyAgsList() throws Exception { + File file = new File(getClass().getResource("BPlan001_6-0.gml").toURI()); + JwtAuthenticationToken authentication = mock(JwtAuthenticationToken.class); + OAuth2UserAuthority authority = new OAuth2UserAuthority("role", + Collections.singletonMap("ags", Collections.emptyList())); + when(authentication.getAuthorities()).thenReturn(Collections.singletonList(authority)); + + boolean hasAgs = agsAuthorizer.hasAgs(file, "GML", authentication); + + assertThat(hasAgs).isFalse(); + } + + @Test + public void testHasAgs_plaNId_matchingAgs() throws Exception { + + JwtAuthenticationToken authentication = createAuthentication("02000000"); + boolean hasAgs = agsAuthorizer.hasAgs("1", authentication); + + assertThat(hasAgs).isTrue(); + } + + private static JwtAuthenticationToken createAuthentication(String TODO) { + JwtAuthenticationToken authentication = mock(JwtAuthenticationToken.class); + OAuth2UserAuthority authority = new OAuth2UserAuthority("role", + Collections.singletonMap("ags", Collections.singletonList(TODO))); + when(authentication.getAuthorities()).thenReturn(Collections.singletonList(authority)); + return authentication; + } + +} diff --git a/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsParserTest.java b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsParserTest.java new file mode 100644 index 0000000000..b496c96153 --- /dev/null +++ b/xplan-core/xplan-core-security/src/test/java/de/latlon/xplanbox/security/authorization/AgsParserTest.java @@ -0,0 +1,36 @@ +package de.latlon.xplanbox.security.authorization; + +import static de.latlon.xplanbox.security.authorization.AgsAuthorizer.OriginFileType.GML; +import static de.latlon.xplanbox.security.authorization.AgsAuthorizer.OriginFileType.ZIP; +import static org.assertj.core.api.Assertions.assertThat; + +import javax.xml.stream.XMLStreamException; +import java.io.InputStream; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +/** + * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> + */ +public class AgsParserTest { + + private final AgsParser agsParser = new AgsParser(); + + @Test + public void testParseAgs_fromGml() throws XMLStreamException { + InputStream gml = getClass().getResourceAsStream("BPlan001_6-0.gml"); + Set<String> ags = agsParser.parseAgs(gml, GML); + + assertThat(ags).containsExactly("02000000"); + } + + @Test + public void testParseAgs_fromZip() throws XMLStreamException { + InputStream gml = getClass().getResourceAsStream("BPlan001_6-0.zip"); + Set<String> ags = agsParser.parseAgs(gml, ZIP); + + assertThat(ags).containsExactly("02000000"); + } + +} diff --git a/xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.gml b/xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.gml new file mode 100644 index 0000000000..84cc9506c5 --- /dev/null +++ b/xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.gml @@ -0,0 +1,372 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<!-- + Testfälle: + - BP_KomplexeZweckbestGruen + - BP_VeraenderungssperreDaten + - XP_VerbundenerPlanBereich + - Besondere Zweckbestimmung in SO_Strassenverkehr +--> +<xplan:XPlanAuszug xmlns:xplan="http://www.xplanung.de/xplangml/6/0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wfs="http://www.opengis.net/wfs" gml:id="GML_c0490d13-8f76-4583-b348-56957aad0813" xsi:schemaLocation="http://www.xplanung.de/xplangml/6/0 https://repository.gdi-de.org/schemas/de.xleitstelle.xplanung/6.0/XPlanung-Operationen.xsd"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <gml:featureMember> + <xplan:BP_Plan gml:id="GML_bf2168c4-c292-4340-bc50-7a2aa2cab5be"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:name>BPlan001_6-0</xplan:name> + <xplan:beschreibung>Testdaten</xplan:beschreibung> + <xplan:technHerstellDatum>2021-07-01</xplan:technHerstellDatum> + <xplan:wurdeGeaendertVonPlanBereich> + <xplan:XP_VerbundenerPlanBereich> + <xplan:planName>Testplan_Aend</xplan:planName> + <xplan:aenderungsArt>10001</xplan:aenderungsArt> + <xplan:aenderungsdatum>2018-04-03</xplan:aenderungsdatum> + <xplan:bereichNummer>0</xplan:bereichNummer> + </xplan:XP_VerbundenerPlanBereich> + </xplan:wurdeGeaendertVonPlanBereich> + <xplan:erstellungsMassstab>1000</xplan:erstellungsMassstab> + <xplan:raeumlicherGeltungsbereich> + <gml:MultiSurface srsName="EPSG:25832" gml:id="GML_a4b76c05-e841-441f-9284-0d28c0bd2502"> + <gml:surfaceMember> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_63208495-2dad-4690-a072-f31868f7eece"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="5">564984.128 5940442.486 565072.441 5940442.486 565072.441 5940522.630 564984.128 5940522.630 564984.128 5940442.486 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </gml:surfaceMember> + </gml:MultiSurface> + </xplan:raeumlicherGeltungsbereich> + <xplan:gemeinde> + <xplan:XP_Gemeinde> + <xplan:ags>02000000</xplan:ags> + <xplan:gemeindeName>Freie und Hansestadt Hamburg</xplan:gemeindeName> + </xplan:XP_Gemeinde> + </xplan:gemeinde> + <xplan:planArt>10002</xplan:planArt> + <xplan:rechtsstand>3000</xplan:rechtsstand> + <xplan:veraenderungssperre> + <xplan:BP_VeraenderungssperreDaten> + <xplan:startDatum>2021-07-02</xplan:startDatum> + <xplan:endDatum>2021-08-01</xplan:endDatum> + <xplan:verlaengerung>1000</xplan:verlaengerung> + </xplan:BP_VeraenderungssperreDaten> + </xplan:veraenderungssperre> + <xplan:staedtebaulicherVertrag>false</xplan:staedtebaulicherVertrag> + <xplan:erschliessungsVertrag>false</xplan:erschliessungsVertrag> + <xplan:durchfuehrungsVertrag>false</xplan:durchfuehrungsVertrag> + <xplan:gruenordnungsplan>false</xplan:gruenordnungsplan> + <xplan:bereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + </xplan:BP_Plan> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_Bereich gml:id="GML_95a8b21b-8754-4350-9041-213259262fd8"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:nummer>1</xplan:nummer> + <xplan:planinhalt xlink:href="#GML_51e17233-d921-46cb-83b9-af28451186a1" /> + <xplan:planinhalt xlink:href="#GML_fa0eea57-ebb1-4d50-b205-95865d6b9284" /> + <xplan:planinhalt xlink:href="#GML_b5f66983-6732-4cdc-8910-ba4d40a060e8" /> + <xplan:planinhalt xlink:href="#GML_06f9b5b2-8051-4f03-9dc3-50ba956a2670" /> + <xplan:planinhalt xlink:href="#GML_3b987a05-5df3-42ed-ba22-b1b04bf58bf0" /> + <xplan:planinhalt xlink:href="#GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419" /> + <xplan:planinhalt xlink:href="#GML_c8fa8ddd-d5de-4111-9489-03967eec715e" /> + <xplan:praesentationsobjekt xlink:href="#GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3" /> + <xplan:praesentationsobjekt xlink:href="#GML_458852b4-0f35-4405-b3be-90bb70688ddd" /> + <xplan:praesentationsobjekt xlink:href="#GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a" /> + <xplan:praesentationsobjekt xlink:href="#GML_22989f35-59e8-4260-8c60-e706b916a886" /> + <xplan:verfahren>1000</xplan:verfahren> + <xplan:gehoertZuPlan xlink:href="#GML_bf2168c4-c292-4340-bc50-7a2aa2cab5be" /> + </xplan:BP_Bereich> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_WohngebaeudeFlaeche gml:id="GML_51e17233-d921-46cb-83b9-af28451186a1"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565011.438 5940447.733</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_22989f35-59e8-4260-8c60-e706b916a886" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_2ada5f26-230c-4dfe-ac97-f62ba56a6f3c"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="15">565065.689 5940482.457 565064.406 5940485.989 565055.484 5940510.564 565050.619 5940511.714 565048.163 5940509.388 565024.500 5940486.984 565011.438 5940474.619 565016.424 5940469.350 565020.516 5940465.024 565028.611 5940456.469 565029.337 5940457.156 565038.252 5940447.733 565053.250 5940456.591 565072.441 5940463.556 565065.689 5940482.457 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:typ>1000</xplan:typ> + </xplan:BP_WohngebaeudeFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_GruenFlaeche gml:id="GML_fa0eea57-ebb1-4d50-b205-95865d6b9284"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940468.040</gml:lowerCorner> + <gml:upperCorner>565042.005 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_1c92b1db-bd5f-478c-a034-3b5e7bf9a81f"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="5">565042.005 5940522.630 564984.128 5940522.630 564984.128 5940468.040 565022.175 5940504.055 565042.005 5940522.630 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:zweckbestimmung> + <xplan:BP_KomplexeZweckbestGruen> + <xplan:allgemein>2700</xplan:allgemein> + <xplan:aufschrift>Grüne Hölle</xplan:aufschrift> + </xplan:BP_KomplexeZweckbestGruen> + </xplan:zweckbestimmung> + <xplan:nutzungsform>2000</xplan:nutzungsform> + </xplan:BP_GruenFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_BaugebietsTeilFlaeche gml:id="GML_b5f66983-6732-4cdc-8910-ba4d40a060e8"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565038.252 5940474.619</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_9315e58c-ee79-4e4a-85fa-993709ccfc29"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="12">565029.337 5940457.156 565028.611 5940456.469 565020.516 5940465.024 565016.424 5940469.350 565011.438 5940474.619 564999.828 5940463.629 564988.215 5940452.640 564984.128 5940448.773 564984.128 5940442.486 565034.802 5940442.486 565038.252 5940447.733 565029.337 5940457.156 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:besondereArtDerBaulNutzung>1450</xplan:besondereArtDerBaulNutzung> + </xplan:BP_BaugebietsTeilFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:SO_Strassenverkehr gml:id="GML_06f9b5b2-8051-4f03-9dc3-50ba956a2670"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940448.773</gml:lowerCorner> + <gml:upperCorner>565055.484 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_7f6be5de-9acd-42b6-a664-1e8de042e532"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="13">565048.163 5940509.388 565050.619 5940511.714 565055.484 5940510.564 565045.164 5940522.630 565042.005 5940522.630 565022.175 5940504.055 564984.128 5940468.040 564984.128 5940448.773 564988.215 5940452.640 564999.828 5940463.629 565011.438 5940474.619 565024.500 5940486.984 565048.163 5940509.388 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:nordwinkel uom="grad">0.000000</xplan:nordwinkel> + <xplan:artDerFestlegung> + <xplan:SO_KomplexeZweckbestStrassenverkehr> + <xplan:allgemein>3500</xplan:allgemein> + </xplan:SO_KomplexeZweckbestStrassenverkehr> + </xplan:artDerFestlegung> + <xplan:nutzungsform>2000</xplan:nutzungsform> + <xplan:hatDarstellungMitBesondZweckbest>true</xplan:hatDarstellungMitBesondZweckbest> + </xplan:SO_Strassenverkehr> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_GruenFlaeche gml:id="GML_3b987a05-5df3-42ed-ba22-b1b04bf58bf0"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565045.164 5940463.858</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_27b9cf2e-4f08-4db9-9be5-9edd59ad5f0e"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="7">565072.441 5940522.630 565045.164 5940522.630 565055.484 5940510.564 565064.406 5940485.989 565065.689 5940482.457 565072.441 5940463.858 565072.441 5940522.630 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:zweckbestimmung> + <xplan:BP_KomplexeZweckbestGruen> + <xplan:allgemein>2700</xplan:allgemein> + </xplan:BP_KomplexeZweckbestGruen> + </xplan:zweckbestimmung> + <xplan:nutzungsform>1000</xplan:nutzungsform> + </xplan:BP_GruenFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_BaugebietsTeilFlaeche gml:id="GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565034.802 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940463.556</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_458852b4-0f35-4405-b3be-90bb70688ddd" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_fd59b568-132d-4ff7-9549-d387f8c629d1"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="6">565072.441 5940463.556 565053.250 5940456.591 565038.252 5940447.733 565034.802 5940442.486 565072.441 5940442.486 565072.441 5940463.556 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:besondereArtDerBaulNutzung>1700</xplan:besondereArtDerBaulNutzung> + </xplan:BP_BaugebietsTeilFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:SO_Gebiet gml:id="GML_c8fa8ddd-d5de-4111-9489-03967eec715e"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_bb3db696-52cd-49d6-96fb-034ab3e910da"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="16">565065.689 5940482.457 565064.406 5940485.989 565055.484 5940510.564 565050.619 5940511.714 565048.163 5940509.388 565024.500 5940486.984 565011.438 5940474.619 564999.828 5940463.629 564988.215 5940452.640 564984.128 5940448.773 564984.128 5940442.486 565034.802 5940442.486 565038.252 5940447.733 565053.250 5940456.591 565072.441 5940463.556 565065.689 5940482.457 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>false</xplan:flaechenschluss> + <xplan:gemeinde> + <xplan:XP_Gemeinde> + <xplan:ags>02000001</xplan:ags> + <xplan:gemeindeName>Freie und Hansestadt Hamburg</xplan:gemeindeName> + </xplan:XP_Gemeinde> + </xplan:gemeinde> + <xplan:gebietsArt>2400</xplan:gebietsArt> + </xplan:SO_Gebiet> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565027.244 5940470.916</gml:lowerCorner> + <gml:upperCorner>565028.244 5940471.916</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>gebietsArt[0]</xplan:art> + <xplan:art>gemeinde[0]/gemeindeName[0]</xplan:art> + <xplan:art>gemeinde[0]/ags[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_c8fa8ddd-d5de-4111-9489-03967eec715e" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_9c0ff9d5-5736-4e21-a30c-ee5c459f7c78"> + <gml:pos>565027.244 5940470.916</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.00</xplan:drehwinkel> + <xplan:skalierung>1</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_458852b4-0f35-4405-b3be-90bb70688ddd"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565063.749 5940451.169</gml:lowerCorner> + <gml:upperCorner>565064.749 5940451.169</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_51c5093a-5964-41f6-8f3a-a07973982464"> + <gml:pos>565063.749 5940451.169</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565010.917 5940455.804</gml:lowerCorner> + <gml:upperCorner>565011.917 5940455.804</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_b5f66983-6732-4cdc-8910-ba4d40a060e8" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_3424ae3a-6635-45ac-9242-3089daeaf9db"> + <gml:pos>565010.917 5940455.804</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_22989f35-59e8-4260-8c60-e706b916a886"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565043.676 5940476.202</gml:lowerCorner> + <gml:upperCorner>565044.676 5940476.202</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_51e17233-d921-46cb-83b9-af28451186a1" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_27888432-2c29-41c0-b6bc-d857207dced4"> + <gml:pos>565043.676 5940476.202</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> +</xplan:XPlanAuszug> \ No newline at end of file diff --git a/xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.zip b/xplan-core/xplan-core-security/src/test/resources/de/latlon/xplanbox/security/authorization/BPlan001_6-0.zip new file mode 100644 index 0000000000000000000000000000000000000000..384cb16f5781e687914b9d7019cb5195fcea65ff GIT binary patch literal 3337 zcma)9byO3M+8$$+gh-2kGz_G>nKVd`kQ_)iQk&E!Am}7UD~$s|Qjt#SPATaSm^30C z*WY)(d+z=7KF@jMocBD>`}bp@gAbws5dWo-PXQG0|IpV307w9=0Jx8botL1qr-uoY z96&VR<Y#}c+0P#Jw*ug#06fqZJ^=84ZP#icaju58W#q{s#H0d(#|i+-**NYr%np9n zlMmn?!cH6lKt+zahH{)K)|-e6vgTjbHl@)@iJF-C$s2Qb?~tlzctp`>GMjQsGN9|7 zj1ouD^GQcUleYfH&W?%KIvpvo6J0oeYgJ7>9z>pTNs`Ggy^jyA6tA6b{+Ny2M2@a+ zS8yjiw6;-gz2(uG*E*-xwP`|})=nO=`<m^g>Cm@GvHGNzSvTz7^f~@0m~!0q$86FI z4$SLVdw{~qL4%ASqqJr%|BH4<L5h)#LqXe=XA2G`3O0g}2~Is8?{N5OO|O4;BhA$D zVwSUQc$9(6LJ6sX|B+wu-ns0pXLEX6`@|L2O(`pzzN@RxBM^bWnF!>LRC$?R2Y-Iz zWKa0OI3Ah9d_EbaL+`s+P@bNW-=ZOvZ>E*mvQKP#vB+mR7-QsS`o~M{H(WEp{)v-P zYuF!2`5>Lx)vxmCQBQSi_46&OTyI$vNml2H|BI80$wo@CD1k%FTOf)dO;J=aDTcHQ zzf2&tlc)<3l4zzMTzx0N@Ld;PqZrunIc5KR7hgQu<m8*>48v2ivJX?~Bg>m6tE=on zOy+~8b5G!KQ)Y@QWhJB*R6npdC}j@UB!BMw(`fLMIO*l8%H((P8`@!6REqx5qgxxH zZ<@Ck8@sb4Q3T_z95XT8B|2%>jwvX+p?a9MXuN^U${V}xq8=<<axQI~*WA|XD~%6R z8>>1WL8g)ZS)J)<s(YcV`$)CTcxh|lFED1JOV+PqVSJ~1nvQJG*vohmrmOloflY<Y zghnLC&f#&KVQ%r1`1e;2YHROZK0pi%g(Q%NB6XQ(XRQ6gvxXE4D{Ict&-uS~ERulY zT>^GU@OvXSkr0438bJcDi7Xk4(c53_ZI9Z-1pz7wn(=$f()`|lA=1j}9yDacyT$cZ z&Qn?Sj1uS^Q&&>DIm^$G`g@>VuTTN28}Qu*3$ydJ1wVMdliS=P3L{4ro=xlb^3Y3d zq1?Uahm&!PYC7A_smaW6oPS(_#pLPsPpU`2{oxM_^ODIbway%f(Hf~F*SLzz19xI& z<V4|*q}cMj8wFZQ+UWt1f8)*|mm1jZ!rAKmpX~snPVecb*bY1W-Q@@;Zc4U|UM+RX zI@3s+l*-xEe#!?rGAu{CO;bydytuXulOwy&+TPj7190jSU)8dj7?LOqp^yefAB%KZ zx7sQU)_2KXDZi7}RdT)QeQDcOJTbepmb(4Nft9uS&F}oo%>g)W{QY(tlZtZms(=4S zjv0wrl@FK=LM(T%w)%T1Z8xObhUC|#S@P`?0(HrvJrBL2;F_v!irPKTIkORd3gL<F zTzW5@{XrHaMs_=BZ`lqrBI5IK{(0^fPi6n#Z|@YeM7h?Hz)#lYvNixNKj;od3Z6Qn zW3z{m5dW<qkMOM<*#V^oWLVEFj}J@TeRw<Qru^@It<_C|mx~Fumm&47AEpm}<#|RB zId<77|Illmlo6(38DrtK#CXg}2$Pv&+K%Zak7Y+^c5x5;*mT@+j0+_T<5>ckW7|Js zAX4jOXaqKCzPbixP!xZ$f}m=Y7s`<;ay56*kGFPSL417`=?ERE>}}~uc|FBf#T7q1 zkXjxW78H+z#>p2yPojoNjNy()xFY$>3-UTy@B0ukQEwHrQ|j^_g3X|#y^jl}=Monv zEImIjC{`;V4<*@Zsf{V#k2-6=AUOoKD*|z4;IS#|2|+ctyr-Gj+t{rPJf1kv_fw3? z^5v7r%G(x0O$}vU*rJik7qN&4s5+zEM+7ocBzL?W!g$9)%@<rpTZrYWg}TByBVS&b zf)qJb^T;t!(6O7-{V8)8k9RQ@S`)&ehKXE*JZe`ol03fGqs}iVPK(!4pgkjX-^CnU zi-~6lpySpAi*~}C*ada{EmMY(QfGQ>?l6_7oFt<C7VAWYTLZnwsA9`cWRBPZ0_If9 zXa+VAn44BOfJ=Loj&ko66iBuyDDX*M(e_<<<0*cBHK!q^2+<0WCioeKK<9`#5i0#U z7CU?%WI9}zoXNOcj~Ri;?0h|p#ZMRJZhM?s(r`J5nvF_ED!4@76Vqc=V<nK9c_k`t zVN|+bnrXykBI8<~2^yee=%c)mPOmXkbpdxFpT~q^2qkb~{+<@WJ3Ao+hU;koCI(w_ zV{9f-Y@Oabnx}y4@X}!v6$5L=R4C~cAm4`vzywn3AqFtv+lYlz1AsyY*ZSfBX?*a$ zpmBM4+`BGx^a`+%T|E;|Zji2AI})A7m4gtTtHAle%f+r+c%NCtTkKz)gnlVC>&|+F z3&aUbn*NTtql!n(`cjPoXF$M9_1z_goc*W+kDqa1-b?$ELd#VvW#ajxIv(sN0ppjb z!(43}g5L~ux?-nLFmNanA7K|uVt=<zcj2u91Ue^L;>4}Me${ZFe<baTTjAgugH!{- zR(ZjkB2}e@-RvWI^=%DNJZ<Unl(q>iF^D;SVKo(>9V`j$#{hQYq9MG1OfbPCr@;+E z3jMBg0^2{&M&H(I*ReOt+n%v_CzI_g2fVwietPNBt(aNnE!G!`?@1>0$xuY#H##7D zgcNp~A#xdd8PIo^o|zsTeu@kMp!P|BO`>zz#Fb(QSaOC*adxlvksAp_ut6m+@=L?9 zD-pc3$Ty7k<f5s6y&Pi1PwpR)2ccd=wfN)7>c|&Q;;%<P!8~0hG7aNFu~dWd$e(>N zdpt<h)_|o|3c8wCOFVb!D3Y*(<3p~ae9T^!(XUEB99`=&(f+R5IlV3LI$GGj)lJ;J zvb>HcD1N|Qi(#_dl#~z(<422*@$r+oH`WKqzMx#_o(ML3ddxVg7^rsh0iDE_pvYTs z^VUt!^QD1bA`jtswBerI#+Uf}c***8YskxCf;%ET;)(L(nqZ|iJ~9qXi+J67S7xAk z?-oM<Gj{{WS9pS|SV1yRt#9Wks4RmkU20{BgAG=R3Njog1%~g?n*8J#OiDk=h_3(B zwwj~-Ry0FSW29=eU;x0IwC`@7P2FuNl&#Tqp_a&2*-ZcPbYC$*ej^vS!2t_$L<Y6( z1(sh#!IXrX2r<ItrKfz%7M(@+G)ccv`i{%8=EvP-Io60WYqgu{Fp0)6c4?|b_!_jI zoShK|KU`Vk*a>B_iT(zsY|tp-;;2qRDIkDFmMuk1Alv7C4$T(Xdi3vVCS*<;rh$P* zmumr0?MuK@t$BOlYC!MK=Til;X2m{$ZHr{z%<;ko#4_~RM5{`7C9{7y>2gFyhGxZD zev4jX7IZVji)K%~It*~(GMOJ?lg0e;Wa(w%IEpJRXDhZx$wT-9%Fs^LTI&U;{S+^j zwSnzt=}&D-7Q3Kz7~K<%xa)>3ajF4zw{wn^+h#tg^z9kX8XigrOG(YKZ;8q}br}V- z|M{|X?!3OmK2iS=X&w(@f3!*T9z1qc<en1HO3F$Tv>koS^#+KQ#_u?Gr0k>Atl`p7 z4;fRrI??IIm?d(krD75Xhv-wJ;zNL=Vb)rOQN!^zi83YPfvp{~>*|xvP&K9Qu9Tkg zgr(i=AJ6P_MOq{tlXSX1Z8tP!<zmM-?f#15)vcWD5nPEGSvBha2-Oe&5@aGfJ?`Ch zq15lpse24oV$Ac9S~K;lST>4I3nl=k<1(a_{FNBwKznf=>#oa&Q^{t)9q{usVl_t{ zl36gKm$+aB9?0`Y|Ej{2+1tEE5}1%#?THKI`1Zcy;lUX2W32TZw<^=9gO8JK6041i z4<E*c`&uv^gh_WAVjpS99}w8bQDFxL-VGln_|g*Cu@aTu&3;ifnQ|S<8F`=iZG@!X zW{2ADZjhqo>+8?w!C9R{o5pkd$$_5MK1B-`d6<=4hXd(efUgitw{i`X-_n3D3fN?T z9*y=2XGe#u?gdW^Y42^eWJb0vhQ!uURq|4iaB`d#`{n{|wfaGg-Jv~C);JpWcbkHE z!X0iEwmyycUZo}1HPrL9qiCw+&V<-Hv|G;h6_lbHb8au*ite`AMe%lkrrC^=4cDI) zmj*IEuBz`2|LcOjWjPKQ{Huo8Gl}C~u*zG6DTcY<I(nG*(cd<264jpmwq?`=-v<zq z7r#7v0E7`!v-2aAePJrj73kJyg@@RyAf9xO8~xAcw|E9RM8uDBeeS7|0RaCb5Ca`N pAPxS1(#e0{{z)hQ##huo+y9(Z40H$x{}JH*rP<$^`S%?F@Gm7kKtKQh literal 0 HcmV?d00001 diff --git a/xplan-core/xplan-core-synthesizer/src/main/java/de/latlon/xplan/manager/synthesizer/expression/flatten/xp/XpExterneReferenzFlattener.java b/xplan-core/xplan-core-synthesizer/src/main/java/de/latlon/xplan/manager/synthesizer/expression/flatten/xp/XpExterneReferenzFlattener.java index 2d4de987c0..32940d22ef 100644 --- a/xplan-core/xplan-core-synthesizer/src/main/java/de/latlon/xplan/manager/synthesizer/expression/flatten/xp/XpExterneReferenzFlattener.java +++ b/xplan-core/xplan-core-synthesizer/src/main/java/de/latlon/xplan/manager/synthesizer/expression/flatten/xp/XpExterneReferenzFlattener.java @@ -20,6 +20,8 @@ */ package de.latlon.xplan.manager.synthesizer.expression.flatten.xp; +import static de.latlon.xplan.commons.util.XPlanVersionUtils.determineBaseVersion; + import de.latlon.xplan.commons.XPlanVersion; import de.latlon.xplan.manager.dictionary.XPlanDictionaries; import de.latlon.xplan.manager.dictionary.XPlanEnumerationFactory; @@ -29,8 +31,6 @@ import org.deegree.commons.tom.TypedObjectNode; import org.deegree.feature.Feature; import org.deegree.feature.property.GenericProperty; -import static de.latlon.xplan.commons.util.XPlanVersionUtils.determineBaseVersion; - /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ @@ -77,10 +77,7 @@ public class XpExterneReferenzFlattener extends AbstractFlattener { extRef.append(escape(georefUrlString)); } else { - extRef.append("/getAttachment?featureID=") - .append(fid) - .append("&filename=") - .append(escape(georefUrlString)); + appendRelativeGetAttachmenUrl(extRef, georefUrlString); } extRef.append(" | "); if (typ != null) @@ -91,6 +88,14 @@ public class XpExterneReferenzFlattener extends AbstractFlattener { } } + /** + * @deprecated method will be removed in a future version. + */ + @Deprecated + private void appendRelativeGetAttachmenUrl(StringBuilder extRef, String georefUrlString) { + extRef.append("/getAttachment?featureID=").append(fid).append("&filename=").append(escape(georefUrlString)); + } + private String translateTyp(TypedObjectNode xpExterneReferenz) { XPlanVersion version = determineBaseVersion(contextFeature.getName()); TypedObjectNode typ = getPropertyValue(xpExterneReferenz, "typ"); diff --git a/xplan-core/xplan-core-validator-events/src/main/java/de/latlon/core/validator/events/v1/XPlanPublicV1Event.java b/xplan-core/xplan-core-validator-events/src/main/java/de/latlon/core/validator/events/v1/XPlanPublicV1Event.java index d4e6cb97be..6c50394464 100644 --- a/xplan-core/xplan-core-validator-events/src/main/java/de/latlon/core/validator/events/v1/XPlanPublicV1Event.java +++ b/xplan-core/xplan-core-validator-events/src/main/java/de/latlon/core/validator/events/v1/XPlanPublicV1Event.java @@ -20,6 +20,10 @@ public class XPlanPublicV1Event implements XPlanPublicEvent { SYNTACTIC_VALIDATION_FINISHED("validation.syntaktisch"), + REFERENCES_STARTED("validation.referenzen"), + + REFERENCES_FINISHED("validation.referenzen"), + GEOMETRIC_VALIDATION_STARTED("validation.geometrisch"), GEOMETRIC_VALIDATION_FINISHED("validation.geometrisch"), diff --git a/xplan-core/xplan-core-validator-events/src/test/java/de/latlon/core/validator/events/v1/XPlanPublicV1EventTest.java b/xplan-core/xplan-core-validator-events/src/test/java/de/latlon/core/validator/events/v1/XPlanPublicV1EventTest.java index f8d07c401f..890260f358 100644 --- a/xplan-core/xplan-core-validator-events/src/test/java/de/latlon/core/validator/events/v1/XPlanPublicV1EventTest.java +++ b/xplan-core/xplan-core-validator-events/src/test/java/de/latlon/core/validator/events/v1/XPlanPublicV1EventTest.java @@ -60,4 +60,28 @@ class XPlanPublicV1EventTest { assertThat(json).isEqualTo(expected); } + @Test + void jsonSerializeReferencedStarted() throws Exception { + XPlanPublicV1Event event = new XPlanPublicV1Event(EventType.REFERENCES_STARTED, "uuid1"); + + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(event); + + String expected = "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_STARTED\",\"uuid\":\"uuid1\",\"valid\":null,\"error\":null}"; + + assertThat(json).isEqualTo(expected); + } + + @Test + void jsonSerializeReferencesFinished() throws Exception { + XPlanPublicV1Event event = new XPlanPublicV1Event(EventType.REFERENCES_FINISHED, "uuid1", true); + + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(event); + + String expected = "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_FINISHED\",\"uuid\":\"uuid1\",\"valid\":true,\"error\":null}"; + + assertThat(json).isEqualTo(expected); + } + } diff --git a/xplan-core/xplan-core-validator/pom.xml b/xplan-core/xplan-core-validator/pom.xml index 0c84a2b827..c6ee29b285 100644 --- a/xplan-core/xplan-core-validator/pom.xml +++ b/xplan-core/xplan-core-validator/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>xplan-core-validator</artifactId> <packaging>jar</packaging> @@ -17,10 +18,10 @@ <groupId>org.jvnet.jaxb</groupId> <artifactId>jaxb-maven-plugin</artifactId> <configuration> - <!-- - <bindingDirectory>${project.basedir}/src/xjc</bindingDirectory> - <schemaDirectory>${project.basedir}/src/main/resources/schemas</schemaDirectory> - <outputDirectory>${project.build.directory}/generated-sources/jaxb</outputDirectory> + <!-- + <bindingDirectory>${project.basedir}/src/xjc</bindingDirectory> + <schemaDirectory>${project.basedir}/src/main/resources/schemas</schemaDirectory> + <outputDirectory>${project.build.directory}/generated-sources/jaxb</outputDirectory> --> <generatePackage>de.latlon.xplan.validator.report</generatePackage> </configuration> @@ -136,13 +137,18 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> <scope>test</scope> </dependency> <dependency> @@ -160,11 +166,6 @@ <artifactId>xmlunit-matchers</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>pl.pragmatists</groupId> - <artifactId>JUnitParams</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> diff --git a/xplan-core/xplan-core-validator/src/main/java/de/latlon/xplan/validator/XPlanGmlValidation.java b/xplan-core/xplan-core-validator/src/main/java/de/latlon/xplan/validator/XPlanGmlValidation.java index 7ac66b8051..4ca7690031 100644 --- a/xplan-core/xplan-core-validator/src/main/java/de/latlon/xplan/validator/XPlanGmlValidation.java +++ b/xplan-core/xplan-core-validator/src/main/java/de/latlon/xplan/validator/XPlanGmlValidation.java @@ -2,6 +2,7 @@ package de.latlon.xplan.validator; import static de.latlon.xplan.validator.report.SkipCode.SKIPPED; import static de.latlon.xplan.validator.web.shared.ValidationType.GEOMETRIC; +import static de.latlon.xplan.validator.web.shared.ValidationType.REFERENCES; import javax.xml.stream.XMLStreamException; import java.util.Map; @@ -13,6 +14,7 @@ import de.latlon.xplan.commons.feature.XPlanGmlParserBuilder; import de.latlon.xplan.validator.geometric.GeometricValidator; import de.latlon.xplan.validator.geometric.report.GeometricValidatorResult; import de.latlon.xplan.validator.listener.ValidationProcessListener; +import de.latlon.xplan.validator.planinfo.PlanInfo; import de.latlon.xplan.validator.planinfo.PlanInfoParser; import de.latlon.xplan.validator.planinfo.PlanInfoReport; import de.latlon.xplan.validator.report.ValidatorReport; @@ -123,7 +125,10 @@ public class XPlanGmlValidation { private void parseGmlValidation(String uuid, ValidatorReport report, boolean skipGeometric) throws ValidatorException { parse(); + validationProcessListener.validationPartStarted(uuid, REFERENCES); this.planInfoReport = planInfoParser.parsePlanInfo(this); + validationProcessListener.validationPartFinished(uuid, REFERENCES, + this.planInfoReport.getPlanInfos().values().stream().allMatch(PlanInfo::isValid)); report.setPlanInfoReport(planInfoReport); if (skipGeometric) { report.getPlanInfoReport() diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanGmlValidationTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanGmlValidationTest.java index 2a9ad39393..87c0dd06b4 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanGmlValidationTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanGmlValidationTest.java @@ -22,7 +22,7 @@ import de.latlon.xplan.validator.listener.InactiveValidationProcessListener; import de.latlon.xplan.validator.planinfo.PlanInfoParser; import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.web.shared.ValidationSettings; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanValidatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanValidatorTest.java index c01d591241..716565e388 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanValidatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/XPlanValidatorTest.java @@ -26,7 +26,8 @@ import static de.latlon.xplan.validator.web.shared.ValidationType.SYNTACTIC; import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; @@ -78,9 +79,9 @@ import org.apache.commons.io.IOUtils; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for <link>XPlanValidator</link> @@ -107,7 +108,7 @@ public class XPlanValidatorTest { private static File planToValidate; - @Before + @BeforeEach public void resetMocks() { geoVal = mockGeometricValidator(); semVal = mockSemanticValidator(); @@ -118,7 +119,7 @@ public class XPlanValidatorTest { validationProcessListener = mock(ValidationProcessListener.class); } - @BeforeClass + @BeforeAll public static void initFileToValidate() throws IOException { InputStream input = XPlanValidatorTest.class.getResourceAsStream("/testdata/xplan60/Blankenese29.gml"); Path xPlanGml = Files.createTempFile("XPlanValidatorTest", ".gml"); @@ -320,22 +321,26 @@ public class XPlanValidatorTest { assertTrue(report.getSyntacticValidatorResult().getMessages().isEmpty()); } - @Test(expected = ValidatorException.class) - public void testValidateWithInvalidProfile() throws Exception { - ValidationSettings semanticSettings = new ValidationSettings("", singletonList(SEMANTIC), emptyList()); - semanticSettings.setProfiles(Collections.singletonList("99")); - SemanticProfileValidator profileValidator = mockSemanticProfileValidator("42"); - List<SemanticProfileValidator> profileValidators = Collections.singletonList(profileValidator); + @Test + public void testValidateWithInvalidProfile() { + assertThrows(ValidatorException.class, () -> { + ValidationSettings semanticSettings = new ValidationSettings("", singletonList(SEMANTIC), emptyList()); + semanticSettings.setProfiles(Collections.singletonList("99")); + SemanticProfileValidator profileValidator = mockSemanticProfileValidator("42"); + List<SemanticProfileValidator> profileValidators = Collections.singletonList(profileValidator); - executeValidator(geoVal, semVal, synVal, profileValidators, semanticSettings); + executeValidator(geoVal, semVal, synVal, profileValidators, semanticSettings); + }); } - @Test(expected = ValidatorException.class) - public void testValidateWithInvalidProfile_NoProfileConfigured() throws Exception { - ValidationSettings semanticSettings = new ValidationSettings("", singletonList(SEMANTIC), emptyList()); - semanticSettings.setProfiles(Collections.singletonList("99")); + @Test + public void testValidateWithInvalidProfile_NoProfileConfigured() { + assertThrows(ValidatorException.class, () -> { + ValidationSettings semanticSettings = new ValidationSettings("", singletonList(SEMANTIC), emptyList()); + semanticSettings.setProfiles(Collections.singletonList("99")); - executeValidator(geoVal, semVal, synVal, semanticSettings); + executeValidator(geoVal, semVal, synVal, semanticSettings); + }); } private Matcher<SyntacticValidatorResult> containsSyntaticResult(final String messageToCheck) { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/configuration/ValidatorConfigurationParserTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/configuration/ValidatorConfigurationParserTest.java index f9fad4d90e..8d3433fc9d 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/configuration/ValidatorConfigurationParserTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/configuration/ValidatorConfigurationParserTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -24,11 +24,11 @@ import de.latlon.xplan.commons.configuration.DefaultPropertiesLoader; import de.latlon.xplan.commons.configuration.PropertiesLoader; import de.latlon.xplan.manager.web.shared.ConfigurationException; import org.apache.commons.io.IOUtils; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -37,8 +37,7 @@ import java.util.Properties; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.Files.isDirectory; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -54,8 +53,8 @@ public class ValidatorConfigurationParserTest { private static final String VALIDATION_REPORT_DIRECTORY_KEY = "validationReportDirectory"; - @ClassRule - public static TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public static File tempFolder; private static Path valid; @@ -67,35 +66,35 @@ public class ValidatorConfigurationParserTest { private static Path duplicateName; - @BeforeClass + @BeforeAll public static void copyProfiles() throws IOException { - valid = tempFolder.newFolder("valid").toPath(); + valid = newFolder(tempFolder, "valid").toPath(); Path profile = valid.resolve("profile.yaml"); Path profiles = valid.resolve("profiles.yaml"); copy("/de/latlon/xplan/validator/configuration/profile.yaml", profile); copy("/de/latlon/xplan/validator/configuration/profiles.yaml", profiles); - invalidName = tempFolder.newFolder("invalidName").toPath(); + invalidName = newFolder(tempFolder, "invalidName").toPath(); Path invalidName = ValidatorConfigurationParserTest.invalidName.resolve("profile-invalidName.yaml"); copy("/de/latlon/xplan/validator/configuration/profile-invalidName.yaml", invalidName); - invalidId = tempFolder.newFolder("invalidId").toPath(); + invalidId = newFolder(tempFolder, "invalidId").toPath(); Path invalidPath = ValidatorConfigurationParserTest.invalidId.resolve("profile-invalidId.yaml"); copy("/de/latlon/xplan/validator/configuration/profile-invalidId.yaml", invalidPath); - duplicateId = tempFolder.newFolder("duplicateId").toPath(); + duplicateId = newFolder(tempFolder, "duplicateId").toPath(); Path duplicateIdPath = ValidatorConfigurationParserTest.duplicateId.resolve("profiles-duplicateId.yaml"); copy("/de/latlon/xplan/validator/configuration/profiles-duplicateId.yaml", duplicateIdPath); - duplicateName = tempFolder.newFolder("duplicateName").toPath(); + duplicateName = newFolder(tempFolder, "duplicateName").toPath(); Path duplicateNamePath = ValidatorConfigurationParserTest.duplicateName.resolve("profiles-duplicateName.yaml"); copy("/de/latlon/xplan/validator/configuration/profiles-duplicateName.yaml", duplicateNamePath); } private static void copy(String name, Path profiles) throws IOException { String contentProfiles = IOUtils.resourceToString(name, UTF_8); - String paths = contentProfiles.replaceAll("PATH", tempFolder.getRoot().getAbsolutePath()); + String paths = contentProfiles.replaceAll("PATH", tempFolder.getAbsolutePath()); Files.write(profiles, paths.getBytes(UTF_8)); } @@ -154,32 +153,41 @@ public class ValidatorConfigurationParserTest { assertEquals(3, validatorConfiguration.getValidatorProfiles().size()); } - @Test(expected = ConfigurationException.class) - public void testParseProfile_invalidName() throws Exception { - PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", invalidName); - ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); - validatorConfigurationParser.parse(propertiesLoader); + @Test + public void testParseProfile_invalidName() { + assertThrows(ConfigurationException.class, () -> { + PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", invalidName); + ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); + validatorConfigurationParser.parse(propertiesLoader); + }); } - @Test(expected = ConfigurationException.class) - public void testParseProfile_invalidId() throws Exception { - PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", invalidId); - ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); - validatorConfigurationParser.parse(propertiesLoader); + @Test + public void testParseProfile_invalidId() { + assertThrows(ConfigurationException.class, () -> { + PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", invalidId); + ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); + validatorConfigurationParser.parse(propertiesLoader); + }); } - @Test(expected = ConfigurationException.class) - public void testParseProfile_DuplicateId() throws Exception { - PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", duplicateId); - ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); - validatorConfigurationParser.parse(propertiesLoader); + @Test + public void testParseProfile_DuplicateId() { + assertThrows(ConfigurationException.class, () -> { + PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", duplicateId); + ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); + validatorConfigurationParser.parse(propertiesLoader); + }); } - @Test(expected = ConfigurationException.class) - public void testParseProfile_DuplicateName() throws Exception { - PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", duplicateName); - ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); - validatorConfigurationParser.parse(propertiesLoader); + @Test + public void testParseProfile_DuplicateName() { + assertThrows(ConfigurationException.class, () -> { + PropertiesLoader propertiesLoader = mockPropertiesLoaderWithProfile("/home/xplanbox/report/", + duplicateName); + ValidatorConfigurationParser validatorConfigurationParser = new ValidatorConfigurationParser(); + validatorConfigurationParser.parse(propertiesLoader); + }); } private PropertiesLoader mockPropertiesLoader(String validationReportDirectory) throws ConfigurationException { @@ -198,4 +206,13 @@ public class ValidatorConfigurationParserTest { return propertiesLoader; } + private static File newFolder(File root, String... subDirs) throws IOException { + String subFolder = String.join("/", subDirs); + File result = new File(root, subFolder); + if (!result.mkdirs()) { + throw new IOException("Couldn't create folders " + root); + } + return result; + } + } diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/GeometricValidatorImplTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/GeometricValidatorImplTest.java index 4a42d1ed50..818c812262 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/GeometricValidatorImplTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/GeometricValidatorImplTest.java @@ -29,8 +29,8 @@ import static de.latlon.xplan.validator.web.shared.ValidationType.SYNTACTIC; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.io.InputStream; @@ -51,15 +51,15 @@ import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.report.ValidatorResult; import de.latlon.xplan.validator.web.shared.ValidationOption; import de.latlon.xplan.validator.web.shared.ValidationSettings; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:schneider@occamlabs.de">Markus Schneider</a> */ public class GeometricValidatorImplTest { - @Ignore("TODO: test plan is required (with only few features)") + @Disabled("TODO: test plan is required (with only few features)") @Test public void testValidateGeometryWithNullVoOptions() throws Exception { XPlanArchive archive = getTestArchive("xplan51/BP2070.zip"); @@ -98,7 +98,7 @@ public class GeometricValidatorImplTest { assertThat(numberOfErrors, is(6)); } - @Ignore("TODO: test plan is required (with only few features)") + @Disabled("TODO: test plan is required (with only few features)") @Test public void testValidateGeometryWithInvalidFlaechenschluss_notskipped() throws Exception { XPlanArchive archive = getTestArchive("xplan51/BP2070.zip"); diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/ParameterizedGeometricValidatorImplTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/ParameterizedGeometricValidatorImplTest.java index d52857d6d2..bfda6846f9 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/ParameterizedGeometricValidatorImplTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/ParameterizedGeometricValidatorImplTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -42,25 +42,22 @@ import de.latlon.xplan.validator.planinfo.PlanInfoParser; import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.report.ValidatorResult; import de.latlon.xplan.validator.web.shared.ValidationSettings; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -@RunWith(Parameterized.class) public class ParameterizedGeometricValidatorImplTest { - private final String testResource; + private String testResource; - private final boolean expectedValidationResult; + private boolean expectedValidationResult; - private final int expectedNumberOfErrors; + private int expectedNumberOfErrors; - private final int expectedNumberOfWarnings; + private int expectedNumberOfWarnings; - @Parameterized.Parameters public static List<Object[]> data() { return Arrays .asList(new Object[][] { { "xplan41/BP2070.zip", false, 6, 0 }, { "xplan41/BP2135.zip", true, 0, 0 }, @@ -75,7 +72,7 @@ public class ParameterizedGeometricValidatorImplTest { { "xplan51/LA22.zip", false, 24, 0 }, { "xplan51/LA67.zip", false, 7, 0 } }); } - public ParameterizedGeometricValidatorImplTest(String testResource, boolean expectedValidationResult, + public void initParameterizedGeometricValidatorImplTest(String testResource, boolean expectedValidationResult, int expectedNumberOfErrors, int expectedNumberOfWarnings) { this.testResource = testResource; this.expectedValidationResult = expectedValidationResult; @@ -83,8 +80,12 @@ public class ParameterizedGeometricValidatorImplTest { this.expectedNumberOfWarnings = expectedNumberOfWarnings; } - @Test - public void testValidateGeometry() throws Exception { + @MethodSource("data") + @ParameterizedTest + public void testValidateGeometry(String testResource, boolean expectedValidationResult, int expectedNumberOfErrors, + int expectedNumberOfWarnings) throws Exception { + initParameterizedGeometricValidatorImplTest(testResource, expectedValidationResult, expectedNumberOfErrors, + expectedNumberOfWarnings); XPlanArchive archive = getTestArchive(testResource); ValidatorResult report = validateGeometryAndReturnReport(archive); GeometricValidatorResult geometricReport = (GeometricValidatorResult) report; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/XPlanGeometryInspectorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/XPlanGeometryInspectorTest.java index 33e3405109..63949c859d 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/XPlanGeometryInspectorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/XPlanGeometryInspectorTest.java @@ -45,7 +45,7 @@ import org.deegree.geometry.primitive.Point; import org.deegree.geometry.primitive.Ring; import org.deegree.geometry.primitive.patches.PolygonPatch; import org.deegree.gml.GMLInputFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for <link>XPlanGeometryInspector</link>. diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/aenderungen/AenderungenInspectorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/aenderungen/AenderungenInspectorTest.java index db03a9fda2..dce617ed9a 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/aenderungen/AenderungenInspectorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/aenderungen/AenderungenInspectorTest.java @@ -23,16 +23,13 @@ package de.latlon.xplan.validator.geometric.inspector.aenderungen; import static de.latlon.xplan.validator.FeatureParserUtils.readFeaturesFromGml; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import java.util.List; import de.latlon.xplan.validator.geometric.result.GeometricValidationFinding; import de.latlon.xplan.validator.geometric.result.GeometricValidationFindingLevel; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> @@ -68,7 +65,7 @@ public class AenderungenInspectorTest { aenderungenInspector.checkGeometricRule(); List<GeometricValidationFinding> findings = aenderungenInspector.getFindings(); assertThat(findings.size(), is(1)); - assertNotNull(findings.get(0).getMessage(), is(1)); + assertNotNull(is(1), findings.get(0).getMessage()); assertThat(findings.get(0).getGmlIds().size(), is(0)); assertThat(findings.get(0).getLevel(), is(GeometricValidationFindingLevel.WARNING)); assertNull(findings.get(0).getMarkerGeom()); @@ -89,7 +86,7 @@ public class AenderungenInspectorTest { List<GeometricValidationFinding> findings = aenderungenInspector.getFindings(); assertThat(findings.size(), is(1)); - assertNotNull(findings.get(0).getMessage(), is(1)); + assertNotNull(is(1), findings.get(0).getMessage()); assertThat(findings.get(0).getGmlIds().size(), is(0)); assertThat(findings.get(0).getLevel(), is(GeometricValidationFindingLevel.ERROR)); assertNull(findings.get(0).getMarkerGeom()); diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/doppelbelegung/DoppelbelegungInspectorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/doppelbelegung/DoppelbelegungInspectorTest.java index e5510d7aee..6694c100ca 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/doppelbelegung/DoppelbelegungInspectorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/doppelbelegung/DoppelbelegungInspectorTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.util.List; import de.latlon.xplan.validator.geometric.result.GeometricValidationFinding; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/flaechenschluss/OptimisedFlaechenschlussInspectorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/flaechenschluss/OptimisedFlaechenschlussInspectorTest.java index 45ecfade90..85871c52a7 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/flaechenschluss/OptimisedFlaechenschlussInspectorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/flaechenschluss/OptimisedFlaechenschlussInspectorTest.java @@ -34,21 +34,21 @@ import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItems; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; import de.latlon.xplan.validator.geometric.result.GeometricValidationFinding; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ public class OptimisedFlaechenschlussInspectorTest { - @Ignore + @Disabled @Test public void testCheckFlaechenschluss_executionTime() throws Exception { OptimisedFlaechenschlussInspector flaechenschlussInspector = new OptimisedFlaechenschlussInspector(XPLAN_54, @@ -567,7 +567,7 @@ public class OptimisedFlaechenschlussInspectorTest { assertThat(isValid, is(true)); } - @Ignore + @Disabled @Test public void testCheckFlaechenschluss_PolygonPatch_nicht_zusammenhaengend_Flaechenschlussobjekt() throws Exception { OptimisedFlaechenschlussInspector flaechenschlussInspector = new OptimisedFlaechenschlussInspector(XPLAN_60, @@ -591,7 +591,7 @@ public class OptimisedFlaechenschlussInspectorTest { assertThat(isValid, is(true)); } - @Ignore + @Disabled @Test public void testCheckFlaechenschluss_PolygonPatch_Flaechenschlussobjekt() throws Exception { OptimisedFlaechenschlussInspector flaechenschlussInspector = new OptimisedFlaechenschlussInspector(XPLAN_60, diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorKompensationsbereichTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorKompensationsbereichTest.java index 1906f2ee17..8a02912ca1 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorKompensationsbereichTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorKompensationsbereichTest.java @@ -20,13 +20,12 @@ */ package de.latlon.xplan.validator.geometric.inspector.geltungsbereich; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - import java.util.Arrays; import java.util.List; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import static de.latlon.xplan.commons.XPlanVersion.XPLAN_60; import static de.latlon.xplan.validator.FeatureParserUtils.readFeaturesFromGml; import static org.hamcrest.CoreMatchers.is; @@ -35,14 +34,12 @@ import static org.hamcrest.MatcherAssert.assertThat; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -@RunWith(Parameterized.class) public class GeltungsbereichInspectorKompensationsbereichTest { - private final String planName; + private String planName; - private final boolean isExpectedValid; + private boolean isExpectedValid; - @Parameterized.Parameters public static List<Object[]> data() { return Arrays.asList(new Object[][] { { "kompensationsbereich/Bereich_1800_Bereich_mitGeltungsbereich_2_Flaechenschlussobjekte_korrekt.gml", @@ -65,13 +62,15 @@ public class GeltungsbereichInspectorKompensationsbereichTest { { "outside/Bereich_2000_Bereich_ohneGeltungsbereich_ohne_Flaechenschlussobjekte_Fehler.gml", true } }); } - public GeltungsbereichInspectorKompensationsbereichTest(String planName, boolean expectedIsValid) { + public void initGeltungsbereichInspectorKompensationsbereichTest(String planName, boolean expectedIsValid) { this.planName = planName; this.isExpectedValid = expectedIsValid; } - @Test - public void testCheck_Kompensationsbereiche_valide() throws Exception { + @MethodSource("data") + @ParameterizedTest + public void testCheck_Kompensationsbereiche_valide(String planName, boolean expectedIsValid) throws Exception { + initGeltungsbereichInspectorKompensationsbereichTest(planName, expectedIsValid); GeltungsbereichInspector geltungsbereichInspector = new GeltungsbereichInspector(XPLAN_60); readFeaturesFromGml(planName, GeltungsbereichInspector.class, geltungsbereichInspector); diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorTest.java index bd4a1c9636..f689ab23dc 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/geometric/inspector/geltungsbereich/GeltungsbereichInspectorTest.java @@ -32,12 +32,12 @@ import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.List; import de.latlon.xplan.validator.geometric.result.GeometricValidationFinding; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/planinfo/PlanInfoParserTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/planinfo/PlanInfoParserTest.java index 916eefad96..60f6d4366e 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/planinfo/PlanInfoParserTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/planinfo/PlanInfoParserTest.java @@ -5,9 +5,7 @@ import static de.latlon.xplan.commons.XPlanVersion.XPLAN_52; import static de.latlon.xplan.commons.XPlanVersion.XPLAN_60; import static de.latlon.xplan.validator.report.reference.ExternalReferenceStatus.AVAILABLE; import static de.latlon.xplan.validator.report.reference.ExternalReferenceStatus.MISSING; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.io.InputStream; @@ -24,7 +22,7 @@ import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.web.shared.ValidationSettings; import de.latlon.xplanbox.core.raster.evaluation.XPlanRasterEvaluation; import de.latlon.xplanbox.core.raster.evaluation.XPlanRasterEvaluator; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/reference/ExternalReferenceEvaluatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/reference/ExternalReferenceEvaluatorTest.java index fce2f04d24..d145fa8e8b 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/reference/ExternalReferenceEvaluatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/reference/ExternalReferenceEvaluatorTest.java @@ -33,7 +33,7 @@ import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.commons.feature.XPlanFeatureCollection; import de.latlon.xplan.commons.feature.XPlanGmlParserBuilder; import de.latlon.xplan.validator.report.reference.ExternalReferenceReport; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportUtilsTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportUtilsTest.java index ccc6ddeecf..7ba378902c 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportUtilsTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportUtilsTest.java @@ -20,12 +20,12 @@ */ package de.latlon.xplan.validator.report; -import org.junit.Test; - import static de.latlon.xplan.validator.report.ReportUtils.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.Test; + /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> * @version $Revision: $, $Date: $ diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportWriterTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportWriterTest.java index 95182cae1d..b17b28d853 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportWriterTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ReportWriterTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -45,10 +46,9 @@ import de.latlon.xplan.validator.planinfo.PlanInfoReport; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -64,14 +64,14 @@ public class ReportWriterTest { private ReportWriter reportWriter = new ReportWriter(); - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir + public File temporaryFolder; private Path targetDirectory; - @Before + @BeforeEach public void createTargetDirectory() throws Exception { - targetDirectory = Paths.get(temporaryFolder.newFolder("ReportWriterTest").toURI()); + targetDirectory = Paths.get(newFolder(temporaryFolder, "ReportWriterTest").toURI()); } @Test @@ -205,4 +205,13 @@ public class ReportWriterTest { }; } + private static File newFolder(File root, String... subDirs) throws IOException { + String subFolder = String.join("/", subDirs); + File result = new File(root, subFolder); + if (!result.mkdirs()) { + throw new IOException("Couldn't create folders " + root); + } + return result; + } + } diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ValidatorDetailTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ValidatorDetailTest.java index b7fcdf276c..d415b2d6be 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ValidatorDetailTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/ValidatorDetailTest.java @@ -22,12 +22,12 @@ package de.latlon.xplan.validator.report; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List; -import org.junit.Test; - import de.latlon.xplan.validator.report.ValidatorDetail.DetailPart; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -89,19 +89,25 @@ public class ValidatorDetailTest { assertThat(validatorDetail.toString(), is(" ghi jkl ")); } - @Test(expected = NullPointerException.class) - public void testConstructor_withNullDetailsString() throws Exception { - new ValidatorDetail(null); + @Test + public void testConstructor_withNullDetailsString() { + assertThrows(NullPointerException.class, () -> { + new ValidatorDetail(null); + }); } - @Test(expected = IllegalArgumentException.class) - public void testConstructor_withPlaceholderButNoLinks() throws Exception { - new ValidatorDetail("details %s", null); + @Test + public void testConstructor_withPlaceholderButNoLinks() { + assertThrows(IllegalArgumentException.class, () -> { + new ValidatorDetail("details %s", null); + }); } - @Test(expected = IllegalArgumentException.class) - public void testConstructor_withoutPlaceholderButLink() throws Exception { - new ValidatorDetail("details", "link"); + @Test + public void testConstructor_withoutPlaceholderButLink() { + assertThrows(IllegalArgumentException.class, () -> { + new ValidatorDetail("details", "link"); + }); } } diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonBuilderTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonBuilderTest.java index bb0d29041d..1547d3f900 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonBuilderTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonBuilderTest.java @@ -31,7 +31,7 @@ import org.deegree.cs.exceptions.UnknownCRSException; import org.deegree.cs.persistence.CRSManager; import org.deegree.geometry.Geometry; import org.deegree.geometry.GeometryFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonGeometryBuilderTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonGeometryBuilderTest.java index b244c12996..891f74c815 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonGeometryBuilderTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/geojson/GeoJsonGeometryBuilderTest.java @@ -31,7 +31,7 @@ import org.deegree.geometry.multi.MultiGeometry; import org.deegree.geometry.points.Points; import org.deegree.geometry.primitive.GeometricPrimitive; import org.deegree.geometry.primitive.Ring; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/html/HtmlReportGeneratorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/html/HtmlReportGeneratorTest.java index aeaa57edda..0fee2b9215 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/html/HtmlReportGeneratorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/html/HtmlReportGeneratorTest.java @@ -28,6 +28,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.xmlunit.matchers.EvaluateXPathMatcher.hasXPath; import java.io.ByteArrayOutputStream; @@ -46,7 +47,7 @@ import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.semantic.report.InvalidFeaturesResult; import de.latlon.xplan.validator.semantic.report.SemanticValidatorResult; import de.latlon.xplan.validator.syntactic.report.SyntacticValidatorResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> @@ -125,16 +126,20 @@ public class HtmlReportGeneratorTest { assertThat(html.toString(), hasXPath("/html/body/p[5]/p[6]", containsString("gegen das Profil"))); } - @Test(expected = IllegalArgumentException.class) - public void testGenerateXmlReportWithNullReport() throws Exception { - HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(); - htmlReportGenerator.generateHtmlReport(null, new ByteArrayOutputStream()); + @Test + public void testGenerateXmlReportWithNullReport() { + assertThrows(IllegalArgumentException.class, () -> { + HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(); + htmlReportGenerator.generateHtmlReport(null, new ByteArrayOutputStream()); + }); } - @Test(expected = IllegalArgumentException.class) - public void testGenerateXmlReportWithNullOutputStream() throws Exception { - HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(); - htmlReportGenerator.generateHtmlReport(createValidationReport(), null); + @Test + public void testGenerateXmlReportWithNullOutputStream() { + assertThrows(IllegalArgumentException.class, () -> { + HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(); + htmlReportGenerator.generateHtmlReport(createValidationReport(), null); + }); } private ValidatorReport createValidatorReportWithSemanticFailures() { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/PdfReportGeneratorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/PdfReportGeneratorTest.java index e766f5a907..1290a423a7 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/PdfReportGeneratorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/PdfReportGeneratorTest.java @@ -21,6 +21,7 @@ package de.latlon.xplan.validator.report.pdf; import static java.util.Collections.singletonMap; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayOutputStream; import java.util.ArrayList; @@ -37,7 +38,7 @@ import de.latlon.xplan.validator.report.ValidatorDetail; import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.semantic.report.SemanticValidatorResult; import de.latlon.xplan.validator.syntactic.report.SyntacticValidatorResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -45,11 +46,13 @@ import org.junit.Test; */ public class PdfReportGeneratorTest { - @Test(expected = IllegalArgumentException.class) - public void testCreateReportAsPdfWithNullReport() throws Exception { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PdfReportGenerator pdfReportGenerator = new PdfReportGenerator(); - pdfReportGenerator.createPdfReport(null, bos); + @Test + public void testCreateReportAsPdfWithNullReport() { + assertThrows(IllegalArgumentException.class, () -> { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PdfReportGenerator pdfReportGenerator = new PdfReportGenerator(); + pdfReportGenerator.createPdfReport(null, bos); + }); } @Test diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/ReportBuilderTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/ReportBuilderTest.java index 991a98bb49..93829f63fc 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/ReportBuilderTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/pdf/ReportBuilderTest.java @@ -25,6 +25,7 @@ import static java.util.Collections.singletonMap; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayOutputStream; import java.io.File; @@ -43,9 +44,8 @@ import de.latlon.xplan.validator.report.ValidatorDetail; import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.semantic.report.SemanticValidatorResult; import de.latlon.xplan.validator.syntactic.report.SyntacticValidatorResult; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -53,31 +53,35 @@ import org.junit.rules.TemporaryFolder; */ public class ReportBuilderTest { - @Rule - public TemporaryFolder tmpFolder = new TemporaryFolder(); + @TempDir + public File tmpFolder; // @Ignore("Make a visibility check if the report looks like expected!") @Test public void testCreateReportAsPdf() throws Exception { PdfReportGenerator reportBuilder = new PdfReportGenerator(); - File file = tmpFolder.newFile(); + File file = File.createTempFile("junit", null, tmpFolder); OutputStream os = new FileOutputStream(file); reportBuilder.createPdfReport(createReport(), os); os.close(); assertThat(Files.size(file.toPath()), is(not(0))); } - @Test(expected = IllegalArgumentException.class) - public void testCreateReportAsPdfWithNullReport() throws Exception { - PdfReportGenerator reportBuilder = new PdfReportGenerator(); - reportBuilder.createPdfReport(null, createSimpleOutputStream()); + @Test + public void testCreateReportAsPdfWithNullReport() { + assertThrows(IllegalArgumentException.class, () -> { + PdfReportGenerator reportBuilder = new PdfReportGenerator(); + reportBuilder.createPdfReport(null, createSimpleOutputStream()); + }); } - @Test(expected = IllegalArgumentException.class) - public void testCreateReportAsPdfWithNullStream() throws Exception { - PdfReportGenerator reportBuilder = new PdfReportGenerator(); - reportBuilder.createPdfReport(createReport(), null); + @Test + public void testCreateReportAsPdfWithNullStream() { + assertThrows(IllegalArgumentException.class, () -> { + PdfReportGenerator reportBuilder = new PdfReportGenerator(); + reportBuilder.createPdfReport(createReport(), null); + }); } private ValidatorReport createReport() { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/xml/XmlReportGeneratorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/xml/XmlReportGeneratorTest.java index 34ec351aec..b07433becb 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/xml/XmlReportGeneratorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/report/xml/XmlReportGeneratorTest.java @@ -26,6 +26,7 @@ import static de.latlon.xplan.validator.report.SkipCode.SYNTAX_ERRORS; import static java.util.Collections.singletonMap; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayOutputStream; import java.util.Collections; @@ -39,7 +40,7 @@ import de.latlon.xplan.validator.report.ValidatorReport; import de.latlon.xplan.validator.semantic.report.InvalidFeaturesResult; import de.latlon.xplan.validator.semantic.report.SemanticValidatorResult; import de.latlon.xplan.validator.syntactic.report.SyntacticValidatorResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xmlunit.matchers.EvaluateXPathMatcher; import org.xmlunit.matchers.HasXPathMatcher; @@ -131,16 +132,20 @@ public class XmlReportGeneratorTest { .hasXPath("/ValidationReport/Plan/Validation/Profile/Rules/Rule[name = 'b']/isValid", equalTo("false"))); } - @Test(expected = IllegalArgumentException.class) - public void testGenerateXmlReportWithNullReport() throws Exception { - XmlReportGenerator xmlReportGenerator = new XmlReportGenerator(); - xmlReportGenerator.generateXmlReport(null, new ByteArrayOutputStream()); + @Test + public void testGenerateXmlReportWithNullReport() { + assertThrows(IllegalArgumentException.class, () -> { + XmlReportGenerator xmlReportGenerator = new XmlReportGenerator(); + xmlReportGenerator.generateXmlReport(null, new ByteArrayOutputStream()); + }); } - @Test(expected = IllegalArgumentException.class) - public void testGenerateXmlReportWithNullOutputStream() throws Exception { - XmlReportGenerator xmlReportGenerator = new XmlReportGenerator(); - xmlReportGenerator.generateXmlReport(createValidatorReport(), null); + @Test + public void testGenerateXmlReportWithNullOutputStream() { + assertThrows(IllegalArgumentException.class, () -> { + XmlReportGenerator xmlReportGenerator = new XmlReportGenerator(); + xmlReportGenerator.generateXmlReport(createValidatorReport(), null); + }); } private ValidatorReport createValidatorReport() { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/DefaultRulesMessagesAccessorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/DefaultRulesMessagesAccessorTest.java index 98c186e24b..ee93e46d2a 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/DefaultRulesMessagesAccessorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/DefaultRulesMessagesAccessorTest.java @@ -21,7 +21,7 @@ package de.latlon.xplan.validator.semantic.configuration; import de.latlon.xplan.validator.semantic.configuration.message.DefaultRulesMessagesAccessor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static de.latlon.xplan.commons.XPlanVersion.XPLAN_51; import static org.hamcrest.CoreMatchers.is; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/FileRulesMessagesAccessorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/FileRulesMessagesAccessorTest.java index 078b0c3e4c..fb780d2785 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/FileRulesMessagesAccessorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/FileRulesMessagesAccessorTest.java @@ -20,40 +20,40 @@ */ package de.latlon.xplan.validator.semantic.configuration; -import de.latlon.xplan.validator.semantic.configuration.message.FileRulesMessagesAccessor; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import static de.latlon.xplan.commons.XPlanVersion.XPLAN_41; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.nio.file.Path; -import static de.latlon.xplan.commons.XPlanVersion.XPLAN_41; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; +import de.latlon.xplan.validator.semantic.configuration.message.FileRulesMessagesAccessor; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> */ public class FileRulesMessagesAccessorTest { - @ClassRule - public static TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public static Path tempFolder; private static FileRulesMessagesAccessor rulesMessagesAccessor; - @BeforeClass + @BeforeAll public static void initFileRulesMessagesAccessor() throws IOException { - File file = tempFolder.newFile("rules.properties"); - Files.delete(file.toPath()); + Path resolve = tempFolder.resolve("rules.properties"); + Path file = Files.createFile(resolve); + Files.delete(file); InputStream properties = FileRulesMessagesAccessorTest.class .getResourceAsStream("/de/latlon/xplan/validator/configuration/rules/rules.properties"); - Files.copy(properties, file.toPath()); - rulesMessagesAccessor = new FileRulesMessagesAccessor(tempFolder.getRoot().toPath()); + Files.copy(properties, file); + rulesMessagesAccessor = new FileRulesMessagesAccessor(tempFolder); } @Test diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidationOptionsTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidationOptionsTest.java index 18f9854968..17f138cd18 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidationOptionsTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidationOptionsTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -27,10 +27,10 @@ import static de.latlon.xplan.validator.semantic.configuration.SemanticValidatio import static de.latlon.xplan.validator.semantic.configuration.SemanticValidationOptions.getByOption; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; import de.latlon.xplan.validator.web.shared.ValidationOption; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -90,9 +90,9 @@ public class SemanticValidationOptionsTest { assertThat(IGNORE_XP.getOptionName(), is("ignore-xp")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testGetByDirectoryNameWithNullShouldFail() { - getByDirectoryName(null); + assertThrows(IllegalArgumentException.class, () -> getByDirectoryName(null)); } } diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidatorConfigurationTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidatorConfigurationTest.java index 4995463610..0d2533ddfd 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidatorConfigurationTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/SemanticValidatorConfigurationTest.java @@ -26,16 +26,16 @@ import static de.latlon.xplan.validator.semantic.configuration.SemanticValidatio import static java.util.Collections.singletonList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; -import org.junit.Test; - import de.latlon.xplan.commons.XPlanVersion; import de.latlon.xplan.validator.semantic.SemanticValidatorRule; +import org.junit.jupiter.api.Test; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz</a> @@ -65,16 +65,20 @@ public class SemanticValidatorConfigurationTest { assertThat(rules.size(), is(2)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testGetRUlesWithNullVersionShouldFail() { - SemanticValidatorConfiguration configuration = createConfigurationWithRules(); - configuration.getRules(null, singletonList(IGNORE_SO)); + assertThrows(IllegalArgumentException.class, () -> { + SemanticValidatorConfiguration configuration = createConfigurationWithRules(); + configuration.getRules(null, singletonList(IGNORE_SO)); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testGetRUlesWithNullOptionsShouldFail() { - SemanticValidatorConfiguration configuration = createConfigurationWithRules(); - configuration.getRules(XPLAN_40, null); + assertThrows(IllegalArgumentException.class, () -> { + SemanticValidatorConfiguration configuration = createConfigurationWithRules(); + configuration.getRules(XPLAN_40, null); + }); } private SemanticValidatorConfiguration createConfigurationWithRules() { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/metadata/RulesVersionParserTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/metadata/RulesVersionParserTest.java index 0128ce9979..7f81b4c48b 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/metadata/RulesVersionParserTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/metadata/RulesVersionParserTest.java @@ -22,7 +22,7 @@ package de.latlon.xplan.validator.semantic.configuration.metadata; import de.latlon.xplan.validator.semantic.configuration.SemanticRulesConfiguration; import de.latlon.xplan.validator.semantic.configuration.SemanticRulesMainConfiguration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URISyntaxException; import java.nio.file.Path; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/xquery/XQuerySemanticValidatorConfigurationRetrieverTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/xquery/XQuerySemanticValidatorConfigurationRetrieverTest.java index 3e85d3ab29..1a6bcca25a 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/xquery/XQuerySemanticValidatorConfigurationRetrieverTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/configuration/xquery/XQuerySemanticValidatorConfigurationRetrieverTest.java @@ -24,7 +24,7 @@ import de.latlon.xplan.validator.semantic.SemanticValidatorRule; import de.latlon.xplan.validator.semantic.configuration.SemanticRulesConfiguration; import de.latlon.xplan.validator.semantic.configuration.SemanticRulesMainConfiguration; import de.latlon.xplan.validator.semantic.configuration.SemanticValidatorConfiguration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.util.List; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/profile/SemanticProfilesCreatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/profile/SemanticProfilesCreatorTest.java index 30620aabbf..5fd0d3c267 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/profile/SemanticProfilesCreatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/profile/SemanticProfilesCreatorTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -24,24 +24,21 @@ import de.latlon.xplan.commons.configuration.PropertiesLoader; import de.latlon.xplan.manager.web.shared.ConfigurationException; import de.latlon.xplan.validator.configuration.ValidatorConfiguration; import de.latlon.xplan.validator.semantic.configuration.metadata.RulesMetadata; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ResourceLoader; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = { TestContext.class }) +@SpringJUnitConfig(classes = { TestContext.class }) public class SemanticProfilesCreatorTest { @Autowired diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/report/SemanticValidatorResultTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/report/SemanticValidatorResultTest.java index eda5236f88..912fc54daf 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/report/SemanticValidatorResultTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/report/SemanticValidatorResultTest.java @@ -20,11 +20,11 @@ */ package de.latlon.xplan.validator.semantic.report; -import org.junit.Test; - import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.Test; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorRuleTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorRuleTest.java index 66db788c61..cff930525f 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorRuleTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorRuleTest.java @@ -24,7 +24,7 @@ import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.validator.semantic.report.InvalidFeaturesResult; import net.sf.saxon.trans.XPathException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -39,6 +39,7 @@ import static de.latlon.xplan.validator.semantic.report.ValidationResultType.ERR import static de.latlon.xplan.validator.semantic.report.ValidationResultType.WARNING; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests for <link>XQuerySemanticValidatorRule</link> @@ -100,11 +101,13 @@ public class XQuerySemanticValidatorRuleTest { assertThat(invalidFeatures.size(), is(1)); } - @Test(expected = XPathException.class) - public void testDefectedRuleShouldThrowException() throws Exception { - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("<<".getBytes()); - (new XQuerySemanticValidatorRule(byteArrayInputStream, "name", XPLAN_41, NONE, "message")) - .validate(retrieveArchive("xplan41/BP2070.zip")); + @Test + public void testDefectedRuleShouldThrowException() { + assertThrows(XPathException.class, () -> { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("<<".getBytes()); + (new XQuerySemanticValidatorRule(byteArrayInputStream, "name", XPLAN_41, NONE, "message")) + .validate(retrieveArchive("xplan41/BP2070.zip")); + }); } @Test diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorTest.java index 3b531191a3..2bb9a75a0a 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/semantic/xquery/XQuerySemanticValidatorTest.java @@ -8,18 +8,32 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ package de.latlon.xplan.validator.semantic.xquery; +import static de.latlon.xplan.commons.XPlanVersion.XPLAN_40; +import static de.latlon.xplan.commons.XPlanVersion.XPLAN_41; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.stream.Stream; + import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.commons.configuration.SemanticConformityLinkConfiguration; @@ -29,22 +43,10 @@ import de.latlon.xplan.validator.semantic.configuration.SemanticRulesConfigurati import de.latlon.xplan.validator.semantic.configuration.SemanticRulesMainConfiguration; import de.latlon.xplan.validator.semantic.configuration.xquery.XQuerySemanticValidatorConfigurationRetriever; import de.latlon.xplan.validator.semantic.report.SemanticValidatorResult; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collections; - -import static de.latlon.xplan.commons.XPlanVersion.XPLAN_40; -import static de.latlon.xplan.commons.XPlanVersion.XPLAN_41; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for <link>XQuerySemanticValidator</link> @@ -52,11 +54,15 @@ import static org.hamcrest.Matchers.is; * @author <a href="mailto:erben@lat-lon.de">Alexander Erben</a> * @version $Revision: $, $Date: $ */ -@RunWith(JUnitParamsRunner.class) public class XQuerySemanticValidatorTest { - @Parameters({ "xplan41/BP2070.zip,10 ", "xplan50/BP2070.zip,7", "xplan51/BP2070.zip,7" }) - @Test + private static Stream<Arguments> provideParamsForValidateSementic() { + return Stream.of(Arguments.of("xplan41/BP2070.zip", 10), Arguments.of("xplan50/BP2070.zip", 7), + Arguments.of("xplan51/BP2070.zip", 7)); + } + + @ParameterizedTest + @MethodSource("provideParamsForValidateSementic") public void testValidateSemantic(String testResource, int expectedNumberOfRules) throws Exception { Path xqueryFilePath = pathToSampleRules(); SemanticRulesConfiguration semanticRulesConfiguration = new SemanticRulesMainConfiguration(xqueryFilePath); @@ -117,24 +123,28 @@ public class XQuerySemanticValidatorTest { assertThat(semanticValidatorResult.getValidatorDetail(), is(nullValue())); } - @Test(expected = IllegalArgumentException.class) - public void testValidateSemanticWithNullArchiveShouldFail() throws Exception { - Path xqueryFilePath = pathToSampleRules(); - SemanticRulesConfiguration semanticRulesConfiguration = new SemanticRulesMainConfiguration(xqueryFilePath); - XQuerySemanticValidatorConfigurationRetriever retriever = new XQuerySemanticValidatorConfigurationRetriever( - semanticRulesConfiguration); - SemanticValidator xQuerySemanticValidator = new XQuerySemanticValidator(retriever); - xQuerySemanticValidator.validateSemantic(null, Collections.emptyList()); + @Test + public void testValidateSemanticWithNullArchiveShouldFail() { + assertThrows(IllegalArgumentException.class, () -> { + Path xqueryFilePath = pathToSampleRules(); + SemanticRulesConfiguration semanticRulesConfiguration = new SemanticRulesMainConfiguration(xqueryFilePath); + XQuerySemanticValidatorConfigurationRetriever retriever = new XQuerySemanticValidatorConfigurationRetriever( + semanticRulesConfiguration); + SemanticValidator xQuerySemanticValidator = new XQuerySemanticValidator(retriever); + xQuerySemanticValidator.validateSemantic(null, Collections.emptyList()); + }); } - @Test(expected = IllegalArgumentException.class) - public void testValidateSemanticWithOptionsArchiveShouldFail() throws Exception { - Path xqueryFilePath = pathToSampleRules(); - SemanticRulesConfiguration semanticRulesConfiguration = new SemanticRulesMainConfiguration(xqueryFilePath); - XQuerySemanticValidatorConfigurationRetriever retriever = new XQuerySemanticValidatorConfigurationRetriever( - semanticRulesConfiguration); - SemanticValidator xQuerySemanticValidator = new XQuerySemanticValidator(retriever); - xQuerySemanticValidator.validateSemantic(getTestArchive("xplan41/BP2070.zip"), null); + @Test + public void testValidateSemanticWithOptionsArchiveShouldFail() { + assertThrows(IllegalArgumentException.class, () -> { + Path xqueryFilePath = pathToSampleRules(); + SemanticRulesConfiguration semanticRulesConfiguration = new SemanticRulesMainConfiguration(xqueryFilePath); + XQuerySemanticValidatorConfigurationRetriever retriever = new XQuerySemanticValidatorConfigurationRetriever( + semanticRulesConfiguration); + SemanticValidator xQuerySemanticValidator = new XQuerySemanticValidator(retriever); + xQuerySemanticValidator.validateSemantic(getTestArchive("xplan41/BP2070.zip"), null); + }); } private XPlanArchive getTestArchive(String name) throws Exception { diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/ParameterizedSyntacticValidatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/ParameterizedSyntacticValidatorTest.java index 3b89dafc0e..0a1962c1ef 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/ParameterizedSyntacticValidatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/ParameterizedSyntacticValidatorTest.java @@ -22,28 +22,25 @@ package de.latlon.xplan.validator.syntactic; import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertTrue; - /** * Tests for <link>SyntacticValidatorImpl</link> * * @author <a href="mailto:erben@lat-lon.de">Alexander Erben</a> * @version $Revision: $, $Date: $ */ -@RunWith(Parameterized.class) public class ParameterizedSyntacticValidatorTest { private String testResource; - @Parameterized.Parameters public static List<Object[]> data() { return Arrays.asList(new Object[][] { { "xplan41/BP2070.zip" }, { "xplan41/BP2135.zip" }, { "xplan41/Demo.zip" }, { "xplan41/Eidelstedt_4_V4.zip" }, { "xplan41/FPlan.zip" }, @@ -53,12 +50,14 @@ public class ParameterizedSyntacticValidatorTest { { "xplan51/BP2135.zip" }, { "xplan51/FPlan.zip" }, { "xplan51/LA22.zip" }, { "xplan51/LA67.zip" } }); } - public ParameterizedSyntacticValidatorTest(String testResource) { + public void initParameterizedSyntacticValidatorTest(String testResource) { this.testResource = testResource; } - @Test - public void testValidateSyntax() throws IOException { + @MethodSource("data") + @ParameterizedTest + public void testValidateSyntax(String testResource) throws IOException { + initParameterizedSyntacticValidatorTest(testResource); XPlanArchive archive = getTestArchive(testResource); SyntacticValidator validator = new SyntacticValidatorImpl(); validator.validateSyntax(archive); diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/SyntacticValidatorTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/SyntacticValidatorTest.java index 42457ef864..529090422d 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/SyntacticValidatorTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/syntactic/SyntacticValidatorTest.java @@ -23,7 +23,7 @@ package de.latlon.xplan.validator.syntactic; import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; import de.latlon.xplan.validator.syntactic.report.SyntacticValidatorResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/ValidatorWmsManagerTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/ValidatorWmsManagerTest.java index b480a31d7f..a96e981dd5 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/ValidatorWmsManagerTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/ValidatorWmsManagerTest.java @@ -28,10 +28,10 @@ import de.latlon.xplan.manager.synthesizer.XPlanSynthesizer; import de.latlon.xplan.manager.synthesizer.rules.SynRulesAccessor; import de.latlon.xplan.validator.wms.storage.PlanStorage; import de.latlon.xplan.validator.wms.storage.WorkspacePlanStorage; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -45,12 +45,12 @@ import static org.hamcrest.MatcherAssert.assertThat; */ public class ValidatorWmsManagerTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; @Test public void testInsert() throws Exception { - Path workspaceLocation = tempFolder.getRoot().toPath(); + Path workspaceLocation = tempFolder.toPath(); SynRulesAccessor synRulesAccessor = new SynRulesAccessor(); XPlanSynthesizer synthesizer = new XPlanSynthesizer(synRulesAccessor); PlanStorage planStorage = new WorkspacePlanStorage(workspaceLocation); diff --git a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/storage/SqlPlanStorageTest.java b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/storage/SqlPlanStorageTest.java index 3cc26ed794..adc8996b90 100644 --- a/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/storage/SqlPlanStorageTest.java +++ b/xplan-core/xplan-core-validator/src/test/java/de/latlon/xplan/validator/wms/storage/SqlPlanStorageTest.java @@ -8,12 +8,12 @@ * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -24,12 +24,9 @@ import static de.latlon.xplan.commons.XPlanVersion.XPLAN_SYN; import org.deegree.feature.FeatureCollection; import org.deegree.feature.types.AppSchema; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import de.latlon.xplan.commons.XPlanSchemas; import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.commons.archive.XPlanArchiveCreator; @@ -44,8 +41,7 @@ import de.latlon.xplan.validator.wms.config.ValidatorWmsSqlContext; /** * @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = { ValidatorWmsSqlContext.class, TestContext.class }) +@SpringJUnitConfig(classes = { ValidatorWmsSqlContext.class, TestContext.class }) public class SqlPlanStorageTest { @Autowired diff --git a/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanManager_API.adoc b/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanManager_API.adoc index 75b124e47d..57d201d9e7 100644 --- a/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanManager_API.adoc +++ b/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanManager_API.adoc @@ -103,3 +103,32 @@ Zusätzliche Anforderungen an die im XPlanGML-Dokument verlinkten Referenzen: - Für alle Dokumente und Rasterbasis in der Version 4.1 bis 5.2 gilt, dass _referenzName_ oder _referenzURL_ belegt sein muss. - Für Pläne mit mehreren `BP_Bereich`-Elementen muss das Element `nummer` für jeden `BP_Bereich` eindeutig sein. - Und zusätzlich gilt für alle Dokumente und Rasterbasis, dass die Kombination aus _referenzName-referenzURL_ innerhalb eines XPlanGML-Dokuments eindeutig sein muss. + +[[xplanmanager-api-authorisierung]] +==== Abgesicherter Zugriff auf XPlanManagerAPI + +Wenn der abgesicherte Zugriff auf die REST-API des XPlanManagerAPI aktiviert ist, die Konfiguration ist im Betriebshandbuch der xPlanBox beschrieben, dann ist für den Aufruf der Schnittstelle ein gültiges Zugriffstoken im HTTP-Header erforderlich. Als Autorisierungsprotokoll wird OAuth 2.0 unterstützt und für das Format des Zugriffstokens das "JSON Web Token (JWT)"-Format. + +==== Authentifizierung + +Ein Client muss dazu im HTTP-Header "Authorization" einen gültigen Bearer Token mitschicken. + +._Beispiel für einen Aufruf der XPlanManagerAPI mit einem Bearer Token:_ +[source,bash] +---- +curl -i -X GET \ +-H "Accept:application/json" \ +-H "Authorization:Bearer eyJhb...I0kGA" \ +'http://localhost:8080/xplan-manager-api/xmanager/api/v2/plans' +---- + +Die Abfrage des Bearer Tokens muss vorher gegen den OpenID Provider wie z.B. https://www.keycloak.org/[Keycloak] erfolgt sein. Ist der Bearer Token nicht gültig, wird der Zugriff auf die XPlanManagerAPI verweigert (HTTP-Status 401). + +==== Autorisierung + +Der Aufruf der XPlanManagerAPI kann durch Berechtigungen eingeschränkt werden. + +Für folgende HTTP-Methoden werden die Berechtigungen geprüft: + +- `POST/PUT/DELETE` - gilt für alle Ressourcen - nur erfolgreich (HTTP-Status 200), wenn der Client über die Berechtigungen für den Zugriff auf die angefragte Ressource verfügt, andernfalls wird der Zugriff verweigert (HTTP-Status 403). Der Abgleich erfolgt über das Element _xplan:XP_Gemeinde/ags_. +- `GET` - gilt für alle Ressourcen - Client mit gültigem Token hat die Berechtigung für den Zugriff. diff --git a/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanWMS.adoc b/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanWMS.adoc index 88d77bf66b..a5d20bfe3d 100644 --- a/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanWMS.adoc +++ b/xplan-documentation/xplan-benutzerhandbuch/src/main/asciidoc/XPlanWMS.adoc @@ -23,7 +23,7 @@ Die folgende Tabelle gibt einen Überblick über die zur Verfügung stehenden Op |GetMap |Abfrage von Kartenbildern zu WMS Ebenen |GetFeatureInfo |Abfrage von Sachinformationen einzelner Objekte |GetLegendGraphic |Abfrage von Legendengrafiken einzelner Ebenen -|GetAttachment |Abfrage von Anhängen aus dem XPlanArchiv +|GetAttachment |Abfrage von Anhängen aus dem XPlanArchiv (veraltet) |=== [[xplanwms-adresse-des-dienstes]] @@ -274,6 +274,8 @@ Die Operation unterstützt folgende Parameter: http://<host>:<port>/xplan-services-wms/getAttachment?featureID=XPLAN_XP_RASTERPLANBASIS_7b36b0ee-5139-4a55-afc0-01fec18e9f0a&filename=Stellingen64.png ---- +IMPORTANT: Der Abruf von im XPlanGML referenzierten Anhängen über die Operation GetAttachment ist veraltet und wird in zukünftigen Versionen der xPlanBox entfernt. Stattdessen sollte die REST-API der Komponente XPlanDokumenteAPI verwendet werden. + [[xplanwms-koordinatenreferenzsysteme]] === Koordinatenreferenzsysteme diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/aktualisierung.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/aktualisierung.adoc index 4c19f7c93e..c9b4da7078 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/aktualisierung.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/aktualisierung.adoc @@ -42,7 +42,7 @@ cp ${WORK_DIR}/web/xplan-services-wfs.war <CATALINA_HOME>/webapps/ cp ${WORK_DIR}/web/xplan-services-wms.war <CATALINA_HOME>/webapps/ ---- -NOTE: Falls die Hintergrundkarte der Kartenvorschau im XPlanValidatorWeb angepasst wurde, müssen die Änderungen in der Datei _services-internet.template.json_ manuell in die neue Webapp _xplan-validator-web_ übertragen werden (s. <<kartenvorschau-validator>>). +NOTE: Falls die Hintergrundkarte der Kartenvorschau im XPlanValidatorWeb angepasst wurde, müssen die Änderungen in der Datei _services-internet.template.json_ manuell in die neue Webapp _xplan-validator-web_ übertragen werden (s. <<konfiguration-kartenvorschau-validator>>). [[neustart-tomcat]] === Neustart der Tomcat-Server diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/anhang/aktualisierung.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/anhang/aktualisierung.adoc index e49318f3c6..2649e01ebd 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/anhang/aktualisierung.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/anhang/aktualisierung.adoc @@ -33,7 +33,7 @@ Die Zuordnung der Anwendungskomponenten zu den jeweiligen Konfigurationen ist im ** _Anwendungs-Tomcat/webapps/xplan-manager-web/index.html_ anpassen ** _Anwendungs-Tomcat/webapps/xplan-manager-web/XPlanManager.jpg_ kopieren ** _Anwendungs-Tomcat/webapps/xplan-manager-web/XPlanMgrWeb.css_ kopieren - ** _Anwendungs-Tomcat/webapps/xplan-manager-web/WEB-INF/web.xml_ anpassen der Konfiguration, wenn der XPlanManagerWeb abgesichert ist (siehe Kapitel <<security>>) + ** _Anwendungs-Tomcat/webapps/xplan-manager-web/WEB-INF/web.xml_ anpassen der Konfiguration, wenn der XPlanManagerWeb abgesichert ist (siehe Kapitel <<konfiguration-security-manager>>) ** _Anwendungs-Tomcat/webapps/xplan-manager-web/WEB-INF/classes/security.properties_ anpassen * [ ] Folgende Dateien für XPlanValidator sichern und zurückspielen, bzw. vergleichen und anpassen: ** _Anwendungs-Tomcat/webapps/xplan-validator-web/index.html_ anpassen diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/installation/postinstallation.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/installation/postinstallation.adoc index eed98eb928..38849794c8 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/installation/postinstallation.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/installation/postinstallation.adoc @@ -6,10 +6,10 @@ Nach Abschluss der Installation sollten folgende Aktionen ausgeführt werden: . Absicherung der deegree webservice console (Ressource _/console_) für die Webapps _xplan-services-wms_, _xplan-services-wfs_, _xplan-services-wfs-syn_ und _xplan-webservices-inspireplu_ im _Dienste-Tomcat_ durch ein Kennwort (Datei _console.pw_ im deegree Workspace). . Absicherung der deegree REST-Schnittstelle (Ressource _/config_) für die Webapps _xplan-services-wms_, _xplan-services-wfs_, _xplan-services-wfs-syn_ und _xplan-webservices-inspireplu_ durch einen API-Key (Datei _config.apikey_ im Workspace-Verzeichnis, siehe Kapitel <<dienste-tomcat>>). . Absicherung des Zugriffs auf die deegree webservice console und deegree REST-Schnittstelle auf IP-Adressbereiche bzw. Domänen (Tomcat-Konfigurationsdatei _context.xml_ innerhalb der Webapps). -. Betriebs der Tomcat-Instanzen hinter einem Proxy z. B. Apache httpd oder nginx. -. Absicherung des Zugriffs auf den XPlanManagerWeb durch Benutzername und Kennwort (siehe Kapitel <<security>>). +. Betrieb der Tomcat-Instanzen hinter einem Proxy z. B. Apache httpd oder nginx. +. Prüfung der über den XPlanManagerAPI/-Web sowie XPlanValidatorAPI/-Web hochgeladenen Dateien auf Viren und Malware durch einen Proxy mit Virenscannerfunktion (z. B. https://www.clamav.net/[ClamAV]). +. Absicherung des Zugriffs auf den XPlanManagerWeb durch Benutzername und Kennwort (siehe Kapitel <<konfiguration-security-manager>>). . Absicherung der Komponente XPlanManagerAPI ebenfalls über Benutzername und Kennwort. -. Prüfung der über den XPlanManagerAPI/-Web sowie XPlanValidatorAPI/-Web hochgeladenen Dateien auf Viren und Malware durch einen Proxy mit Virenscannerfunktion. . Festlegung einer Obergrenze für die maximale Dateigröße auf Netzwerkebene, um den Upload von beliebig großen Dateien zu verhindern. CAUTION: Der Betrieb der xPlanBox *ohne* die Umsetzung dieser Maßnahmen kann die IT-Sicherheit der Anwendung gefährden! \ No newline at end of file diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/dienste/html_gfi.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/dienste/html_gfi.adoc index 4ef3be806a..65b8a92d65 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/dienste/html_gfi.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/dienste/html_gfi.adoc @@ -13,4 +13,6 @@ var WMS_URL = "http://localhost:8080/xplan-services-wms"; Eine Übersicht der weiteren Konfigurationsdateien des XPlanWMS ist im Anhang <<appendix_xplanwms-workspace>> zu finden. -TIP: Wenn die relativen Referenzen bereits beim Import durch absolute URLs ersetzt werden, wie im Kapitel <<konfiguration-externe-refrenzen>> beschrieben, ist keine Konfiguration in der Datei _html.gfi_ erforderlich und der Vorgabewert kann beibehalten werden. \ No newline at end of file +TIP: Wenn die relativen Referenzen bereits beim Import durch absolute URLs ersetzt werden, wie im Kapitel <<konfiguration-externe-refrenzen>> beschrieben, ist keine Konfiguration in der Datei _html.gfi_ erforderlich und der Vorgabewert kann beibehalten werden. + +IMPORTANT: Der Abruf von im XPlanGML referenzierten Anhängen über die Operation GetAttachment ist veraltet und wird in zukünftigen Versionen der xPlanBox entfernt. Stattdessen sollte der Abruf über absolute URLs erfolgen, wie im Abschnitt <<konfiguration-externe-refrenzen>> beschrieben. \ No newline at end of file diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/absicherung.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/absicherung.adoc index e71bc9386f..5f87f1277b 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/absicherung.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/absicherung.adoc @@ -1,7 +1,7 @@ -[[security]] +[[konfiguration-security-manager]] === Absicherung des XPlanManagerWeb -Der Zugriff auf die Komponente XPlanManagerWeb kann mittels Spring Security über BASIC-Authentication abgesichert werden. +Der Zugriff auf die Komponente XPlanManagerWeb kann über BASIC-Authentication mittels des Spring Security Frameworks abgesichert werden. Dabei stehen folgende Konfigurationsvarianten zur Verfügung: @@ -32,8 +32,8 @@ NOTE: Diese Konfiguration ist für beide Varianten erforderlich! Wenn der Servle Weitere Informationen zur Absicherung mit Spring Security sind Online in der Referenzdokumentation von Spring Security zu finden: -* https://docs.spring.io/spring-security/site/docs/5.2.x/reference/html5/#ns-getting-started[Servlet-Filter von Spring Security] -* https://docs.spring.io/spring-security/site/docs/5.2.x/reference/html5/#jc-authentication[Authentifizierung mit Spring Security] +* https://docs.spring.io/spring-security/reference/6.3/servlet/index.html[Servlet-Filter von Spring Security] +* https://docs.spring.io/spring-security/reference/6.3/servlet/authentication/index.html[Authentifizierung mit Spring Security] ==== Rollenbasierter Zugriff @@ -103,7 +103,7 @@ der Referenzdokumentation von Spring Security zu finden. Die Konfiguration eines UserService mit allen Optionen ist auch in der Referenzdokumentation von Spring Security beschrieben: -* https://docs.spring.io/spring-security/site/docs/5.2.x/reference/html5/#core-services-jdbc-user-service[Datenbank UserService] +https://docs.spring.io/spring-security/reference/6.3/servlet/authentication/passwords/jdbc.html#servlet-authentication-jdbc-schema[Datenbank UserService] [[disable_security]] ==== Absicherung deaktivieren diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/kartenvorschau.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/kartenvorschau.adoc index ab9a3b19ca..19cb697fa6 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/kartenvorschau.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/kartenvorschau.adoc @@ -1,4 +1,4 @@ -[[kartenvorschau]] +[[konfiguration-kartenvorschau-manager]] === Kartenvorschau Die nachfolgenden Konfigurationen müssen in der Datei _<XPLANBOX_CONFIG>/managerWebConfiguration.properties_ angepasst werden. diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/main.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/main.adoc index 39d05f1db5..08324c87d6 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/main.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/manager/main.adoc @@ -1,7 +1,7 @@ [[konfiguration-manager]] == Konfiguration des XPlanManagerWeb -In den nachfolgenden Kapiteln wird die Konfiguration des XPlanManagerWeb erläutert: +In den nachfolgenden Kapiteln wird die Konfiguration des XPlanManagerWeb erläutert. include::planliste.adoc[] diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/absicherung.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/absicherung.adoc new file mode 100644 index 0000000000..5820d34959 --- /dev/null +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/absicherung.adoc @@ -0,0 +1,27 @@ +[[konfiguration-security-rest]] +=== Absicherung der REST-API + +Alle REST-Schnittstellen der xPlanBox sind über das https://docs.spring.io/spring-security/reference/6.3/index.html[Spring Security Framework] abgesichert. + +Als Autorisierungsprotokoll wird OAuth 2.0 unterstützt und für das Format des Zugriffstokens das „JSON Web Token (JWT)“-Format. + +Um die Authentifizierung und Autorisierung von Aufrufen der REST-Schnittstellen zu aktivieren, muss das Spring-Profil `enableOAuth2JWT` für alle Komponenten aktiviert werden. + +==== Keycloak als Identity Provider + +Als Identity Provider muss die Open-Source-Software https://www.keycloak.org/[Keycloak] installiert und in der xPlanBox konfiguriert sein. + +Die vorbereitenden Schritte sind: + +1. Installation von Keycloak +2. Konfiguration eines Realm in Keycloak +3. Einrichtung der xPlanBox als Client im neu angelegten Realm +4. Anlegen von Rollen und Nutzern oder Einbindung einer Benutzerdatenbank o.a. in Keycloak + +Nachdem die vorbereitenden Schritte abgeschlossen sind, muss noch die OpenID Connect URL für die xPlanBox gesetzt werden. Die URL muss über die Umgebungsvariable `XPLAN_OAUTH2_JWT_URL` gesetzt werden. + +.Beispiel für die Konfiguration der OpenID Connect URL: +[source,properties] +---- +XPLAN_OAUTH2_JWT_URL=http://keycloak-host:8080/keycloak/realms/myrealm/protocol/openid-connect/certs +---- \ No newline at end of file diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/konfiguration.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/konfiguration.adoc new file mode 100644 index 0000000000..1c14da3c8a --- /dev/null +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/konfiguration.adoc @@ -0,0 +1,170 @@ +[[konfiguration-manager-api]] +=== XPlanManagerAPI + +Die Konfiguration der XPlanManagerAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/managerApiConfiguration.properties_. +Außerdem gelten die im Abschnitt <<konfiguration-manager>> beschriebenen Konfigurationsoptionen, die in der Datei _<XPLANBOX_CONFIG>/managerConfiguration.properties_ festgelegt werden. + +Folgende Konfigurationen können für die XPlanManagerAPI vorgenommen werden: + +==== API URL + +URL der XPlanManagerAPI, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration muss vorgenommen werden, andernfalls kann die Schnittstelle nicht verwendet werden und es kommt bereits beim Deployment der Webapp zu einem Fehler. +Beispiel: + +---- +apiUrl=https://xplanbox.lat-lon.de +---- + +==== Kontakt E-Mail-Adresse + +E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +contactEMailAddress=info@lat-lon.de +---- + +==== URL zu den "Terms of Service" + +URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +termsOfServiceUrl=https://opensource.org/tos/ +---- + +==== URL zur Dokumentation der xPlanBox + +URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ +---- + +==== WMS URL + +URL des XPlanwerkWMS, über den einzelne Pläne über die ManagerID angefragt werden können. +Beispiel: + +---- +wmsUrl=http://xplanbox.lat-lon.de/xplan-services-wms +---- + +==== Standard-Validierungseinstellungen + +Mit diesen Einstellungen kann das Validierungslevel konfiguriert werden, das beim Import eines Plans angewendet wird. +Standardmäßig müssen alle Tests (syntaktisch, semantisch und geometrisch) bestanden werden. +Mit dieser Option kann z. B. festgelegt werden, dass Pläne die Prüfung auf den Geltungsbereich nicht bestehen müssen, um diesen zu importieren. +Unabhängig von dieser Konfiguration muss die syntaktische Validierung in jedem Fall bestanden werden, ebenso werden Pläne mit schwerwiegenden geometrischen Fehlern grundsätzlich abgelehnt. + +Beispiel: + +---- +skipSemantisch=false +skipGeometrisch=false +skipFlaechenschluss=false +skipLaufrichtung=false +skipGeltungsbereich=true +---- + +NOTE: Ab der Version 8.0 ist die Validierung von Rasterdaten Teil der Validierung und wird beim Import mit ausgeführt. Für die Komponente XPlanValidatorAPI kann dieser Schritt über die Umgebungsvariable `XPLAN_RASTER_EVALUATION_SKIPPED=true` deaktiviert werden. + +[[konfiguration-validator-api]] +=== XPlanValidatorAPI + +Die Konfiguration der XPlanValidatorAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/validatorApiConfiguration.properties_. +Außerdem gelten die im Abschnitt <<konfiguration-validator>> beschriebenen Konfigurationsoptionen, die in der Datei _<XPLANBOX_CONFIG>/validatorConfiguration.properties_ festgelegt werden. +Folgende Konfiguration kann für die XPlanValidatorAPI vorgenommen werden: + +==== API URL + +URL der XPlanManagerAPI, die im OpenAPI Dokument ausgegeben wird. +Beispiel: + +---- +apiUrl=https://xplanbox.lat-lon.de +---- + +==== Kontakt E-Mail-Adresse + +E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +contactEMailAddress=info@lat-lon.de +---- + +==== URL zu den "Terms of Service" + +URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +termsOfServiceUrl=https://opensource.org/tos/ +---- + +==== URL zur Dokumentation der xPlanBox + +URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ +---- + +[[konfiguration-document-api]] +=== XPlanDokumenteAPI +Für die XPlanDokumenteAPI müssen die Angaben für die Datenbankverbindung über Umgebungsvariablen gesetzt werden: + +[source,properties] +---- +XPLAN_JDBC_URL=jdbc:postgresql://<host>:<port>/<dbname> <1> +XPLAN_DB_USER=$DB_USER <2> +XPLAN_DB_PASSWORD=$DB_PASSWORD <3> +---- +<1> Vollständige JDBC-URL zur XPlanDB +<2> Benutzername des `$DB_USER` +<3> Passwort für den `$DB_USER` + +Die Konfiguration der XPlanDokumenteAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/dokumenteApiConfiguration.properties_. + +Folgende Konfiguration kann für die XPlanDokumenteAPI vorgenommen werden. + +==== API URL + +URL der XPlanDokumenteAPI, die im OpenAPI Dokument ausgegeben wird. +Beispiel: + +---- +apiUrl=https://xplanbox.lat-lon.de +---- +Wird keine URL angegeben, dann wird eine relative URL ausgegeben + +==== Kontakt E-Mail-Adresse + +E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +contactEMailAddress=info@lat-lon.de +---- + +==== URL zu den "Terms of Service" + +URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +termsOfServiceUrl=https://opensource.org/tos/ +---- + +==== URL zur Dokumentation der xPlanBox + +URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. +Beispiel: + +---- +documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ +---- + diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/main.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/main.adoc index 86205f585e..6f78a80f96 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/main.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/rest-api/main.adoc @@ -1,176 +1,14 @@ [[konfiguration-rest-api]] == Konfiguration der REST-Schnittstellen -Die xPlanBox stellt die folgenden REST-Schnittstellen bereit: die XPlanValidatorAPI, XPlanManagerAPI und XPlanDokumenteAPI. +Die xPlanBox stellt die folgenden REST-Schnittstellen bereit: -TIP: Die REST-Schnittstellen von XPlanValidatorAPI und XPlanManagerAPI sind über Spring Security abgesichert. Um für einen Aufruf der REST-Schnittstellen die erfolgreiche Authentifizierung zu prüfen, muss das Spring-Profil `enableSecurity` für die Komponenten aktiviert werden. + - XPlanValidatorAPI, + - XPlanManagerAPI und + - XPlanDokumenteAPI. -[[konfiguration-manager-api]] -=== XPlanManagerAPI +In den nachfolgenden Kapiteln wird die Konfiguration und Absicherung der REST-API erläutert. -Die Konfiguration der XPlanManagerAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/managerApiConfiguration.properties_. -Außerdem gelten die im Abschnitt <<konfiguration-manager>> beschriebenen Konfigurationsoptionen, die in der Datei _<XPLANBOX_CONFIG>/managerConfiguration.properties_ festgelegt werden. +include::konfiguration.adoc[] -Folgende Konfigurationen können für die XPlanManagerAPI vorgenommen werden: - -==== API URL - -URL der XPlanManagerAPI, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration muss vorgenommen werden, andernfalls kann die Schnittstelle nicht verwendet werden und es kommt bereits beim Deployment der Webapp zu einem Fehler. -Beispiel: - ----- -apiUrl=https://xplanbox.lat-lon.de ----- - -==== Kontakt E-Mail-Adresse - -E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -contactEMailAddress=info@lat-lon.de ----- - -==== URL zu den "Terms of Service" - -URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -termsOfServiceUrl=https://opensource.org/tos/ ----- - -==== URL zur Dokumentation der xPlanBox - -URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ ----- - -==== WMS URL - -URL des XPlanwerkWMS, über den einzelne Pläne über die ManagerID angefragt werden können. -Beispiel: - ----- -wmsUrl=http://xplanbox.lat-lon.de/xplan-services-wms ----- - -==== Standard-Validierungseinstellungen - -Mit diesen Einstellungen kann das Validierungslevel konfiguriert werden, das beim Import eines Plans angewendet wird. -Standardmäßig müssen alle Tests (syntaktisch, semantisch und geometrisch) bestanden werden. -Mit dieser Option kann z. B. festgelegt werden, dass Pläne die Prüfung auf den Geltungsbereich nicht bestehen müssen, um diesen zu importieren. -Unabhängig von dieser Konfiguration muss die syntaktische Validierung in jedem Fall bestanden werden, ebenso werden Pläne mit schwerwiegenden geometrischen Fehlern grundsätzlich abgelehnt. - -Beispiel: - ----- -skipSemantisch=false -skipGeometrisch=false -skipFlaechenschluss=false -skipLaufrichtung=false -skipGeltungsbereich=true ----- - -NOTE: Ab der Version 8.0 ist die Validierung von Rasterdaten Teil der Validierung und wird beim Import mit ausgeführt. Für die Komponente XPlanValidatorAPI kann dieser Schritt über die Umgebungsvariable `XPLAN_RASTER_EVALUATION_SKIPPED=true` deaktiviert werden. - -[[konfiguration-validator-api]] -=== XPlanValidatorAPI - -Die Konfiguration der XPlanValidatorAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/validatorApiConfiguration.properties_. -Außerdem gelten die im Abschnitt <<konfiguration-validator>> beschriebenen Konfigurationsoptionen, die in der Datei _<XPLANBOX_CONFIG>/validatorConfiguration.properties_ festgelegt werden. -Folgende Konfiguration kann für die XPlanValidatorAPI vorgenommen werden: - -==== API URL - -URL der XPlanManagerAPI, die im OpenAPI Dokument ausgegeben wird. -Beispiel: - ----- -apiUrl=https://xplanbox.lat-lon.de ----- - -==== Kontakt E-Mail-Adresse - -E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -contactEMailAddress=info@lat-lon.de ----- - -==== URL zu den "Terms of Service" - -URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -termsOfServiceUrl=https://opensource.org/tos/ ----- - -==== URL zur Dokumentation der xPlanBox - -URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ ----- - -[[konfiguration-document-api]] -=== XPlanDokumenteAPI -Für die XPlanDokumenteAPI müssen die Angaben für die Datenbankverbindung über Umgebungsvariablen gesetzt werden: - -[source,properties] ----- -XPLAN_JDBC_URL=jdbc:postgresql://<host>:<port>/<dbname> <1> -XPLAN_DB_USER=$DB_USER <2> -XPLAN_DB_PASSWORD=$DB_PASSWORD <3> ----- -<1> Vollständige JDBC-URL zur XPlanDB -<2> Benutzername des `$DB_USER` -<3> Passwort für den `$DB_USER` - -Die Konfiguration der XPlanDokumenteAPI erfolgt in der Datei _<XPLANBOX_CONFIG>/dokumenteApiConfiguration.properties_. - -Folgende Konfiguration kann für die XPlanDokumenteAPI vorgenommen werden. - -==== API URL - -URL der XPlanDokumenteAPI, die im OpenAPI Dokument ausgegeben wird. -Beispiel: - ----- -apiUrl=https://xplanbox.lat-lon.de ----- -Wird keine URL angegeben, dann wird eine relative URL ausgegeben - -==== Kontakt E-Mail-Adresse - -E-Mail-Adresse des Kontakts, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -contactEMailAddress=info@lat-lon.de ----- - -==== URL zu den "Terms of Service" - -URL zu den "Terms of Services", die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -termsOfServiceUrl=https://opensource.org/tos/ ----- - -==== URL zur Dokumentation der xPlanBox - -URL zur Dokumentation, die im OpenAPI Dokument ausgegeben wird. Diese Konfiguration ist optional. -Beispiel: - ----- -documentationUrl=https://xplanbox.lat-lon.de/xPlanBox-Benutzerhandbuch/ ----- +include::absicherung.adoc[] \ No newline at end of file diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/kartenvorschau.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/kartenvorschau.adoc index a13d40e447..1248b54ac9 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/kartenvorschau.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/kartenvorschau.adoc @@ -1,4 +1,4 @@ -[[kartenvorschau-validator]] +[[konfiguration-kartenvorschau-validator]] === Kartenvorschau im XPlanValidatorWeb Die nachfolgende Konfiguration muss in der Datei _<XPLANBOX_CONFIG>/validatorConfiguration.properties_ angepasst werden. diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/main.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/main.adoc index 288e93f3d2..3412a028b5 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/main.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/konfiguration/validator/main.adoc @@ -1,7 +1,7 @@ [[konfiguration-validator]] == Konfiguration des XPlanValidatorWeb -In den nachfolgenden Kapiteln wird die Konfiguration des XPlanValidatorWeb erläutert: +In den nachfolgenden Kapiteln wird die Konfiguration des XPlanValidatorWeb erläutert. include::kartenvorschau.adoc[] diff --git a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/migration.adoc b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/migration.adoc index 5d306f1bcb..2492ece2b5 100644 --- a/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/migration.adoc +++ b/xplan-documentation/xplan-betriebshandbuch/src/main/asciidoc/migration.adoc @@ -19,7 +19,7 @@ Schlüssels `wmsUrl` angepasst werden: wmsUrl=http://<host>:<port>/xplan-services-wms/services ---- -Für mehr Details siehe Kapitel <<kartenvorschau>>. +Für mehr Details siehe Kapitel <<konfiguration-kartenvorschau-manager>>. *Anpassungen in der Datei managerConfiguration.properties:* diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/config/ApplicationContext.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/config/ApplicationContext.java index 70dfb0a52d..cd4cc2fb81 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/config/ApplicationContext.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/config/ApplicationContext.java @@ -104,7 +104,8 @@ import org.springframework.core.io.ResourceLoader; * @author <a href="mailto:friebe@lat-lon.de">Torsten Friebe</a> */ @Configuration -@ComponentScan(basePackages = { "de.latlon.xplanbox.api.manager.handler" }) +@ComponentScan(basePackages = { "de.latlon.xplanbox.api.manager.v1", "de.latlon.xplanbox.api.manager.v2", + "de.latlon.xplanbox.api.manager.handler" }) @Import({ SecurityContext.class, OAuth2JwtContext.class, JpaContext.class, AmazonS3RasterStorageContext.class, AmazonS3DocumentStorageContext.class, AmazonS3ValidationContext.class, RasterEvaluationContext.class }) public class ApplicationContext { diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/handler/PlanHandler.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/handler/PlanHandler.java index d98e96136e..7004d2e495 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/handler/PlanHandler.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/handler/PlanHandler.java @@ -29,6 +29,7 @@ import static org.slf4j.LoggerFactory.getLogger; import javax.xml.stream.XMLStreamException; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import de.latlon.xplan.commons.archive.XPlanArchive; @@ -48,6 +49,7 @@ import de.latlon.xplanbox.api.commons.exception.UnsupportedParameterValue; import de.latlon.xplanbox.api.manager.v1.model.Bereich; import de.latlon.xplanbox.api.manager.v1.model.Gemeinde; import de.latlon.xplanbox.api.manager.v1.model.StatusMessage; +import de.latlon.xplanbox.security.authorization.AgsAccessor; import jakarta.inject.Singleton; import jakarta.ws.rs.core.StreamingOutput; import org.apache.commons.lang3.StringUtils; @@ -61,7 +63,7 @@ import org.springframework.stereotype.Component; */ @Component @Singleton -public class PlanHandler { +public class PlanHandler implements AgsAccessor { private static final Logger LOG = getLogger(PlanHandler.class); @@ -76,6 +78,12 @@ public class PlanHandler { @Autowired private XPlanDao xPlanDao; + @Override + public Set<String> retrieveAgsFromPlan(String planId) { + List<Gemeinde> gemeinden = findGemeinden(planId); + return gemeinden.stream().map(Gemeinde::getAgs).collect(Collectors.toSet()); + } + public List<Integer> importPlanWithoutValidation(XPlanArchive xPlanArchive, String internalId, String planStatus) throws Exception { LOG.info("Importing plan into storage for '{}'", StringUtils.normalizeSpace(planStatus)); diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/openapi/AbstractApiConfig.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/openapi/AbstractApiConfig.java index 0f6d5c72b1..54914a1bc0 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/openapi/AbstractApiConfig.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/openapi/AbstractApiConfig.java @@ -61,6 +61,7 @@ public abstract class AbstractApiConfig extends ResourceConfig { public AbstractApiConfig(ServletContext servletContext, ManagerApiConfiguration managerApiConfiguration, Optional<BearerSecurityOpenApiWriter> bearerSecurityOpenApiWriter) { + property("jersey.config.server.response.setStatusOverSendError", true); property(ServerProperties.WADL_FEATURE_DISABLE, true); register(new ObjectMapperContextResolver()); diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanAenderungenApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanAenderungenApi.java index 448bad1156..ca422797ba 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanAenderungenApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanAenderungenApi.java @@ -36,6 +36,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the aenderungen resource of a plan. @@ -66,6 +67,7 @@ public class PlanAenderungenApi { return editAenderungenHandler.retrieveAenderungen(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Consumes({ "application/json" }) @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanApi.java index ea5972b2d7..3358949f2b 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanApi.java @@ -118,6 +118,8 @@ import jakarta.ws.rs.core.Variant; import org.apache.http.client.utils.URIBuilder; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Component; /** * Controller class for handling access to a plan identified by it's id. @@ -131,6 +133,7 @@ import org.springframework.beans.factory.annotation.Autowired; @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2020-08-28T13:42:47.160+02:00[Europe/Berlin]") @Deprecated +@Component public class PlanApi { private static final Logger LOG = getLogger(PlanApi.class); @@ -163,6 +166,7 @@ public class PlanApi { @Context private AbstractAsyncImportWrapper importWrapper; + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#body, 'ZIP', authentication)") @POST @Consumes({ "application/octet-stream", "application/zip", "application/x-zip", "application/x-zip-compressed" }) @Produces({ "application/json", XPLANBOX_NO_VERSION_JSON, XPLANBOX_V1_JSON, XPLANBOX_V2_JSON }) @@ -229,6 +233,7 @@ public class PlanApi { skipLaufrichtung, profiles, internalId, planStatus, body, ZIP); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#body, 'GML', authentication)") @POST @Consumes({ "text/xml", "application/gml+xml" }) @Produces({ "application/json", XPLANBOX_NO_VERSION_JSON, XPLANBOX_V1_JSON, XPLANBOX_V2_JSON }) @@ -246,6 +251,7 @@ public class PlanApi { skipLaufrichtung, profiles, internalId, planStatus, body, GML); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{planId}") @Produces({ "application/json", "application/xml" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanBasisdatenApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanBasisdatenApi.java index c5304e9da3..fe83278b5f 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanBasisdatenApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanBasisdatenApi.java @@ -39,6 +39,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the basisdaten resource of a plan. @@ -69,6 +70,7 @@ public class PlanBasisdatenApi { return convertToV1(editBasisdatenHandler.retrieveBasisdaten(planId)); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Consumes({ "application/json" }) @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanDokumentApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanDokumentApi.java index a21afd90ca..6957981cd8 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanDokumentApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanDokumentApi.java @@ -50,6 +50,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the dokument resource of a plan. @@ -81,6 +82,7 @@ public class PlanDokumentApi { return editDokumentHandler.retrieveDokumente(planId).stream().map(Dokument::convertToV1).toList(); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @POST @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @@ -130,6 +132,7 @@ public class PlanDokumentApi { return convertToV1(editDokumentHandler.retrieveDokument(planId, id)); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Path("/{id}") @Consumes({ "multipart/form-data" }) @@ -161,6 +164,7 @@ public class PlanDokumentApi { return convertToV1(editDokumentHandler.replaceDokument(planId, id, convertToV2(dokument), file)); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{id}") @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanGueltigkeitApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanGueltigkeitApi.java index 6098b1fc24..2b7ca58bd7 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanGueltigkeitApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanGueltigkeitApi.java @@ -36,6 +36,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the gueltigkeit resource of a plan. @@ -67,6 +68,7 @@ public class PlanGueltigkeitApi { return editGueltigkeitHandler.retrieveGueltigkeit(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Consumes({ "application/json" }) @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanRasterbasisApi.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanRasterbasisApi.java index d89d5aafa6..7ea67ead07 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanRasterbasisApi.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v1/PlanRasterbasisApi.java @@ -50,6 +50,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the rasterbasis resource of a plan. @@ -81,6 +82,7 @@ public class PlanRasterbasisApi { return editRasterbasisHandler.retrieveRasterbasis(planId).stream().map(Rasterbasis::convertToV1).toList(); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @POST @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @@ -137,6 +139,7 @@ public class PlanRasterbasisApi { return convertToV1(editRasterbasisHandler.retrieveRasterbasis(planId, id)); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Path("/{id}") @Consumes({ "multipart/form-data" }) @@ -176,6 +179,7 @@ public class PlanRasterbasisApi { georeferenzfile)); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{id}") @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanAenderungenApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanAenderungenApi2.java index ed44277443..b96ecd9c46 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanAenderungenApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanAenderungenApi2.java @@ -36,6 +36,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the aenderungen resource of a plan. @@ -64,6 +65,7 @@ public class PlanAenderungenApi2 { return editAenderungenHandler.retrieveAenderungen(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Consumes({ "application/json" }) @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanApi2.java index c0f361189e..cb8ec7387a 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanApi2.java @@ -78,6 +78,8 @@ import jakarta.ws.rs.core.Request; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.StreamingOutput; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Component; /** * Controller class for handling access to a plan identified by it's id. @@ -87,6 +89,7 @@ import org.springframework.beans.factory.annotation.Autowired; * @since 4.0 */ @Path("/plan") +@Component public class PlanApi2 { private static final boolean WITH_SKIP_GEOMETRISCH_VALIDATION = false; @@ -108,6 +111,7 @@ public class PlanApi2 { @Context private ServletContext servletContext; + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#body, 'ZIP', authentication)") @POST @Consumes({ "application/octet-stream", "application/zip", "application/x-zip", "application/x-zip-compressed" }) @Produces("application/json") @@ -168,6 +172,7 @@ public class PlanApi2 { profiles, internalId, planStatus, body, ValidationRequestedEvent.OriginFile.ZIP); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#body, 'GML', authentication)") @POST @Consumes({ "text/xml", "application/gml+xml" }) @Produces("application/json") @@ -186,6 +191,7 @@ public class PlanApi2 { profiles, internalId, planStatus, body, ValidationRequestedEvent.OriginFile.GML); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{planId}") @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanBasisdatenApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanBasisdatenApi2.java index b73e53ffa0..80d1a99fb5 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanBasisdatenApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanBasisdatenApi2.java @@ -36,6 +36,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the basisdaten resource of a plan. @@ -64,6 +65,7 @@ public class PlanBasisdatenApi2 { return editBasisdatenHandler.retrieveBasisdaten(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Consumes({ "application/json" }) @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanDokumentApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanDokumentApi2.java index 54e6af9cc3..4d94c835bd 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanDokumentApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanDokumentApi2.java @@ -47,6 +47,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the dokument resource of a plan. @@ -76,6 +77,7 @@ public class PlanDokumentApi2 { return editDokumentHandler.retrieveDokumente(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @POST @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @@ -125,6 +127,7 @@ public class PlanDokumentApi2 { return editDokumentHandler.retrieveDokument(planId, id); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Path("/{id}") @Consumes({ "multipart/form-data" }) @@ -156,6 +159,7 @@ public class PlanDokumentApi2 { return editDokumentHandler.replaceDokument(planId, id, dokument, file); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{id}") @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanRasterbasisApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanRasterbasisApi2.java index a03a789e74..babd1765fe 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanRasterbasisApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanRasterbasisApi2.java @@ -47,6 +47,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the rasterbasis resource of a plan. @@ -76,6 +77,7 @@ public class PlanRasterbasisApi2 { return editRasterbasisHandler.retrieveRasterbasis(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @POST @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @@ -131,6 +133,7 @@ public class PlanRasterbasisApi2 { return editRasterbasisHandler.retrieveRasterbasis(planId, id); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Path("/{id}") @Consumes({ "multipart/form-data" }) @@ -169,6 +172,7 @@ public class PlanRasterbasisApi2 { return editRasterbasisHandler.replaceRasterbasis(planId, id, rasterbasis, rasterfile, georeferenzfile); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @DELETE @Path("/{id}") @Produces({ "application/json" }) diff --git a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanTextApi2.java b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanTextApi2.java index 9c84801f92..f3bd23c681 100644 --- a/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanTextApi2.java +++ b/xplan-manager/xplan-manager-api/src/main/java/de/latlon/xplanbox/api/manager/v2/PlanTextApi2.java @@ -46,6 +46,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; /** * Controller class for handling access to the text resource of a plan. @@ -74,6 +75,7 @@ public class PlanTextApi2 { return editTextHandler.retrieveTexte(planId); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @POST @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @@ -118,6 +120,7 @@ public class PlanTextApi2 { return editTextHandler.retrieveText(planId, id); } + @PreAuthorize("hasRole('XPLANBOX_ADMIN') || @agsAuthorizer.hasAgs(#planId, authentication)") @PUT @Path("/{id}") @Consumes({ "multipart/form-data" }) diff --git a/xplan-manager/xplan-manager-web/src/main/java/de/latlon/xplan/manager/web/server/service/ManagerServiceImpl.java b/xplan-manager/xplan-manager-web/src/main/java/de/latlon/xplan/manager/web/server/service/ManagerServiceImpl.java index 86778a4075..129958c77b 100644 --- a/xplan-manager/xplan-manager-web/src/main/java/de/latlon/xplan/manager/web/server/service/ManagerServiceImpl.java +++ b/xplan-manager/xplan-manager-web/src/main/java/de/latlon/xplan/manager/web/server/service/ManagerServiceImpl.java @@ -20,6 +20,10 @@ */ package de.latlon.xplan.manager.web.server.service; +import java.io.File; +import java.util.List; +import java.util.ResourceBundle; + import com.google.gwt.user.server.rpc.jakarta.XsrfProtectedServiceServlet; import de.latlon.xplan.commons.archive.XPlanArchive; import de.latlon.xplan.manager.XPlanManager; @@ -33,23 +37,20 @@ import de.latlon.xplan.manager.web.shared.Rechtsstand; import de.latlon.xplan.manager.web.shared.RechtsstandAndPlanStatus; import de.latlon.xplan.manager.web.shared.XPlan; import de.latlon.xplan.manager.web.shared.edit.XPlanToEdit; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpSession; +import jakarta.validation.Valid; import org.apache.commons.lang3.StringUtils; import org.deegree.commons.utils.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.support.WebApplicationContextUtils; -import jakarta.servlet.ServletConfig; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpSession; -import jakarta.validation.Valid; -import java.io.File; -import java.util.List; -import java.util.ResourceBundle; - /** * REST-Interface for plan management. * @@ -107,6 +108,7 @@ public class ManagerServiceImpl extends XsrfProtectedServiceServlet implements M } @Override + @PreAuthorize("hasRole('ROLE_XPLAN_EDITOR') or hasRole('ROLE_XPLAN_SUPERUSER')") public XPlanToEdit getPlanToEdit(String planId) throws ManagerServiceImplException { getThreadLocalResponse().addHeader("Expires", "-1"); LOG.info("Retrieve plan with id {} to edit.", StringUtils.normalizeSpace(planId)); @@ -128,6 +130,7 @@ public class ManagerServiceImpl extends XsrfProtectedServiceServlet implements M } @Override + @PreAuthorize("hasRole('ROLE_XPLAN_EDITOR') or hasRole('ROLE_XPLAN_SUPERUSER')") public void editPlan(String planId, boolean updateRasterConfig, @Valid XPlanToEdit xPlanToEdit) throws ManagerServiceImplException { getThreadLocalResponse().addHeader("Expires", "-1"); @@ -169,6 +172,7 @@ public class ManagerServiceImpl extends XsrfProtectedServiceServlet implements M } @Override + @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public Boolean removePlanFromManager(String planId) throws ManagerServiceImplException { LOG.info("Try to remove plan with id {}.", planId); if (planId == null) @@ -203,6 +207,7 @@ public class ManagerServiceImpl extends XsrfProtectedServiceServlet implements M } @Override + @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public Boolean importPlan(String planId, boolean makeRasterConfig, PlanStatus planStatus) throws ManagerServiceImplException { getThreadLocalResponse().addHeader("Expires", "-1"); @@ -283,6 +288,7 @@ public class ManagerServiceImpl extends XsrfProtectedServiceServlet implements M } @Override + @PreAuthorize("hasRole('ROLE_XPLAN_SUPERUSER')") public Boolean publishPlan(String planId) throws ManagerServiceImplException { getThreadLocalResponse().addHeader("Expires", "-1"); LOG.info("Publish plan with id {} as INSPIRE dataset.", StringUtils.normalizeSpace(planId)); diff --git a/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/manager/ManagerPublicEventsIT.java b/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/manager/ManagerPublicEventsIT.java index 9b404be435..d50c5753bd 100644 --- a/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/manager/ManagerPublicEventsIT.java +++ b/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/manager/ManagerPublicEventsIT.java @@ -60,6 +60,15 @@ class ManagerPublicEventsIT extends AbstractRabbitITExecution { "{\"apiVersion\":\"1.0\",\"eventType\":\"SYNTACTIC_VALIDATION_FINISHED\",\"uuid\":\"" + r.uuid() + "\",\"valid\":true,\"error\":null}"); + ReceivedPublicEvent expectedEventRefValidationStarted = new ReceivedPublicEvent( + testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.referenzen", + "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_STARTED\",\"uuid\":\"" + r.uuid() + + "\",\"valid\":null,\"error\":null}"); + ReceivedPublicEvent expectedEventRefValidationFinished = new ReceivedPublicEvent( + testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.referenzen", + "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_FINISHED\",\"uuid\":\"" + r.uuid() + + "\",\"valid\":true,\"error\":null}"); + ReceivedPublicEvent expectedEventGeomValidationStarted = new ReceivedPublicEvent( testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.geometrisch", "{\"apiVersion\":\"1.0\",\"eventType\":\"GEOMETRIC_VALIDATION_STARTED\",\"uuid\":\"" + r.uuid() @@ -98,6 +107,7 @@ class ManagerPublicEventsIT extends AbstractRabbitITExecution { waitingIfNeeded(30, () -> assertThat(receivedEventsFor(r.uuid())).containsExactly(expectedEventValidationStarted, expectedEventSynValidationStarted, expectedEventSynValidationFinished, + expectedEventRefValidationStarted, expectedEventRefValidationFinished, expectedEventGeomValidationStarted, expectedEventGeomValidationFinished, expectedEventSemValidationStarted, expectedEventSemValidationFinished, expectedEventValidationFinished, expectedEventImportStarted, expectedEventImportFinished)); diff --git a/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/validator/ValidationPublicEventsIT.java b/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/validator/ValidationPublicEventsIT.java index e9fa44eb0a..f31d0fefdf 100644 --- a/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/validator/ValidationPublicEventsIT.java +++ b/xplan-tests/xplan-tests-integration/src/test/java/de/latlon/xplanbox/tests/rabbit/validator/ValidationPublicEventsIT.java @@ -60,6 +60,15 @@ class ValidationPublicEventsIT extends AbstractRabbitITExecution { "{\"apiVersion\":\"1.0\",\"eventType\":\"SYNTACTIC_VALIDATION_FINISHED\",\"uuid\":\"" + r.uuid() + "\",\"valid\":true,\"error\":null}"); + ReceivedPublicEvent expectedEventRefValidationStarted = new ReceivedPublicEvent( + testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.referenzen", + "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_STARTED\",\"uuid\":\"" + r.uuid() + + "\",\"valid\":null,\"error\":null}"); + ReceivedPublicEvent expectedEventRefValidationFinished = new ReceivedPublicEvent( + testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.referenzen", + "{\"apiVersion\":\"1.0\",\"eventType\":\"REFERENCES_FINISHED\",\"uuid\":\"" + r.uuid() + + "\",\"valid\":true,\"error\":null}"); + ReceivedPublicEvent expectedEventGeomValidationStarted = new ReceivedPublicEvent( testConfig.rabbitConfig().publicTopicRoutingPrefix() + "xplanbox.validation.geometrisch", "{\"apiVersion\":\"1.0\",\"eventType\":\"GEOMETRIC_VALIDATION_STARTED\",\"uuid\":\"" + r.uuid() @@ -85,6 +94,7 @@ class ValidationPublicEventsIT extends AbstractRabbitITExecution { waitingIfNeeded(20, () -> assertThat(receivedEventsFor(r.uuid())).containsExactly(expectedEventValidationStarted, expectedEventSynValidationStarted, expectedEventSynValidationFinished, + expectedEventRefValidationStarted, expectedEventRefValidationFinished, expectedEventGeomValidationStarted, expectedEventGeomValidationFinished, expectedEventSemValidationStarted, expectedEventSemValidationFinished, expectedEventValidationFinished)); diff --git a/xplan-tests/xplan-tests-soapui/README.md b/xplan-tests/xplan-tests-soapui/README.md index a6eb4fadc4..8b083486cf 100644 --- a/xplan-tests/xplan-tests-soapui/README.md +++ b/xplan-tests/xplan-tests-soapui/README.md @@ -25,10 +25,12 @@ mvn clean test -Psystem-tests -DtestFileName=xplan-manager-api-soapui-project.xm -DjdbcUrl=jdbc:postgresql://localhost:5433/xplanbox?user=xplanbox&password=xplanbox ``` -Bei Nutzung der Absicherung über ein Bearer Token muss zusätzlich die URL von z.B. Keycloak angegeben werden, um das JSON Web Token anzufragen: +Bei Nutzung der Absicherung über ein Bearer Token muss zusätzlich die URL von z.B. Keycloak angegeben werden, um das JSON Web Token anzufragen, der mit `-Dusername` und `-Dpassword` (s. oben) angegebenen Nutzer, muss der Rolle XPLANBOX_ADMIN zugeordnet sein: ``` --DjwtUrl=https://xplanbox.lat-lon.de/keycloak/realms/xplanbox/protocol/openid-connect/token -DjwtClientId=xplanbox-api +-DjwtUrl=https://xplanbox.lat-lon.de/keycloak/realms/xplanbox/protocol/openid-connect/token -DjwtClientId=xplanbox-api \ +-DusernameDortmund=userdortmund -DpasswordDortmund='PWD' -DusernameNotDortmund=usergelsenkirchen -DpasswordNotDortmund='PWD' ``` +Der Nutzer `-DusernameDortmund` muss einer Gruppe mit dem AGS 1731391860993 zugeordnet sein, der Nutzer `-DusernameNotDortmund` darf dagegen keiner Gruppe mit diesem AGS zugeordnet sein. ### xplan-dokumente-api-soapui-project diff --git a/xplan-tests/xplan-tests-soapui/pom.xml b/xplan-tests/xplan-tests-soapui/pom.xml index f44deb095e..cba4183c02 100644 --- a/xplan-tests/xplan-tests-soapui/pom.xml +++ b/xplan-tests/xplan-tests-soapui/pom.xml @@ -71,6 +71,10 @@ <baseUrlValidatorApi /> <username /> <password /> + <usernameDortmund /> + <passwordDortmund /> + <usernameNotDortmund /> + <passwordNotDortmund /> <jwtUrl /> <jwtClientId /> <apiKey /> @@ -130,6 +134,10 @@ <value>baseUrlValidatorApi=${baseUrlValidatorApi}</value> <value>username=${username}</value> <value>password=${password}</value> + <value>usernameDortmund=${usernameDortmund}</value> + <value>passwordDortmund=${passwordDortmund}</value> + <value>usernameNotDortmund=${usernameNotDortmund}</value> + <value>passwordNotDortmund=${passwordNotDortmund}</value> <value>jwtUrl=${jwtUrl}</value> <value>jwtClientId=${jwtClientId}</value> <value>apiKey=${apiKey}</value> diff --git a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-dokumente-api-soapui-project.xml b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-dokumente-api-soapui-project.xml index 368425076a..93bf967e0a 100644 --- a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-dokumente-api-soapui-project.xml +++ b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-dokumente-api-soapui-project.xml @@ -25,7 +25,7 @@ baseUrlManagerApi=http://localhost:8086/xplan-manager-api Set this if Keycloak authentication shall be used locally: jwtUrl=http://localhost:8096/keycloak/realms/xplanbox/protocol/openid-connect/token -jwtClientId=xplan-dokumente-api +jwtClientId=xplanbox-api For execution against test environment use following property values: diff --git a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api-soapui-project.xml b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api-soapui-project.xml index e571129cc1..1c07be3e89 100644 --- a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api-soapui-project.xml +++ b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api-soapui-project.xml @@ -22,7 +22,7 @@ baseUrlManagerApi=http://localhost:8086 jwtUrl=http://localhost:8096/keycloak/realms/xplanbox/protocol/openid-connect/token -jwtClientId=xplan-manager-api +jwtClientId=xplanbox-api jdbcUrl=jdbc:postgresql://localhost:5433/xplanbox?user=xplanbox&password=xplanbox</con:description> <con:settings/> <con:interface xsi:type="con:RestService" id="4c3b4b1f-f0cd-4a9f-bbc4-433948e85871" wadlVersion="http://wadl.dev.java.net/2009/02" name="XPlanManagerAPI" type="rest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> @@ -2121,15 +2121,18 @@ testRunner.testCase.testSuite.project.testSuiteList.each testSuite.testCaseList.each { testCase -> - testCase.testSteps.each - { - testStep-> - var testStepValue = testStep.getValue() - if (testStepValue instanceof HttpTestRequestStep || testStepValue instanceof RestTestRequestStep){ - def request = testStepValue.getHttpRequest() - def headers = request.getRequestHeaders() - headers.put("Authorization", authHeader) - request.setRequestHeaders(headers) + var testCaseName = testCase.getName() + if (!testCaseName.equals("Security with JWT TestCase")){ + testCase.testSteps.each + { + testStep-> + var testStepValue = testStep.getValue() + if (testStepValue instanceof HttpTestRequestStep || testStepValue instanceof RestTestRequestStep){ + def request = testStepValue.getHttpRequest() + def headers = request.getRequestHeaders() + headers.put("Authorization", authHeader) + request.setRequestHeaders(headers) + } } } } @@ -33422,6 +33425,648 @@ if( ++context.loopIndex < 40 && json.status != "IMPORT_FINISHED" ){ </con:property> </con:properties> </con:testCase> + <con:testCase id="3513a1c3-69fb-41be-bb51-7f7fa52d8782" failOnError="false" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Security with JWT TestCase" searchProperties="true" timeout="0" wsrmEnabled="false" wsrmVersion="1.0" wsrmAckTo="" amfAuthorisation="false" amfEndpoint="" amfLogin="" amfPassword=""> + <con:settings/> + <con:testStep type="groovy" name="checkPreconditions" id="944d7ad1-7315-4b62-b047-30c52ffcafa9"> + <con:settings/> + <con:config> + <script>def jwtUrl = context.testCase.testSuite.project.getPropertyValue("jwtUrl"); +def usernameNotDortmund = context.testCase.testSuite.project.getPropertyValue("usernameNotDortmund"); +def usernameDortmund = context.testCase.testSuite.project.getPropertyValue("usernameDortmund"); +def test_ = null; + +// jwtUrl, usernameNotDortmund and usernameDortmund are required for this TesCase +if (jwtUrl == "" || usernameNotDortmund == "" || usernameDortmund == ""){ + log.info "TestCase is skipped: jwtUrl, usernameNotDortmund and usernameDortmund are required." + testRunner.gotoStepByName("Cleanup Properties"); +}</script> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="GET XX X.X XX openAPI" id="99c43ad1-8869-4cee-bd93-f84920c9ccbe"> + <con:settings/> + <con:config method="GET" xsi:type="con:HttpRequest" id="4d61face-75e6-4117-8d95-8b1e7dd45d2e" name="GET XX X.X XX openAPI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="2f43fbe9-d109-43b0-beb7-c8ed78bed226" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Match" id="31b6521b-7a41-46be-9040-38c3f4655011" name="openapi"> + <con:configuration> + <path>$.openapi</path> + <content>3.0.1</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="dcb84152-4fe9-4776-8673-334ea542c0cc" name="JsonPath Existence Match"> + <con:configuration> + <path>$.security[0].Bearer</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Match" id="44032b4a-affb-40ed-b9ce-dc86c24659bf" name="securitySchemes.Bearer.scheme"> + <con:configuration> + <path>$.components.securitySchemes.Bearer.scheme</path> + <content>bearer</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Match" id="44032b4a-affb-40ed-b9ce-dc86c24659bf" name="securitySchemes.Bearer.bearerFormat"> + <con:configuration> + <path>$.components.securitySchemes.Bearer.bearerFormat</path> + <content>JWT</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="retrieveToken - userNotDortmund" id="6ca8698e-6b61-4c6a-8308-d075c66605ac"> + <con:settings/> + <con:config method="POST" xsi:type="con:HttpRequest" id="951ebbc5-a5ba-418e-a699-aade30608a45" name="retrieveToken - userNotDortmund" postQueryString="true" mediaType="application/x-www-form-urlencoded" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Content-Type" value="application/x-www-form-urlencoded" xmlns="http://eviware.com/soapui/config"/></con:setting> + </con:settings> + <con:endpoint>${#Project#jwtUrl}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="db5ca4f1-f21a-4b5d-b819-c41465665b8d" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="b7016630-f4e7-44ff-85ef-83ded553be27" name="access_token"> + <con:configuration> + <path>$.access_token</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <con:parameter> + <con:name>client_id</con:name> + <con:value>${#Project#jwtClientId}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>username</con:name> + <con:value>${#Project#usernameNotDortmund}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>password</con:name> + <con:value>${#Project#passwordNotDortmund}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>grant_type</con:name> + <con:value>password</con:value> + <con:style>QUERY</con:style> + </con:parameter> + </con:parameters> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="retrieveToken - userDortmund" id="2a92ea6f-2609-4118-a9bb-403eaeb03ec3"> + <con:settings/> + <con:config method="POST" xsi:type="con:HttpRequest" id="951ebbc5-a5ba-418e-a699-aade30608a45" name="retrieveToken - userDortmund" postQueryString="true" mediaType="application/x-www-form-urlencoded" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><entry key="Content-Type" value="application/x-www-form-urlencoded" xmlns="http://eviware.com/soapui/config"/></con:setting> + </con:settings> + <con:endpoint>${#Project#jwtUrl}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="db5ca4f1-f21a-4b5d-b819-c41465665b8d" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="f7fffe97-95dc-47a4-9d59-5e71772747a2" name="access_token"> + <con:configuration> + <path>$.access_token</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <con:parameter> + <con:name>client_id</con:name> + <con:value>${#Project#jwtClientId}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>username</con:name> + <con:value>${#Project#usernameDortmund}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>password</con:name> + <con:value>${#Project#passwordDortmund}</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>grant_type</con:name> + <con:value>password</con:value> + <con:style>QUERY</con:style> + </con:parameter> + </con:parameters> + </con:config> + </con:testStep> + <con:testStep type="transfer" name="retrieveToken Property Transfer" id="ff2c6a7b-441f-48a3-b1cc-cfe94792fc48"> + <con:settings/> + <con:config xsi:type="con:PropertyTransfersStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>accessToken_notDortmund</con:name> + <con:sourceType>Response</con:sourceType> + <con:sourceStep>retrieveToken - userNotDortmund</con:sourceStep> + <con:sourcePath>$.access_token</con:sourcePath> + <con:targetType>tokenNotDortmund</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:type>JSONPATH</con:type> + <con:targetTransferType>JSONPATH</con:targetTransferType> + <con:upgraded>true</con:upgraded> + </con:transfers> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>accessToken_Dortmund</con:name> + <con:sourceType>Response</con:sourceType> + <con:sourceStep>retrieveToken - userDortmund</con:sourceStep> + <con:sourcePath>$.access_token</con:sourcePath> + <con:targetType>tokenDortmund</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:type>JSONPATH</con:type> + <con:targetTransferType>JSONPATH</con:targetTransferType> + <con:upgraded>true</con:upgraded> + </con:transfers> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan Dortmund" id="096344ea-829f-49cc-b156-90a073a6f69b"> + <con:settings/> + <con:config method="POST" xsi:type="con:HttpRequest" id="fb82fa77-b86e-45f2-8c0f-866cb490b0d1" name="POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan Dortmund" postQueryString="false" mediaType="application/gml+xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenDortmund}"/> + <con:entry key="X-Filename" value="soapui-test"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/plan</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="de44e7cd-c4f2-4f55-90d8-367bea84ef1e" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="8b1c937c-2310-49dc-8b48-114ced3fabf3" name="uuidExists"> + <con:configuration> + <path>$.uuid</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="8b1c937c-2310-49dc-8b48-114ced3fabf3" name="statusLinkExists"> + <con:configuration> + <path>$.statusLink</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="8b1c937c-2310-49dc-8b48-114ced3fabf3" name="hrefExists"> + <con:configuration> + <path>$.statusLink.href</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:attachment> + <con:name>FP_6.0.2.zip</con:name> + <con:contentType>application/gml+xml</con:contentType> + <con:contentId>BP_6.0_Dortmund.gml</con:contentId> + <con:url>${projectDir}/xplan-manager-api/plans/BP_6.0_Dortmund.gml</con:url> + <con:id>e65ee7a4-20dd-461e-a899-ae69d9a90731</con:id> + </con:attachment> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <con:parameter> + <con:name>skipSemantisch</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipFlaechenschluss</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipGeltungsbereich</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipLaufrichtung</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter required="false" disableUrlEncoding="false"> + <con:name>internalId</con:name> + <con:value>soapui-test-id</con:value> + <con:style>QUERY</con:style> + <con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type> + <con:default/> + <con:description xsi:nil="true"/> + </con:parameter> + <con:parameter> + <con:name>planStatus</con:name> + <con:value>FESTGESTELLT</con:value> + <con:style>QUERY</con:style> + </con:parameter> + </con:parameters> + </con:config> + </con:testStep> + <con:testStep type="transfer" name="POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan Dortmund Property Transfer" id="1260d6ea-30ff-4335-88f4-b18d7f1072e1"> + <con:settings/> + <con:config xsi:type="con:PropertyTransfersStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>uuid</con:name> + <con:sourceType>Response</con:sourceType> + <con:sourceStep>POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan Dortmund</con:sourceStep> + <con:sourcePath>$.uuid</con:sourcePath> + <con:targetType>uuid</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:type>JSONPATH</con:type> + <con:targetTransferType>JSONPATH</con:targetTransferType> + <con:upgraded>true</con:upgraded> + </con:transfers> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="GET BP 6.0 XX pollStatus" id="d5be5a89-a60b-4eec-925b-f27211edc058"> + <con:settings/> + <con:config method="GET" xsi:type="con:HttpRequest" id="d219264b-19a2-4e32-bda8-d1d431e563e9" name="GET BP 6.0 XX pollStatus" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenDortmund}"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/status/${#TestCase#uuid}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="706a255f-d031-4dfe-b078-d7098c7d2b4a" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="8c1a42b6-d7c1-4c77-91c6-b7d4c3fc4530" name="statusExists"> + <con:configuration> + <path>$.status</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:config> + </con:testStep> + <con:testStep type="groovy" name="pollStatus" id="57e7f4b6-2328-44bd-9d31-ce4c4d46603a"> + <con:settings/> + <con:config> + <script>import groovy.json.JsonSlurper + +def testStepName = "GET BP 6.0 XX pollStatus" +def response = testRunner.testCase.getTestStepByName(testStepName).getPropertyValue("Response") +def json = new JsonSlurper().parseText(response) + +if( context.loopIndex == null ) + context.loopIndex = 0 + +if( ++context.loopIndex < 40 && json.status != "IMPORT_FINISHED" ){ + sleep(1000) + testRunner.gotoStepByName(testStepName) +} else if (context.loopIndex == 40) { + context.loopIndex = null + assert(false) +} else { + context.loopIndex = null +}</script> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="GET BP 6.0 XX retrieveStatus" id="9bfe235c-59a6-497d-ad95-17ab133d565e"> + <con:settings/> + <con:config method="GET" xsi:type="con:HttpRequest" id="d219264b-19a2-4e32-bda8-d1d431e563e9" name="GET BP 6.0 XX retrieveStatus" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenDortmund}"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/status/${#TestCase#uuid}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="706a255f-d031-4dfe-b078-d7098c7d2b4a" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Match" id="d27fd88e-b78e-4e28-acfc-dc25276fc1a1" name="status"> + <con:configuration> + <path>$.status</path> + <content>IMPORT_FINISHED</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="320f668b-21ff-4589-a944-cfbd07931e2a" name="importedPlanIdsExists"> + <con:configuration> + <path>$.importedPlanIds</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="493b851d-f4cf-4289-90b8-3cb49d482b72" name="linksExists"> + <con:configuration> + <path>$.links</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:assertion type="JsonPath Existence Match" id="a9ed262c-75d6-4a67-ad13-5b40ce1eb9ac" name="hrefExists"> + <con:configuration> + <path>$.links[0].href</path> + <content>true</content> + <allowWildcards>false</allowWildcards> + <ignoreNamspaceDifferences>false</ignoreNamspaceDifferences> + <ignoreComments>false</ignoreComments> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:config> + </con:testStep> + <con:testStep type="transfer" name="GET BP 6.0 XX retrieveStatus Property Transfer" id="8d42c117-258d-4cda-b4a0-e58fcd034701"> + <con:settings/> + <con:config xsi:type="con:PropertyTransfersStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>planId</con:name> + <con:sourceType>Response</con:sourceType> + <con:sourceStep>GET BP 6.0 XX retrieveStatus</con:sourceStep> + <con:sourcePath>$.importedPlanIds[0]</con:sourcePath> + <con:targetType>planId</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:type>JSONPATH</con:type> + <con:targetTransferType>JSONPATH</con:targetTransferType> + <con:upgraded>true</con:upgraded> + </con:transfers> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan NotDortmund ExpectError403" id="4d50db5e-fbf3-48ff-824b-899f510f608a"> + <con:settings/> + <con:config method="POST" xsi:type="con:HttpRequest" id="fb82fa77-b86e-45f2-8c0f-866cb490b0d1" name="POST BP 6.0 xF,sS,sF,sG,sL,iI,pS importPlan NotDortmund ExpectError403" postQueryString="false" mediaType="application/gml+xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenNotDortmund}"/> + <con:entry key="X-Filename" value="soapui-test"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/plan</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="de44e7cd-c4f2-4f55-90d8-367bea84ef1e" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>403</codes> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:attachment> + <con:name>FP_6.0.2.zip</con:name> + <con:contentType>application/gml+xml</con:contentType> + <con:contentId>BP_6.0_Dortmund.gml</con:contentId> + <con:url>${projectDir}/xplan-manager-api/plans/BP_6.0_Dortmund.gml</con:url> + <con:id>e65ee7a4-20dd-461e-a899-ae69d9a90731</con:id> + </con:attachment> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <con:parameter> + <con:name>skipSemantisch</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipFlaechenschluss</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipGeltungsbereich</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter> + <con:name>skipLaufrichtung</con:name> + <con:value>true</con:value> + <con:style>QUERY</con:style> + </con:parameter> + <con:parameter required="false" disableUrlEncoding="false"> + <con:name>internalId</con:name> + <con:value>soapui-test-id</con:value> + <con:style>QUERY</con:style> + <con:type xmlns:xs="http://www.w3.org/2001/XMLSchema">xs:string</con:type> + <con:default/> + <con:description xsi:nil="true"/> + </con:parameter> + <con:parameter> + <con:name>planStatus</con:name> + <con:value>FESTGESTELLT</con:value> + <con:style>QUERY</con:style> + </con:parameter> + </con:parameters> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="DEL BP 6.0 pI deletePlan NotDortmund ExpectError403" id="423c27d1-2b83-42de-ad24-1dc5b3eac232"> + <con:settings/> + <con:config method="DELETE" xsi:type="con:HttpRequest" id="bb47d485-53e8-420a-b18d-620a3ba2b7e3" name="DEL BP 6.0 pI deletePlan NotDortmund ExpectError403" postQueryString="false" mediaType="application/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenNotDortmund}"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/plan/${#TestCase#planId}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="a8bfebc1-8840-4207-86e3-e063ec337347" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>403</codes> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:config> + </con:testStep> + <con:testStep type="httprequest" name="DEL BP 6.0 pI deletePlan Dortmund" id="e86f4623-54f5-4918-a223-923302bc98b2"> + <con:settings/> + <con:config method="DELETE" xsi:type="con:HttpRequest" id="bb47d485-53e8-420a-b18d-620a3ba2b7e3" name="DEL BP 6.0 pI deletePlan Dortmund" postQueryString="false" mediaType="application/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment xmlns:con="http://eviware.com/soapui/config"> + <con:entry key="Authorization" value="Bearer ${#TestCase#tokenDortmund}"/> + <con:entry key="Accept" value="application/json"/> +</xml-fragment></con:setting> + </con:settings> + <con:endpoint>${#Project#baseUrlManagerApi}/xplan-manager-api/api/v2/plan/${#TestCase#planId}</con:endpoint> + <con:request/> + <con:assertion type="Valid HTTP Status Codes" id="a8bfebc1-8840-4207-86e3-e063ec337347" name="Valid HTTP Status Codes"> + <con:configuration> + <codes>200</codes> + </con:configuration> + </con:assertion> + <con:credentials> + <con:username>${#Project#username}</con:username> + <con:password>${#Project#password}</con:password> + <con:selectedAuthProfile>No Authorization</con:selectedAuthProfile> + <con:preemptive>true</con:preemptive> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:config> + </con:testStep> + <con:testStep type="transfer" name="Cleanup Properties" id="5ff8fe08-a8f9-4a90-8062-d37fd1821891"> + <con:settings/> + <con:config xsi:type="con:PropertyTransfersStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>tokenNotDortmund</con:name> + <con:sourceType>empty</con:sourceType> + <con:sourceStep>#TestCase#</con:sourceStep> + <con:targetType>tokenNotDortmund</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:upgraded>true</con:upgraded> + </con:transfers> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>tokenDortmund</con:name> + <con:sourceType>empty</con:sourceType> + <con:sourceStep>#TestCase#</con:sourceStep> + <con:targetType>tokenDortmund</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:upgraded>true</con:upgraded> + </con:transfers> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>uuid</con:name> + <con:sourceType>empty</con:sourceType> + <con:sourceStep>#TestCase#</con:sourceStep> + <con:targetType>uuid</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:upgraded>true</con:upgraded> + </con:transfers> + <con:transfers setNullOnMissingSource="true" transferTextContent="true" failOnError="true" ignoreEmpty="false" transferToAll="false" entitize="false" transferChildNodes="false"> + <con:name>planId</con:name> + <con:sourceType>empty</con:sourceType> + <con:sourceStep>#TestCase#</con:sourceStep> + <con:targetType>planId</con:targetType> + <con:targetStep>#TestCase#</con:targetStep> + <con:upgraded>true</con:upgraded> + </con:transfers> + </con:config> + </con:testStep> + <con:properties> + <con:property> + <con:name>empty</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>tokenNotDortmund</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>tokenDortmund</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>uuid</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>planId</con:name> + <con:value/> + </con:property> + </con:properties> + </con:testCase> <con:properties/> </con:testSuite> <con:testSuite id="edf19815-b8a9-4442-add6-cc60cd71da38" name="Cleanup"> @@ -33441,15 +34086,18 @@ testRunner.testCase.testSuite.project.testSuiteList.each testSuite.testCaseList.each { testCase -> - testCase.testSteps.each - { - testStep-> - var testStepValue = testStep.getValue() - if (testStepValue instanceof HttpTestRequestStep || testStepValue instanceof RestTestRequestStep){ - def request = testStepValue.getHttpRequest() - def headers = request.getRequestHeaders() - headers.remove("Authorization") - request.setRequestHeaders(headers) + var testCaseName = testCase.getName() + if (!testCaseName.equals("Security with JWT TestCase")){ + testCase.testSteps.each + { + testStep-> + var testStepValue = testStep.getValue() + if (testStepValue instanceof HttpTestRequestStep || testStepValue instanceof RestTestRequestStep){ + def request = testStepValue.getHttpRequest() + def headers = request.getRequestHeaders() + headers.remove("Authorization") + request.setRequestHeaders(headers) + } } } } @@ -33488,6 +34136,22 @@ testRunner.testCase.testSuite.project.testSuiteList.each <con:name>jdbcUrl</con:name> <con:value/> </con:property> + <con:property> + <con:name>usernameNotDortmund</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>passwordNotDortmund</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>usernameDortmund</con:name> + <con:value/> + </con:property> + <con:property> + <con:name>passwordDortmund</con:name> + <con:value/> + </con:property> </con:properties> <con:wssContainer/> <con:oAuth2ProfileContainer/> diff --git a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api/plans/BP_6.0_Dortmund.gml b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api/plans/BP_6.0_Dortmund.gml new file mode 100644 index 0000000000..fe0e31157f --- /dev/null +++ b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-manager-api/plans/BP_6.0_Dortmund.gml @@ -0,0 +1,400 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<!-- + Testfälle + - versionBauGB in BP_Plan + - XP_SpezExterneReferenz mit Pflichtattributen +--> +<xplan:XPlanAuszug xmlns:xplan="http://www.xplanung.de/xplangml/6/0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wfs="http://www.opengis.net/wfs" gml:id="GML_f343e75d-107b-493b-8c0a-8ba23b8e7466" xsi:schemaLocation="http://www.xplanung.de/xplangml/6/0 https://repository.gdi-de.org/schemas/de.xleitstelle.xplanung/6.0/XPlanung-Operationen.xsd"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <gml:featureMember> + <xplan:BP_Plan gml:id="GML_bf2168c4-c292-4340-bc50-7a2aa2cab5be"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:name>BPlan002_6-0_SoapUI-XPlanManagerAPI</xplan:name> + <xplan:beschreibung>Testdaten</xplan:beschreibung> + <xplan:technHerstellDatum>2021-07-01</xplan:technHerstellDatum> + <xplan:erstellungsMassstab>1000</xplan:erstellungsMassstab> + <xplan:raeumlicherGeltungsbereich> + <gml:MultiSurface srsName="EPSG:25832" gml:id="GML_a4b76c05-e841-441f-9284-0d28c0bd2502"> + <gml:surfaceMember> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_63208495-2dad-4690-a072-f31868f7eece"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="5">564984.128 5940442.486 565072.441 5940442.486 565072.441 5940522.630 564984.128 5940522.630 564984.128 5940442.486 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </gml:surfaceMember> + </gml:MultiSurface> + </xplan:raeumlicherGeltungsbereich> + <xplan:gemeinde> + <xplan:XP_Gemeinde> + <xplan:ags>05913000</xplan:ags> + <xplan:gemeindeName>Stadt Dortmund</xplan:gemeindeName> + </xplan:XP_Gemeinde> + </xplan:gemeinde> + <xplan:planArt>1000</xplan:planArt> + <xplan:sonstPlanArt codeSpace="https://registry.gdi-de.org/codelist/de.xleitstelle.xplanung/BP_SonstPlanArt" >9999_4</xplan:sonstPlanArt> + <xplan:rechtsstand>3000</xplan:rechtsstand> + <xplan:staedtebaulicherVertrag>false</xplan:staedtebaulicherVertrag> + <xplan:erschliessungsVertrag>false</xplan:erschliessungsVertrag> + <xplan:durchfuehrungsVertrag>false</xplan:durchfuehrungsVertrag> + <xplan:gruenordnungsplan>false</xplan:gruenordnungsplan> + <xplan:versionBauGB> + <xplan:XP_GesetzlicheGrundlage> + <xplan:name>BaugGB</xplan:name> + <xplan:datum>2004-03-02</xplan:datum> + <xplan:detail>§10</xplan:detail> + </xplan:XP_GesetzlicheGrundlage> + </xplan:versionBauGB> + <xplan:bereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + </xplan:BP_Plan> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_Bereich gml:id="GML_95a8b21b-8754-4350-9041-213259262fd8"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:nummer>0</xplan:nummer> + <xplan:planinhalt xlink:href="#GML_51e17233-d921-46cb-83b9-af28451186a1" /> + <xplan:planinhalt xlink:href="#GML_b4176441-d7e7-435c-87ae-27360e8cb4d6" /> + <xplan:planinhalt xlink:href="#GML_fa0eea57-ebb1-4d50-b205-95865d6b9284" /> + <xplan:planinhalt xlink:href="#GML_b5f66983-6732-4cdc-8910-ba4d40a060e8" /> + <xplan:planinhalt xlink:href="#GML_06f9b5b2-8051-4f03-9dc3-50ba956a2670" /> + <xplan:planinhalt xlink:href="#GML_3b987a05-5df3-42ed-ba22-b1b04bf58bf0" /> + <xplan:planinhalt xlink:href="#GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419" /> + <xplan:planinhalt xlink:href="#GML_c8fa8ddd-d5de-4111-9489-03967eec715e" /> + <xplan:praesentationsobjekt xlink:href="#GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3" /> + <xplan:praesentationsobjekt xlink:href="#GML_458852b4-0f35-4405-b3be-90bb70688ddd" /> + <xplan:praesentationsobjekt xlink:href="#GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a" /> + <xplan:praesentationsobjekt xlink:href="#GML_22989f35-59e8-4260-8c60-e706b916a886" /> + <xplan:verfahren>1000</xplan:verfahren> + <xplan:gehoertZuPlan xlink:href="#GML_bf2168c4-c292-4340-bc50-7a2aa2cab5be" /> + </xplan:BP_Bereich> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_BaugebietsTeilFlaeche gml:id="GML_51e17233-d921-46cb-83b9-af28451186a1"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565011.438 5940447.733</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_22989f35-59e8-4260-8c60-e706b916a886" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_2ada5f26-230c-4dfe-ac97-f62ba56a6f3c"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="15">565065.689 5940482.457 565064.406 5940485.989 565055.484 5940510.564 565050.619 5940511.714 565048.163 5940509.388 565024.500 5940486.984 565011.438 5940474.619 565016.424 5940469.350 565020.516 5940465.024 565028.611 5940456.469 565029.337 5940457.156 565038.252 5940447.733 565053.250 5940456.591 565072.441 5940463.556 565065.689 5940482.457 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:besondereArtDerBaulNutzung>1200</xplan:besondereArtDerBaulNutzung> + </xplan:BP_BaugebietsTeilFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:SO_Gebiet gml:id="GML_b4176441-d7e7-435c-87ae-27360e8cb4d6"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565034.802 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940463.556</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:externeReferenz> + <xplan:XP_SpezExterneReferenz> + <xplan:art>Dokument</xplan:art> + <xplan:referenzName>Test</xplan:referenzName> + <xplan:referenzURL>http://www.foo.bar/test.pdf</xplan:referenzURL> + <xplan:typ>3100</xplan:typ> + </xplan:XP_SpezExterneReferenz> + </xplan:externeReferenz> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_de0f8d0d-9d94-4679-ae91-08b6347dafae"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="6">565072.441 5940463.556 565053.250 5940456.591 565038.252 5940447.733 565034.802 5940442.486 565072.441 5940442.486 565072.441 5940463.556 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>false</xplan:flaechenschluss> + <xplan:gemeinde> + <xplan:XP_Gemeinde> + <xplan:ags>02000000</xplan:ags> + <xplan:gemeindeName>Freie und Hansestadt Hamburg</xplan:gemeindeName> + </xplan:XP_Gemeinde> + </xplan:gemeinde> + <xplan:gebietsArt>2300</xplan:gebietsArt> + </xplan:SO_Gebiet> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_GruenFlaeche gml:id="GML_fa0eea57-ebb1-4d50-b205-95865d6b9284"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940468.040</gml:lowerCorner> + <gml:upperCorner>565042.005 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_1c92b1db-bd5f-478c-a034-3b5e7bf9a81f"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="5">565042.005 5940522.630 564984.128 5940522.630 564984.128 5940468.040 565022.175 5940504.055 565042.005 5940522.630 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:zweckbestimmung> + <xplan:BP_KomplexeZweckbestGruen> + <xplan:allgemein>1000</xplan:allgemein> + </xplan:BP_KomplexeZweckbestGruen> + </xplan:zweckbestimmung> + <xplan:nutzungsform>2000</xplan:nutzungsform> + </xplan:BP_GruenFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_BaugebietsTeilFlaeche gml:id="GML_b5f66983-6732-4cdc-8910-ba4d40a060e8"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565038.252 5940474.619</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_9315e58c-ee79-4e4a-85fa-993709ccfc29"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="12">565029.337 5940457.156 565028.611 5940456.469 565020.516 5940465.024 565016.424 5940469.350 565011.438 5940474.619 564999.828 5940463.629 564988.215 5940452.640 564984.128 5940448.773 564984.128 5940442.486 565034.802 5940442.486 565038.252 5940447.733 565029.337 5940457.156 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:besondereArtDerBaulNutzung>1500</xplan:besondereArtDerBaulNutzung> + </xplan:BP_BaugebietsTeilFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:SO_Strassenverkehr gml:id="GML_06f9b5b2-8051-4f03-9dc3-50ba956a2670"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940448.773</gml:lowerCorner> + <gml:upperCorner>565055.484 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_7f6be5de-9acd-42b6-a664-1e8de042e532"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="13">565048.163 5940509.388 565050.619 5940511.714 565055.484 5940510.564 565045.164 5940522.630 565042.005 5940522.630 565022.175 5940504.055 564984.128 5940468.040 564984.128 5940448.773 564988.215 5940452.640 564999.828 5940463.629 565011.438 5940474.619 565024.500 5940486.984 565048.163 5940509.388 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:nordwinkel uom="grad">0.000000</xplan:nordwinkel> + <xplan:artDerFestlegung> + <xplan:SO_KomplexeZweckbestStrassenverkehr> + <xplan:allgemein>3500</xplan:allgemein> + </xplan:SO_KomplexeZweckbestStrassenverkehr> + </xplan:artDerFestlegung> + <xplan:nutzungsform>2000</xplan:nutzungsform> + <xplan:hatDarstellungMitBesondZweckbest>true</xplan:hatDarstellungMitBesondZweckbest> + </xplan:SO_Strassenverkehr> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_GruenFlaeche gml:id="GML_3b987a05-5df3-42ed-ba22-b1b04bf58bf0"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565045.164 5940463.858</gml:lowerCorner> + <gml:upperCorner>565072.441 5940522.630</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_27b9cf2e-4f08-4db9-9be5-9edd59ad5f0e"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="7">565072.441 5940522.630 565045.164 5940522.630 565055.484 5940510.564 565064.406 5940485.989 565065.689 5940482.457 565072.441 5940463.556 565072.441 5940522.630 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:zweckbestimmung> + <xplan:BP_KomplexeZweckbestGruen> + <xplan:allgemein>1000</xplan:allgemein> + </xplan:BP_KomplexeZweckbestGruen> + </xplan:zweckbestimmung> + <xplan:nutzungsform>1000</xplan:nutzungsform> + </xplan:BP_GruenFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:BP_BaugebietsTeilFlaeche gml:id="GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565034.802 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940463.556</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:ebene>0</xplan:ebene> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_458852b4-0f35-4405-b3be-90bb70688ddd" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_fd59b568-132d-4ff7-9549-d387f8c629d1"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="6">565072.441 5940463.556 565053.250 5940456.591 565038.252 5940447.733 565034.802 5940442.486 565072.441 5940442.486 565072.441 5940463.556 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>true</xplan:flaechenschluss> + <xplan:besondereArtDerBaulNutzung>1700</xplan:besondereArtDerBaulNutzung> + </xplan:BP_BaugebietsTeilFlaeche> + </gml:featureMember> + <gml:featureMember> + <xplan:SO_Gebiet gml:id="GML_c8fa8ddd-d5de-4111-9489-03967eec715e"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>564984.128 5940442.486</gml:lowerCorner> + <gml:upperCorner>565072.441 5940511.714</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:wirdDargestelltDurch xlink:href="#GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3" /> + <xplan:rechtscharakter>1000</xplan:rechtscharakter> + <xplan:position> + <gml:Polygon srsName="EPSG:25832" gml:id="GML_bb3db696-52cd-49d6-96fb-034ab3e910da"> + <gml:exterior> + <gml:LinearRing> + <gml:posList srsDimension="2" count="16">565065.689 5940482.457 565064.406 5940485.989 565055.484 5940510.564 565050.619 5940511.714 565048.163 5940509.388 565024.500 5940486.984 565011.438 5940474.619 564999.828 5940463.629 564988.215 5940452.640 564984.128 5940448.773 564984.128 5940442.486 565034.802 5940442.486 565038.252 5940447.733 565053.250 5940456.591 565072.441 5940463.556 565065.689 5940482.457 </gml:posList> + </gml:LinearRing> + </gml:exterior> + </gml:Polygon> + </xplan:position> + <xplan:flaechenschluss>false</xplan:flaechenschluss> + <xplan:gemeinde> + <xplan:XP_Gemeinde> + <xplan:ags>02000000</xplan:ags> + <xplan:gemeindeName>Freie und Hansestadt Hamburg</xplan:gemeindeName> + </xplan:XP_Gemeinde> + </xplan:gemeinde> + <xplan:gebietsArt>1700</xplan:gebietsArt> + </xplan:SO_Gebiet> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_a81f7f4e-071f-44fd-af3e-826e80b82ee3"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565027.244 5940470.916</gml:lowerCorner> + <gml:upperCorner>565028.244 5940471.916</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>gebietsArt[0]</xplan:art> + <xplan:art>gemeinde[0]/gemeindeName[0]</xplan:art> + <xplan:art>gemeinde[0]/ags[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_c8fa8ddd-d5de-4111-9489-03967eec715e" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_9c0ff9d5-5736-4e21-a30c-ee5c459f7c78"> + <gml:pos>565027.244 5940470.916</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.00</xplan:drehwinkel> + <xplan:skalierung>1</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_458852b4-0f35-4405-b3be-90bb70688ddd"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565063.749 5940451.169</gml:lowerCorner> + <gml:upperCorner>565064.749 5940451.169</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_eb8753e9-db57-4f81-b9dd-37fc38fb4419" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_51c5093a-5964-41f6-8f3a-a07973982464"> + <gml:pos>565063.749 5940451.169</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_a630c212-8ae0-4be6-91c4-b0dc8cba820a"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565010.917 5940455.804</gml:lowerCorner> + <gml:upperCorner>565011.917 5940455.804</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_b5f66983-6732-4cdc-8910-ba4d40a060e8" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_3424ae3a-6635-45ac-9242-3089daeaf9db"> + <gml:pos>565010.917 5940455.804</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> + <gml:featureMember> + <xplan:XP_PPO gml:id="GML_22989f35-59e8-4260-8c60-e706b916a886"> + <gml:boundedBy> + <gml:Envelope srsName="EPSG:25832"> + <gml:lowerCorner>565043.676 5940476.202</gml:lowerCorner> + <gml:upperCorner>565044.676 5940476.202</gml:upperCorner> + </gml:Envelope> + </gml:boundedBy> + <xplan:art>besondereArtDerBaulNutzung[0]</xplan:art> + <xplan:gehoertZuBereich xlink:href="#GML_95a8b21b-8754-4350-9041-213259262fd8" /> + <xplan:dientZurDarstellungVon xlink:href="#GML_51e17233-d921-46cb-83b9-af28451186a1" /> + <xplan:position> + <gml:Point srsName="EPSG:25832" gml:id="GML_27888432-2c29-41c0-b6bc-d857207dced4"> + <gml:pos>565043.676 5940476.202</gml:pos> + </gml:Point> + </xplan:position> + <xplan:drehwinkel uom="grad">0.0</xplan:drehwinkel> + <xplan:skalierung>1.0</xplan:skalierung> + </xplan:XP_PPO> + </gml:featureMember> +</xplan:XPlanAuszug> diff --git a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-validator-api-soapui-project.xml b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-validator-api-soapui-project.xml index a34e17c43a..b1b02b2e27 100644 --- a/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-validator-api-soapui-project.xml +++ b/xplan-tests/xplan-tests-soapui/src/main/resources/xplan-validator-api-soapui-project.xml @@ -21,7 +21,7 @@ <con:description>Set this if Keycloak authentication shall be used locally: jwtUrl=http://localhost:8096/keycloak/realms/xplanbox/protocol/openid-connect/token -jwtClientId=xplan-validator-api</con:description> +jwtClientId=xplanbox-api</con:description> <con:settings/> <con:interface xsi:type="con:RestService" id="85ec4fc3-149e-4a77-a566-194de2899fd3" wadlVersion="http://wadl.dev.java.net/2009/02" name="XPlanValidatorAPI" type="rest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <con:description>XPlanValidator REST API</con:description> @@ -2055,7 +2055,7 @@ assert json.version != null</scriptText> <con:testStep type="restrequest" name="POST BP 5.1 XX validatePlanRequestBodyApplication/ZIPContentTypeText/XMLExpectError400" id="8e15b574-4b91-4e98-8f73-4b7f5098b500"> <con:settings/> <con:config service="XPlanValidatorAPI" resourcePath="/validate" methodName="validate" xsi:type="con:RestRequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <con:restRequest name="POST BP 5.1 XX validatePlanRequestBodyApplication/ZIPContentTypeText/XMLExpectError" id="1e838fd1-d5da-4a94-9638-1e66e478df75" mediaType="text/xml" postQueryString="false"> + <con:restRequest name="POST BP 5.1 XX validatePlanRequestBodyApplication/ZIPContentTypeText/XMLExpectError400" id="1e838fd1-d5da-4a94-9638-1e66e478df75" mediaType="text/xml" postQueryString="false"> <con:settings> <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/></con:setting> </con:settings> @@ -4448,7 +4448,7 @@ assert json.version != null</scriptText> <con:parameters/> </con:config> </con:testStep> - <con:properties></con:properties> + <con:properties/> </con:testCase> <con:testCase id="390b7003-ed8f-4b66-976d-346be67663fb" failOnError="false" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="Validation invalid TestCase" searchProperties="true" timeout="0" wsrmEnabled="false" wsrmVersion="1.0" wsrmAckTo="" amfAuthorisation="false" amfEndpoint="" amfLogin="" amfPassword=""> <con:description>TestCase für die Validierung von geometrisch, semantisch und syntaktisch invaliden Planwerken.</con:description> @@ -4651,7 +4651,7 @@ assert json.version != null</scriptText> <con:parameters/> </con:config> </con:testStep> - <con:properties></con:properties> + <con:properties/> </con:testCase> <con:properties/> </con:testSuite> diff --git a/xplan-validator/xplan-validator-executor/src/main/java/de/latlon/xplanbox/validator/executor/listener/EventValidationProcessListener.java b/xplan-validator/xplan-validator-executor/src/main/java/de/latlon/xplanbox/validator/executor/listener/EventValidationProcessListener.java index 17f583e962..355c0dcba4 100644 --- a/xplan-validator/xplan-validator-executor/src/main/java/de/latlon/xplanbox/validator/executor/listener/EventValidationProcessListener.java +++ b/xplan-validator/xplan-validator-executor/src/main/java/de/latlon/xplanbox/validator/executor/listener/EventValidationProcessListener.java @@ -4,6 +4,8 @@ import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.GE import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.GEOMETRIC_VALIDATION_STARTED; import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.PROFILE_VALIDATION_FINISHED; import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.PROFILE_VALIDATION_STARTED; +import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.REFERENCES_FINISHED; +import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.REFERENCES_STARTED; import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.SEMANTIC_VALIDATION_FINISHED; import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.SEMANTIC_VALIDATION_STARTED; import static de.latlon.core.validator.events.v1.XPlanPublicV1Event.EventType.SYNTACTIC_VALIDATION_FINISHED; @@ -36,6 +38,7 @@ public class EventValidationProcessListener implements ValidationProcessListener public void validationPartStarted(String uuid, ValidationType validationType) { XPlanPublicV1Event.EventType eventType = SYNTACTIC_VALIDATION_STARTED; switch (validationType) { + case REFERENCES -> eventType = REFERENCES_STARTED; case GEOMETRIC -> eventType = GEOMETRIC_VALIDATION_STARTED; case SEMANTIC -> eventType = SEMANTIC_VALIDATION_STARTED; } @@ -47,6 +50,7 @@ public class EventValidationProcessListener implements ValidationProcessListener public void validationPartFinished(String uuid, ValidationType validationType, Boolean isValid) { XPlanPublicV1Event.EventType eventType = SYNTACTIC_VALIDATION_FINISHED; switch (validationType) { + case REFERENCES -> eventType = REFERENCES_FINISHED; case GEOMETRIC -> eventType = GEOMETRIC_VALIDATION_FINISHED; case SEMANTIC -> eventType = SEMANTIC_VALIDATION_FINISHED; } diff --git a/xplan-validator/xplan-validator-executor/src/test/java/de/latlon/xplanbox/validator/executor/PlanValidatorTest.java b/xplan-validator/xplan-validator-executor/src/test/java/de/latlon/xplanbox/validator/executor/PlanValidatorTest.java index e9a1cb3017..941ad4f281 100644 --- a/xplan-validator/xplan-validator-executor/src/test/java/de/latlon/xplanbox/validator/executor/PlanValidatorTest.java +++ b/xplan-validator/xplan-validator-executor/src/test/java/de/latlon/xplanbox/validator/executor/PlanValidatorTest.java @@ -148,6 +148,8 @@ class PlanValidatorTest { uuid); XPlanPublicV1Event expectedSynFinishedEvent = new XPlanPublicV1Event(EventType.SYNTACTIC_VALIDATION_FINISHED, uuid, true); + XPlanPublicV1Event expectedRefStartedEvent = new XPlanPublicV1Event(EventType.REFERENCES_STARTED, uuid); + XPlanPublicV1Event expectedRefFinishedEvent = new XPlanPublicV1Event(EventType.REFERENCES_FINISHED, uuid, true); XPlanPublicV1Event expectedSemStartedEvent = new XPlanPublicV1Event(EventType.SEMANTIC_VALIDATION_STARTED, uuid); XPlanPublicV1Event expectedSemFinishedEvent = new XPlanPublicV1Event(EventType.SEMANTIC_VALIDATION_FINISHED, @@ -157,14 +159,14 @@ class PlanValidatorTest { XPlanPublicV1Event expectedGeomFinishedEvent = new XPlanPublicV1Event(EventType.GEOMETRIC_VALIDATION_FINISHED, uuid, false); XPlanPublicV1Event expectedFinishedEvent = new XPlanPublicV1Event(EventType.VALIDATION_FINISHED, uuid, false); - verify(eventSender, times(8)).sendPublicEvent(publicEventCaptor.capture(), stringCaptor.capture()); + verify(eventSender, times(10)).sendPublicEvent(publicEventCaptor.capture(), stringCaptor.capture()); assertThat(publicEventCaptor.getAllValues()).containsExactly(expectedStartEvent, expectedSynStartedEvent, - expectedSynFinishedEvent, expectedGeomStartedEvent, expectedGeomFinishedEvent, expectedSemStartedEvent, - expectedSemFinishedEvent, expectedFinishedEvent); + expectedSynFinishedEvent, expectedRefStartedEvent, expectedRefFinishedEvent, expectedGeomStartedEvent, + expectedGeomFinishedEvent, expectedSemStartedEvent, expectedSemFinishedEvent, expectedFinishedEvent); assertThat(stringCaptor.getAllValues()).containsExactly("validation", "validation.syntaktisch", - "validation.syntaktisch", "validation.geometrisch", "validation.geometrisch", "validation.semantisch", - "validation.semantisch", "validation"); + "validation.syntaktisch", "validation.referenzen", "validation.referenzen", "validation.geometrisch", + "validation.geometrisch", "validation.semantisch", "validation.semantisch", "validation"); } @Test diff --git a/xplan-webservices/xplan-webservices-services/xplan-services-wms/src/main/java/de/latlon/xplan/wms/GetAttachmentHandler.java b/xplan-webservices/xplan-webservices-services/xplan-services-wms/src/main/java/de/latlon/xplan/wms/GetAttachmentHandler.java index 7efa8ad0dd..c171240f0b 100644 --- a/xplan-webservices/xplan-webservices-services/xplan-services-wms/src/main/java/de/latlon/xplan/wms/GetAttachmentHandler.java +++ b/xplan-webservices/xplan-webservices-services/xplan-services-wms/src/main/java/de/latlon/xplan/wms/GetAttachmentHandler.java @@ -20,8 +20,6 @@ */ package de.latlon.xplan.wms; -import static org.apache.commons.io.IOUtils.closeQuietly; - import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -34,7 +32,6 @@ import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - import org.deegree.commons.config.DeegreeWorkspace; import org.deegree.db.ConnectionProvider; import org.deegree.db.ConnectionProviderProvider; @@ -48,8 +45,10 @@ import org.slf4j.LoggerFactory; * * @author <a href="mailto:ionita@lat-lon.de">Andrei Ionita</a> * @version 1.0, Date: 2010-02-01 + * @deprecated GetAttachmentHandler is deprecated and will be removed in a future version * */ +@Deprecated public class GetAttachmentHandler extends HttpServlet { private static final long serialVersionUID = -3208934442687262173L; diff --git a/xplan-webservices/xplan-webservices-workspaces/src/main/workspace/styles/xplansyn/default/so/so_gebiet.xml b/xplan-webservices/xplan-webservices-workspaces/src/main/workspace/styles/xplansyn/default/so/so_gebiet.xml index 86f877a48d..568a6baf9d 100644 --- a/xplan-webservices/xplan-webservices-workspaces/src/main/workspace/styles/xplansyn/default/so/so_gebiet.xml +++ b/xplan-webservices/xplan-webservices-workspaces/src/main/workspace/styles/xplansyn/default/so/so_gebiet.xml @@ -73,6 +73,10 @@ <ogc:PropertyName>xplan:gebietsArt</ogc:PropertyName> <ogc:Literal>2200</ogc:Literal> </ogc:PropertyIsEqualTo> + <ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!"> + <ogc:PropertyName>xplan:gebietsArt</ogc:PropertyName> + <ogc:Literal>1700*</ogc:Literal> + </ogc:PropertyIsLike> </ogc:Or> </ogc:And> </ogc:Filter> -- GitLab