Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#226 from FraunhoferISST/chore/upd…
Browse files Browse the repository at this point in the history
…ate_springboot_322

Chore/update springboot 322
  • Loading branch information
tom-rm-meyer-ISST authored Jan 31, 2024
2 parents 709e4a4 + c149c36 commit a02322a
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 224 deletions.
181 changes: 94 additions & 87 deletions DEPENDENCIES_BACKEND

Large diffs are not rendered by default.

181 changes: 94 additions & 87 deletions backend/DEPENDENCIES

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<version>3.2.2</version>
<relativePath/>
</parent>
<groupId>org.eclipse.tractusx.puris</groupId>
Expand All @@ -38,9 +38,8 @@
<description>PURIS Backend</description>
<properties>
<java.version>17</java.version>
<springdoc.version>2.2.0</springdoc.version>
<okhttp3.version>2.7.5</okhttp3.version>
<hibernate-validator.version>8.0.0.Final</hibernate-validator.version>
<springdoc.version>2.3.0</springdoc.version>
<hibernate-validator.version>8.0.1.Final</hibernate-validator.version>
<snakeyaml.version>2.2</snakeyaml.version>
</properties>
<dependencies>
Expand Down Expand Up @@ -98,9 +97,9 @@
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp3.version}</version>
<version>4.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
Expand All @@ -112,7 +111,7 @@
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.squareup.okhttp.*;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.util.VariablesService;
import okhttp3.*;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.EDR_Dto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.datatype.DT_ApiMethodEnum;
import org.eclipse.tractusx.puris.backend.common.edc.logic.util.EdcRequestBodyBuilder;
import org.eclipse.tractusx.puris.backend.common.util.VariablesService;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Pattern;
import lombok.*;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
* <p>This class represents materials and products that are to be traded between
Expand Down Expand Up @@ -109,9 +106,6 @@ public class Material {
@Pattern(regexp = PatternStore.NON_EMPTY_NON_VERTICAL_WHITESPACE_STRING)
private String name;

@OneToMany(mappedBy = "material")
Set<MaterialPartnerRelation> materialPartnerRelations = new HashSet<>();

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ public class MaterialPartnerRelation {
private boolean partnerBuysMaterial;

@ManyToOne
@MapsId("ownMaterialNumber")
@JoinColumn(name = "material_ownMaterialNumber")
private Material material;

@ManyToOne
@MapsId("uuid")
@JoinColumn(name = "partner_uuid")
private Partner partner;

public MaterialPartnerRelation() {
Expand Down Expand Up @@ -95,11 +91,11 @@ public String toString() {
@ToString
public static class Key implements Serializable {

@Column(name = "material_ownMaterialNumber")
@Column(name = "key_ownMaterialNumber")
@Pattern(regexp = PatternStore.NON_EMPTY_NON_VERTICAL_WHITESPACE_STRING)
private String ownMaterialNumber;

@Column(name = "partner_uuid")
@Column(name = "key_uuid")
private UUID partnerUuid;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ public class Partner {
*/
private SortedSet<Site> sites = new TreeSet<>();

@OneToMany(mappedBy = "partner")
/**
* Contains all MaterialPartnerRelations that this Partner is involved in.
*/
private Set<MaterialPartnerRelation> materialPartnerRelations = new HashSet<>();

/**
* Use this constructor to generate a new Partner with a BPNS and a BPNA attached.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.HashSet;

import java.util.UUID;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -84,11 +85,8 @@ public void createMaterialPartnerRelationTest() throws Exception {
String partnerMaterialNumber = "MNR-8101-ID146955.001";
MaterialPartnerRelation newMpr = new MaterialPartnerRelation(material, partner, partnerMaterialNumber,
true, true);
HashSet<MaterialPartnerRelation> set = new HashSet<>();
set.add(newMpr);

material.setMaterialPartnerRelations(set);
partner.setMaterialPartnerRelations(set);


// when
when(materialService.findByOwnMaterialNumber(materialNumber)).thenReturn(material);
Expand Down Expand Up @@ -148,10 +146,7 @@ public void updateMaterialPartnerRelationTest() throws Exception {
String partnerMaterialNumber = "MNR-8101-ID146955.001";
MaterialPartnerRelation newMpr = new MaterialPartnerRelation(material, partner, partnerMaterialNumber,
true, true);
HashSet<MaterialPartnerRelation> set = new HashSet<>();
set.add(newMpr);
material.setMaterialPartnerRelations(set);
partner.setMaterialPartnerRelations(set);


String partnerMaterialNumber2 = "MNR-8101-ID146955.002";
MaterialPartnerRelation newMpr2 = new MaterialPartnerRelation(material, partner, partnerMaterialNumber2,
Expand Down Expand Up @@ -190,18 +185,12 @@ public void updateMaterialPartnerRelationTestWrongPatternShouldFail() throws Exc
String partnerMaterialNumber = "MNR-8101-ID146955.001";
MaterialPartnerRelation newMpr = new MaterialPartnerRelation(material, partner, partnerMaterialNumber,
true, true);
HashSet<MaterialPartnerRelation> set = new HashSet<>();
set.add(newMpr);
material.setMaterialPartnerRelations(set);
partner.setMaterialPartnerRelations(set);


String partnerMaterialNumber2 = "MNR-8101-ID146955.002";
MaterialPartnerRelation newMpr2 = new MaterialPartnerRelation(material, partner, partnerMaterialNumber2,
true, true);
HashSet<MaterialPartnerRelation> set2 = new HashSet<>();
set.add(newMpr2);
material.setMaterialPartnerRelations(set2);
partner.setMaterialPartnerRelations(set2);


// when
when(partnerService.findByBpnl(anyString())).thenReturn(partner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

import java.util.HashSet;
import java.util.List;
import java.util.UUID;

Expand All @@ -39,12 +38,12 @@ public class MaterialRepositoryTest {
@Test
void findAllByMaterialFlagTrue_ReturnsListOfMaterials() {
// Given
Material material1 = new Material(true, false, "MNR-123", UUID.randomUUID().toString(), "Test Material 1", new HashSet<>());
Material material1 = new Material(true, false, "MNR-123", UUID.randomUUID().toString(), "Test Material 1");

Material material2 = new Material(true, false, "MNR-234", UUID.randomUUID().toString(), "Test Material 2", new HashSet<>());
Material material2 = new Material(true, false, "MNR-234", UUID.randomUUID().toString(), "Test Material 2");

// would be more realistic with relationship, but didn't add it here as we just want to test the MaterialRepo
Material product = new Material(false, true, "MNR-456", UUID.randomUUID().toString(), "Test Product 1", new HashSet<>());
Material product = new Material(false, true, "MNR-456", UUID.randomUUID().toString(), "Test Product 1");

materialRepository.save(material1);
materialRepository.save(material2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -64,7 +63,7 @@ void setUp() {
@Test
void create_WhenMaterialDoesNotExist_ReturnsCreatedMaterial() {
// Given
Material material = new Material(true, false, "MNR-123", "uuid-value", "Test Material", new HashSet<>());
Material material = new Material(true, false, "MNR-123", "uuid-value", "Test Material");

// When
when(materialRepository.findById(material.getOwnMaterialNumber())).thenReturn(Optional.empty());
Expand All @@ -82,7 +81,7 @@ void create_WhenMaterialDoesNotExist_ReturnsCreatedMaterial() {
@Test
void create_WhenMaterialExists_ReturnsNull() {
// Given
Material material = new Material(true, false, "MNR-123", "uuid-value", "Test Material", new HashSet<>());
Material material = new Material(true, false, "MNR-123", "uuid-value", "Test Material");

// When
when(materialRepository.findById(material.getOwnMaterialNumber())).thenReturn(Optional.of(material));
Expand Down

0 comments on commit a02322a

Please sign in to comment.