*.log
*.war
.vscode
+sdc-workflow-designer-be/src/test/resources/db/*.cql
<junitJupiter.version>5.9.1</junitJupiter.version>
<junit.platform.version>1.9.0</junit.platform.version>
<janino.version>3.1.10</janino.version>
+ <testcontainers.version>1.19.1</testcontainers.version>
</properties>
<dependencyManagement>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <artifactId>asm</artifactId>
- <groupId>org.ow2.asm</groupId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <!-- <exclusion>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </exclusion> -->
- <exclusion>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>zusammen-commons-configuration</artifactId>
<version>${zusammen.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>${testcontainers.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>cassandra</artifactId>
+ <version>${testcontainers.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${testcontainers.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <phase>
+ generate-sources
+ </phase>
+ <!-- This copies and merges all cql files from the designer-init module
+ into a 'init.cql' file the resources folder in the tests.
+ This is used by the WorkflowControllerIntegrationTest to initialize the
+ cassandra container that is used for the test. -->
+ <configuration>
+ <target>
+ <concat destfile="${basedir}/src/test/resources/db/init.cql"
+ force="yes">
+ <fileset dir="../sdc-workflow-designer-init/src/main/docker">
+ <include name="*.cql"></include>
+ </fileset>
+ </concat>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
/*
* Copyright © 2018 European Support Limited
+ * Modifications Copyright © 2025 Deutsche Telekom
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
import org.onap.sdc.workflow.api.types.dto.ArtifactDeliveriesRequestDto;
import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.web.client.RestTemplate;
-
-@SpringJUnitConfig(
- classes = {ArtifactAssociationHandlerTest.RestBuilderMockProvider.class, ArtifactAssociationService.class})
+@DirtiesContext
+@SpringBootTest(classes = {ArtifactAssociationService.class})
@TestPropertySource(locations = "classpath:application-test.properties")
-@Component("ArtifactAssociationHandlerTest")
public class ArtifactAssociationHandlerTest {
- @Configuration
- static class RestBuilderMockProvider {
-
- @Bean
- public RestTemplateBuilder templateBuilder() {
- return Mockito.mock(RestTemplateBuilder.class);
- }
-
- @Bean
- public RestTemplate restTemplate() {
- return Mockito.mock(RestTemplate.class);
- }
- }
-
private static final String FILE_NAME = "fileName.txt";
private static final String USER_ID = "cs0008";
private static final String END_POINT =
@Value("${sdc.be.external.password}")
private String sdcPassword;
- @Autowired
+ @MockBean
+ private RestTemplateBuilder restTemplateBuilder;
+ @MockBean
private RestTemplate restClientMock;
--- /dev/null
+/*
+ * Copyright © 2025 Deutsche Telekom
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.sdc.workflow.api;
+
+import org.junit.jupiter.api.BeforeEach;
+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.SpringBootTest.WebEnvironment;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+import org.testcontainers.containers.CassandraContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import lombok.SneakyThrows;
+
+@Testcontainers
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
+ properties = {
+ "spring.data.cassandra.contact-points=localhost",
+ "spring.data.cassandra.schema-action=CREATE_IF_NOT_EXISTS"
+})
+public class WorkflowControllerIntegrationTest {
+
+ @LocalServerPort
+ int port;
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ RestTemplateBuilder builder;
+ RestTemplate restTemplate;
+
+ @BeforeEach
+ void setup() {
+ this.restTemplate = builder
+ .rootUri("http://localhost:" + port)
+ .defaultHeader(HttpHeaders.ACCEPT, "application/json")
+ .build();
+ }
+
+
+
+ @Container
+ private static CassandraContainer<?> cassandraContainer
+ = new CassandraContainer<>("cassandra:3.11.2")
+ .withInitScript("db/init.cql")
+ .withExposedPorts(9042);
+
+ @DynamicPropertySource
+ static void configureProperties(DynamicPropertyRegistry registry) {
+ registry.add("spring.data.cassandra.port", () -> cassandraContainer.getFirstMappedPort());
+ }
+
+ @Test
+ @SneakyThrows
+ public void someTest() {
+ String baseUrl = "/wf/workflows";
+ String queryParams = UriComponentsBuilder
+ .fromUriString(baseUrl)
+ .queryParam("sort", "name:asc")
+ .queryParam("limit", 31)
+ .queryParam("offset", 0)
+ .queryParam("archiving", "ACTIVE")
+ .toUriString();
+
+ ResponseEntity<String> response = restTemplate.getForEntity(queryParams, String.class);
+ assert(response.getStatusCode().is2xxSuccessful());
+
+ }
+
+}