Skip to content

Commit

Permalink
feat(bpdm-system-test): golden record tester module.
Browse files Browse the repository at this point in the history
feat(bpdm-system-test): golden record tester module
  • Loading branch information
nicoprow authored and SujitMBRDI committed Oct 18, 2024
1 parent f5b6122 commit 2a5db4b
Show file tree
Hide file tree
Showing 17 changed files with 907 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class CleaningServiceDummy(

val cleanedBusinessPartner = BusinessPartner(
nameParts = businessPartner.nameParts,
uncategorized = businessPartner.uncategorized,
// ToDo: Identifiers are taken as legal identifiers and should be removed from uncategorized collection
uncategorized = businessPartner.uncategorized.copy(identifiers = emptyList()),
owningCompany = businessPartner.owningCompany,
legalEntity = cleanLegalEntity(businessPartner, sharedByOwner),
site = cleanSite(businessPartner, sharedByOwner),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
.copyWithBpnReferences(BpnReference.empty)
.copyWithLegalAddress(PostalAddress.empty)
.copyWithSiteMainAddress(PostalAddress.empty)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -128,6 +133,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
val mockedBusinessPartner = businessPartnerFactory.createFullBusinessPartner("test")
.copyWithLegalAddress(PostalAddress.empty)
.copyWithSiteMainAddress(PostalAddress.empty)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -156,6 +166,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
.copyWithBpnReferences(BpnReference.empty)
.copyWithLegalAddress(PostalAddress.empty)
.copy(site = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -183,6 +198,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
val mockedBusinessPartner = businessPartnerFactory.createFullBusinessPartner("test")
.copyWithLegalAddress(PostalAddress.empty)
.copy(site = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -210,6 +230,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
.copyWithBpnReferences(BpnReference.empty)
.copyWithLegalAddress(PostalAddress.empty)
.copy(additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -237,6 +262,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
val mockedBusinessPartner = businessPartnerFactory.createFullBusinessPartner("test")
.copyWithLegalAddress(PostalAddress.empty)
.copy(additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -264,6 +294,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
.copyWithBpnReferences(BpnReference.empty)
.copyWithSiteMainAddress(null)
.copy(additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand All @@ -290,6 +325,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
val mockedBusinessPartner = businessPartnerFactory.createFullBusinessPartner("test")
.copyWithSiteMainAddress(null)
.copy(additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand All @@ -316,6 +356,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
.copyWithBpnReferences(BpnReference.empty)
.copyWithLegalAddress(PostalAddress.empty)
.copy(site = null, additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down Expand Up @@ -343,6 +388,11 @@ class CleaningServiceApiCallsTest @Autowired constructor(
val mockedBusinessPartner = businessPartnerFactory.createFullBusinessPartner("test")
.copyWithLegalAddress(PostalAddress.empty)
.copy(site = null, additionalAddress = null)
.copy(
uncategorized = businessPartnerFactory.createFullBusinessPartner("test").uncategorized.copy(
identifiers = emptyList() // Assign empty list to uncategorized identifiers
)
)

val resolveMapping = mockOrchestratorResolveApi()
mockOrchestratorReserveApi(mockedBusinessPartner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class LandingPageConfig(
val swaggerProperties: SwaggerUiConfigProperties
val swaggerProperties: SwaggerUiConfigProperties?
) : WebMvcConfigurer{

private val logger = KotlinLogging.logger { }

override fun addViewControllers(registry: ViewControllerRegistry) {
val redirectUri = swaggerProperties.path
if(swaggerProperties == null) return
val redirectUri = swaggerProperties!!.path
logger.info { "Set landing page to path '$redirectUri'" }
registry.addRedirectViewController("/", redirectUri)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BusinessPartnerMappings {
} }
.map(::toIdentifierDto)
}?: emptyList(),
states = entity.states.map(::toStateDto),
states = toStateDtos(entity.states, BusinessPartnerType.GENERIC),
roles = entity.roles,
isOwnCompanyData = entity.isOwnCompanyData,
legalEntity = toLegalEntityComponentOutputDto(entity),
Expand Down
110 changes: 110 additions & 0 deletions bpdm-system-tester/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>bpdm-parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>bpdm-system-tester</artifactId>
<name>Business Partner Data Management System Tester</name>
<description>Application to perform system tests for the BPDM system and golden record process</description>
<packaging>jar</packaging>

<properties>
<java.version>21</java.version>
<kotlin.version>2.0.10</kotlin.version>
<kotlinlogging.version>3.0.5</kotlinlogging.version>
<cucumber.version>7.18.1</cucumber.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-pool-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-gate-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-common-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<!-- in kotlin, use mockk instead of mockito -->
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.14.0</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system

import io.cucumber.junit.Cucumber
import io.cucumber.junit.CucumberOptions
import io.cucumber.spring.CucumberContextConfiguration
import org.junit.runner.RunWith
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.boot.test.context.SpringBootTest

@RunWith(Cucumber::class)
@CucumberOptions(features = ["bpdm-system-tester/src/main/resources"], glue = ["org.eclipse.tractusx.bpdm.test.system.stepdefinations"])
class CucumberTestRunConfiguration

@CucumberContextConfiguration
@SpringBootTest
class SpringTestRunConfiguration

@SpringBootApplication(exclude=[DataSourceAutoConfiguration::class])
@ConfigurationPropertiesScan
class SpringApplicationConfiguration

fun main(args: Array<String>) {
io.cucumber.core.cli.Main.main(*args)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system.config

import org.eclipse.tractusx.bpdm.common.util.BpdmClientProperties
import org.eclipse.tractusx.bpdm.common.util.BpdmWebClientProvider
import org.eclipse.tractusx.bpdm.common.util.ClientConfigurationProperties
import org.eclipse.tractusx.bpdm.gate.api.client.GateClient
import org.eclipse.tractusx.bpdm.gate.api.client.GateClientImpl
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@ConfigurationProperties(prefix = PoolClientConfigurationProperties.PREFIX)
data class GateClientConfigProperties(
override val baseUrl: String = "http://localhost:8081",
val searchChangelogPageSize: Int = 100,
override val securityEnabled: Boolean = false,
override val registration: OAuth2ClientProperties.Registration,
override val provider: OAuth2ClientProperties.Provider
) : BpdmClientProperties {
companion object {
const val PREFIX = "${ClientConfigurationProperties.PREFIX}.gate"
}

override fun getId() = PREFIX
}

@Configuration
class GateClientConfig{

@Bean
fun gateClient(webClientProvider: BpdmWebClientProvider, properties: GateClientConfigProperties): GateClient {
return GateClientImpl { webClientProvider.builder(properties).build() }
}
}
Loading

0 comments on commit 2a5db4b

Please sign in to comment.