Skip to content

Commit

Permalink
Merge pull request #65 from catenax-ng/main
Browse files Browse the repository at this point in the history
Build & Test & Notification Flow Improvements
  • Loading branch information
mkanal authored Apr 4, 2023
2 parents bafc792 + 35d2c6b commit d816c90
Show file tree
Hide file tree
Showing 25 changed files with 1,343 additions and 338 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/docker-image-branch_frontend.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Frontend Build&Push Docker image for branch
on:
pull_request:
paths:
- 'frontend/**'
- '.github/workflows/**'

env:
REGISTRY: ghcr.io
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-main_frontend.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend Build&Push Docker image on main
name: Frontend Build&Push Docker image on main

on:
push:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed

## [3.1.1] - 2023-04-04

### Added
- Some unit tests for better code quality

### Changed
- Fixed edc notification flow bug
- Updated org.springframework/spring-expression from 6.0.6 to 6.0.7
- Updated net.minidev/json-smart from 2.4.8 to 2.4.10
- Updated documentation of application

## [3.1.0] - 2023-04-03

### Added
Expand Down
22 changes: 22 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Update snakeyaml manually to avoid vulnerability CVE-2020-13936; can be removed after Spring updates their dependency -->
Expand All @@ -174,6 +178,12 @@
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>
<!-- Update spring-expression manually to avoid vulnerability CVE-2023-20861; can be removed after Spring updates their dependency -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>6.0.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
Expand Down Expand Up @@ -346,6 +356,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Update json-smart manually to avoid vulnerability CVE-2023-1370; can be removed after Spring updates their dependency -->
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.10</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package org.eclipse.tractusx.traceability.common.support


import org.eclipse.tractusx.traceability.infrastructure.jpa.investigation.InvestigationEntity
import org.eclipse.tractusx.traceability.investigations.domain.model.InvestigationSide
import org.eclipse.tractusx.traceability.investigations.domain.model.InvestigationStatus
Expand All @@ -30,41 +29,41 @@ import java.time.Instant

trait InvestigationsSupport implements InvestigationsRepositoryProvider {

Long defaultReceivedInvestigationStored() {
InvestigationEntity entity = new InvestigationEntity([], "BPNL00000003AXS3", InvestigationStatus.RECEIVED, InvestigationSide.RECEIVER, "", "some-description", Instant.now())
Long defaultReceivedInvestigationStored() {
InvestigationEntity entity = new InvestigationEntity([], "BPNL00000003AXS3", InvestigationStatus.RECEIVED, InvestigationSide.RECEIVER, "", "some-description", Instant.now())

return storedInvestigation(entity)
}
return storedInvestigation(entity)
}

Long defaultAcknowledgedInvestigationStored() {
InvestigationEntity entity = new InvestigationEntity([], "BPNL00000003AXS3", InvestigationStatus.ACKNOWLEDGED, InvestigationSide.RECEIVER, "", "", Instant.now())
Long defaultAcknowledgedInvestigationStored() {
InvestigationEntity entity = new InvestigationEntity([], "BPNL00000003AXS3", InvestigationStatus.ACKNOWLEDGED, InvestigationSide.RECEIVER, "", "", Instant.now())

return storedInvestigation(entity)
}
return storedInvestigation(entity)
}

void assertInvestigationsSize(int size) {
List<InvestigationEntity> investigations = jpaInvestigationRepository().findAll()
void assertInvestigationsSize(int size) {
List<InvestigationEntity> investigations = jpaInvestigationRepository().findAll()

assert investigations.size() == size
}
assert investigations.size() == size
}

void assertInvestigationStatus(InvestigationStatus investigationStatus) {
jpaInvestigationRepository().findAll().each {
assert it.status == investigationStatus
}
}
void assertInvestigationStatus(InvestigationStatus investigationStatus) {
jpaInvestigationRepository().findAll().each {
assert it.status == investigationStatus
}
}

void storedInvestigations(InvestigationEntity... investigations) {
investigations.each {
jpaInvestigationRepository().save(it)
}
}
void storedInvestigations(InvestigationEntity... investigations) {
investigations.each {
jpaInvestigationRepository().save(it)
}
}

Long storedInvestigation(InvestigationEntity investigation) {
return jpaInvestigationRepository().save(investigation).id
}
Long storedInvestigation(InvestigationEntity investigation) {
return jpaInvestigationRepository().save(investigation).id
}

InvestigationEntity storedInvestigationFullObject(InvestigationEntity investigation) {
return jpaInvestigationRepository().save(investigation);
}
InvestigationEntity storedInvestigationFullObject(InvestigationEntity investigation) {
return jpaInvestigationRepository().save(investigation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.eclipse.tractusx.traceability.investigations.domain.model.Investigati
import org.eclipse.tractusx.traceability.investigations.domain.model.InvestigationStatus
import org.eclipse.tractusx.traceability.investigations.domain.model.Severity
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Ignore

import java.time.Instant

Expand Down Expand Up @@ -70,6 +69,7 @@ class EdcControllerIT extends IntegrationSpecification implements TestDataSuppor
given:
defaultAssetsStored()
NotificationEntity notification = new NotificationEntity(
"1",
null,
"senderBpnNumber",
"senderManufacturerName",
Expand All @@ -85,22 +85,21 @@ class EdcControllerIT extends IntegrationSpecification implements TestDataSuppor

InvestigationEntity investigation = new InvestigationEntity(
[], "BPNL00000003AXS3", InvestigationStatus.SENT, InvestigationSide.SENDER, "", "some-description", Instant.now())
List<NotificationEntity> notificationEntities = new ArrayList<>()
InvestigationEntity persistedInvestigation = storedInvestigationFullObject(investigation)

InvestigationEntity persistedInvestigation = storedInvestigationFullObject(investigation)

NotificationEntity notificationEntity = storedNotification(notification)
notification.setInvestigation(persistedInvestigation);
storedNotification(notificationEntity)
String notificationId = notificationEntity.getId()
notificationEntity.setInvestigation(persistedInvestigation);
NotificationEntity persistedNotification = storedNotification(notificationEntity)

investigation.setNotifications(List.of(persistedNotification))

storedInvestigationFullObject(investigation)


String notificationJson = readFile("edc_notification_okay_update.json").replaceAll("REPLACE_ME", notificationEntity.getEdcNotificationId())
EDCNotification edcNotification = objectMapper.readValue(notificationJson, EDCNotification.class);

notificationEntities.add(notificationEntity)
investigation.setNotifications(notificationEntities)

storedInvestigationFullObject(investigation)

when:
given()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class PublisherInvestigationsControllerIT extends IntegrationSpecification imple
[
partIds : partIds,
description: description,
severity: "MINOR"
severity : "MINOR"
]
)
)
Expand Down Expand Up @@ -167,7 +167,7 @@ class PublisherInvestigationsControllerIT extends IntegrationSpecification imple
.body(
asJson(
[
status : "ACCEPTED",
status: "ACCEPTED",
reason: description
]
)
Expand All @@ -180,8 +180,6 @@ class PublisherInvestigationsControllerIT extends IntegrationSpecification imple
.body(Matchers.containsString("Reason should have at least 15 characters and at most 1000 characters"))
}

// will be fixed in: https://jira.catena-x.net/browse/TRACEFOSS-1063
@Ignore
def "should cancel investigation"() {
given:
defaultAssetsStored()
Expand All @@ -193,7 +191,8 @@ class PublisherInvestigationsControllerIT extends IntegrationSpecification imple
asJson(
[
partIds : ["urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca978"],
description: "at least 15 characters long investigation description"
description: "at least 15 characters long investigation description",
severity : "MAJOR"
]
)
)
Expand Down
Loading

0 comments on commit d816c90

Please sign in to comment.