Skip to content

Commit

Permalink
chore: TRACEFOSS-617 adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener committed Apr 21, 2023
1 parent 64b399f commit cff1552
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 42 deletions.
80 changes: 40 additions & 40 deletions tx-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

<dependencies>
<!-- tx-application modules -->
<!-- <dependency>
<groupId>org.eclipse.tractusx.traceability</groupId>
<artifactId>tx-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>-->
<!-- <dependency>
<groupId>org.eclipse.tractusx.traceability</groupId>
<artifactId>tx-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>-->

<!-- managed by spring boot -->
<dependency>
Expand Down Expand Up @@ -221,6 +221,12 @@
<version>${commons-io.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>

<dependency> <!-- use a specific Groovy version rather than the one specified by spock-core -->
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
Expand Down Expand Up @@ -344,12 +350,6 @@
<build>
<finalName>traceability-app-${project.version}</finalName>
<plugins>
<!-- <plugin>
<groupId>org.eclipse.dash</groupId>
<artifactId>license-tool-plugin</artifactId>
<version>${eclipse-license-tool.version}</version>
</plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down Expand Up @@ -587,35 +587,35 @@
<profile>
<id>spotbugs-check</id>
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-plugin.version}</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<failThreshold>High</failThreshold>
<excludeFilterFile>ci/spotbugs-excludes.xml</excludeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>${findsecbugs-plugin.version}</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-plugin.version}</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<failThreshold>High</failThreshold>
<excludeFilterFile>ci/spotbugs-excludes.xml</excludeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>${findsecbugs-plugin.version}</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.commons.collections4.CollectionUtils.emptyIfNull;

@Component
public class AssetService {
Expand Down Expand Up @@ -75,11 +80,21 @@ public void synchronizeAssets(String globalAssetId) {
}
}

/**
* Combines the list of downward assets with the list of upward assets by merging the parent descriptions of
* matching child assets into the corresponding downward assets. If an upward asset has no matching downward asset,
* it is added to the result list as is.
*
* @param downwardAssets the list of downward assets to be combined with the upward assets
* @param upwardAssets the list of upward assets to be combined with the downward assets
* @return a new list of {@link Asset} objects that contains the combined assets with merged parent descriptions
*/
public List<Asset> combineAssetsAndMergeParentDescriptionIntoDownwardAssets(List<Asset> downwardAssets, List<Asset> upwardAssets) {
Map<String, Asset> downwardAssetsMap = downwardAssets.stream()

Map<String, Asset> downwardAssetsMap = emptyIfNull(downwardAssets).stream()
.collect(Collectors.toMap(Asset::getId, Function.identity()));

return upwardAssets.stream()
return emptyIfNull(upwardAssets).stream()
.map(parentAsset -> {
Asset matchingChildAsset = downwardAssetsMap.get(parentAsset.getId());
if (matchingChildAsset == null) {
Expand Down

0 comments on commit cff1552

Please sign in to comment.