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

Feat(bpdm-system-test): golden record tester module WIP

feat(bpdm-system-test): golden record tester module

feat(bpdm-system-test): updated docker file.

feat(bpdm-system-test): golden record tester module.
  • Loading branch information
nicoprow authored and SujitMBRDI committed Nov 7, 2024
1 parent 5da5d96 commit 785694f
Show file tree
Hide file tree
Showing 13 changed files with 919 additions and 0 deletions.
112 changes: 112 additions & 0 deletions bpdm-system-tester/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<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>
<!-- Name jar without version to make it easier to reference it during CICD -->
<finalName>bpdm-system-tester</finalName>
<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() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************
* 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.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl
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 PoolClientConfigurationProperties(
override val baseUrl: String = "http://localhost:8080",
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}.pool"
}

override fun getId() = PREFIX
}

@Configuration
class PoolClientConfiguration{

@Bean
fun poolClient(webClientProvider: BpdmWebClientProvider, properties: PoolClientConfigurationProperties): PoolApiClient{
return PoolClientImpl { webClientProvider.builder(properties).build() }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*******************************************************************************
* 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.gate.api.client.GateClient
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.pool.api.model.IdentifierBusinessPartnerType
import org.eclipse.tractusx.bpdm.pool.api.model.IdentifierTypeDto
import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest
import org.eclipse.tractusx.bpdm.test.system.utils.GateInputFactory
import org.eclipse.tractusx.bpdm.test.system.utils.GateOutputFactory
import org.eclipse.tractusx.bpdm.test.system.utils.StepUtils
import org.eclipse.tractusx.bpdm.test.system.utils.TestMetadata
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.time.Instant

@Configuration
class TestDataConfiguration {

@Bean
fun testMetadata(poolClient: PoolApiClient): TestMetadata {
val testMetadata = TestMetadata(
identifierTypes = listOf("id1", "id2"),
legalForms = listOf("legalform1", "legalform2"),
adminAreas = listOf("DE-BW", "DE-BY")
)

testMetadata.identifierTypes.forEach { technicalKey ->
createIdentifierType(poolClient, technicalKey, IdentifierBusinessPartnerType.LEGAL_ENTITY)
createIdentifierType(poolClient, technicalKey, IdentifierBusinessPartnerType.ADDRESS)
}

testMetadata.legalForms.forEach { technicalKey ->
createLegalForm(poolClient, technicalKey)
}

return testMetadata
}

private fun createIdentifierType(
poolClient: PoolApiClient,
technicalKey: String,
partnerType: IdentifierBusinessPartnerType
) {
runCatching {
poolClient.metadata.createIdentifierType(
IdentifierTypeDto(
technicalKey,
partnerType,
technicalKey,
null, null, null
)
)
}.onFailure {
// Log or handle failure if needed
}
}

private fun createLegalForm(poolClient: PoolApiClient, technicalKey: String) {
runCatching {
poolClient.metadata.createLegalForm(LegalFormRequest(technicalKey, technicalKey, null, null, null, null, null, null, true))
}.onFailure {
// Log or handle failure if needed
}
}

@Bean
fun gateTestDataFactory(testMetadata: TestMetadata, testRunData: TestRunData): GateInputFactory {
return GateInputFactory(testMetadata, testRunData)
}

@Bean
fun gateOutputFactory(gateInputDataFactory: GateInputFactory): GateOutputFactory {
return GateOutputFactory(gateInputDataFactory)
}

@Bean
fun testRunData(): TestRunData {
return TestRunData(Instant.now())
}

@Bean
fun stepUtils(testRunData: TestRunData, gateClient: GateClient): StepUtils{
return StepUtils(gateClient)
}
}
Loading

0 comments on commit 785694f

Please sign in to comment.