Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added postman collection for integration test #160

Merged
merged 14 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.MaterialPartnerRelation;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
Expand Down Expand Up @@ -97,6 +98,12 @@ public class DataInjectionCommandLineRunner implements CommandLineRunner {
private final String semiconductorMatNbrCustomer = "MNR-7307-AU340474.002";
private final String semiconductorMatNbrSupplier = "MNR-8101-ID146955.001";

private final String semiconductorMatNbrCatenaX = "860fb504-b884-4009-9313-c6fb6cdc776b";

private final String supplierSiteNyBpns = "BPNS1234567890ZZ";

private final String supplierSiteLaBpns = "BPNS2222222222SS";

public DataInjectionCommandLineRunner(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
Expand Down Expand Up @@ -251,8 +258,11 @@ private void setupCustomerRole() throws JsonProcessingException {
.locationBpna(mySelf.getSites().first().getAddresses().first().getBpna())
.locationBpns(mySelf.getSites().first().getBpns())
.measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
.quantity(20)
.quantity(500)
.partner(supplierPartner)
.customerOrderId("CNbr-1")
.customerOrderPositionId("C-Pos-1")
.supplierOrderId("SNbr-1")
.build();
var createdMaterialItemStock = materialItemStockService.create(materialItemStock);
log.info("Created MaterialItemStock: \n" + createdMaterialItemStock);
Expand All @@ -278,6 +288,19 @@ private void setupSupplierRole() {
Material semiconductorMaterial = getNewSemiconductorMaterialForSupplier();
Partner mySelf = partnerService.getOwnPartnerEntity();

Site secondSite = new Site(
supplierSiteLaBpns,
"Semiconductor Supplier Inc. Secondary Site",
"BPNA2222222222AA",
"Sunset Blvd. 345",
"90001 Los Angeles",
"USA"
);

mySelf.getSites().add(secondSite);
mySelf = partnerService.update(mySelf);
log.info(String.format("Added Site to mySelf Partner: %s", mySelf));

semiconductorMaterial = materialService.create(semiconductorMaterial);
log.info(String.format("Created product: %s", semiconductorMaterial));

Expand All @@ -297,20 +320,40 @@ private void setupSupplierRole() {
List<Partner> customerPartners = mprService.findAllCustomersForOwnMaterialNumber(semiconductorMaterial.getOwnMaterialNumber());
log.info(String.format("Found customer partners for semiconductor: %s", customerPartners));


Site siteNy = mySelf.getSites().stream().filter(site -> site.getBpns().equals("BPNS1234567890ZZ")).findFirst().get();
Site siteLa = mySelf.getSites().stream().filter(site -> site.getBpns().equals("BPNS2222222222SS")).findFirst().get();

var productItemStock = ProductItemStock.builder()
.locationBpna(mySelf.getSites().first().getAddresses().first().getBpna())
.locationBpns(mySelf.getSites().first().getBpns())
.locationBpna(siteNy.getAddresses().stream().findFirst().get().getBpna())
.locationBpns(siteNy.getBpns())
.measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
.quantity(40)
.quantity(100)
.partner(customerPartner)
.isBlocked(true)
.customerOrderId("CNbr-2")
.customerOrderPositionId("C-Pos-2")
.supplierOrderId("SNbr-2")
.material(semiconductorMaterial)
.lastUpdatedOnDateTime(new Date())
.build();
productItemStock = productItemStockService.create(productItemStock);
log.info("Created ProductItemStock \n" + productItemStock);

var productItemStock2 = ProductItemStock.builder()
.locationBpna(siteLa.getAddresses().stream().findFirst().get().getBpna())
.locationBpns(siteLa.getBpns())
.measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
.quantity(400)
.partner(customerPartner)
.customerOrderId("CNbr-2")
.customerOrderPositionId("C-Pos-2")
.supplierOrderId("SNbr-2")
.material(semiconductorMaterial)
.lastUpdatedOnDateTime(new Date())
.build();
productItemStock2 = productItemStockService.create(productItemStock2);
log.info("Created ProductItemStock 2\n" + productItemStock2);

ReportedProductItemStock reportedProductItemStock = ReportedProductItemStock.builder()
.material(semiconductorMaterial)
.locationBpns(customerPartner.getSites().first().getBpns())
Expand All @@ -332,15 +375,15 @@ private void setupSupplierRole() {
*/
private Partner createAndGetCustomerPartner() {
Partner customerPartnerEntity = new Partner(
"Scenario Customer",
"Control Unit Creator Inc.",
"http://customer-control-plane:8184/api/v1/dsp",
"BPNL4444444444XX",
"BPNS4444444444XX",
"Hauptwerk Musterhausen",
"Control Unit Creator Production Site",
"BPNA4444444444AA",
"Musterstraße 35b",
"77777 Musterhausen",
"Germany"
"13th Street 47",
"10011 New York",
"USA"
);
customerPartnerEntity = partnerService.create(customerPartnerEntity);
log.info(String.format("Created customer partner: %s", customerPartnerEntity));
Expand All @@ -357,20 +400,34 @@ private Partner createAndGetCustomerPartner() {
*/
private Partner createAndGetSupplierPartner() {
Partner supplierPartnerEntity = new Partner(
"Scenario Supplier",
"Semiconductor Supplier Inc.",
"http://supplier-control-plane:9184/api/v1/dsp",
"BPNL1234567890ZZ",
"BPNS1234567890ZZ",
"Konzernzentrale Dudelsdorf",
supplierSiteNyBpns,
"Semiconductor Supplier Inc. Production Site",
"BPNA1234567890AA",
"Heinrich-Supplier-Straße 1",
"77785 Dudelsdorf",
"Germany"
"Wall Street 101",
"10001 New York",
"USA"
);
supplierPartnerEntity = partnerService.create(supplierPartnerEntity);
log.info(String.format("Created supplier partner: %s", supplierPartnerEntity));
supplierPartnerEntity = partnerService.findByUuid(supplierPartnerEntity.getUuid());
log.info(String.format("Found supplier partner: %s", supplierPartnerEntity));

Site secondSite = new Site(
supplierSiteLaBpns,
"Semiconductor Supplier Inc. Secondary Site",
"BPNA2222222222AA",
"Sunset Blvd. 345",
"90001 Los Angeles",
"USA"
);

supplierPartnerEntity.getSites().add(secondSite);
Partner updatedSupplierPartner = partnerService.update(supplierPartnerEntity);
tom-rm-meyer-ISST marked this conversation as resolved.
Fixed
Show resolved Hide resolved
log.info(String.format("Added Site to mySelf Partner: %s", updatedSupplierPartner));

return supplierPartnerEntity;
}

Expand Down Expand Up @@ -402,16 +459,18 @@ private Partner createAndGetNonScenarioCustomer() {
private Material getNewSemiconductorMaterialForSupplier() {
Material material = new Material();
material.setOwnMaterialNumber(semiconductorMatNbrSupplier);
material.setMaterialNumberCx(semiconductorMatNbrCatenaX);
material.setProductFlag(true);
material.setName("semiconductor");
material.setName("Semiconductor");
return material;
}

private Material getNewSemiconductorMaterialForCustomer() {
Material material = new Material();
material.setOwnMaterialNumber(semiconductorMatNbrCustomer);
material.setMaterialNumberCx(semiconductorMatNbrCatenaX);
material.setMaterialFlag(true);
material.setName("semiconductor");
material.setName("Semiconductor");
return material;
}

Expand All @@ -425,7 +484,7 @@ private Material getNewCentralControlUnitMaterial() {
Material material = new Material();
material.setOwnMaterialNumber("MNR-4177-S");
material.setProductFlag(true);
material.setName("central control unit");
material.setName("Central Control Unit");
return material;
}

Expand Down
10 changes: 5 additions & 5 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
own.bpnl=${OWN_BPNL:BPNL4444444444XX}

# Own name (self-description)
own.name=${OWN_NAME:Scenario Customer}
own.name=${OWN_NAME:Control Unit Creator Inc.}

# Own BPNS (optional: if this is set, then set own.site.name as well)
own.bpns=${OWN_BPNS:BPNS4444444444XX}
# Name of Site (see above)
own.site.name=${OWN_SITE:Hauptwerk Musterhausen}
own.site.name=${OWN_SITE:Control Unit Creator Production Site}

# If a BPNS is set, then this BPNA will be attached to it.
# Otherwise, it will be attached immediately to the BPNL (see above)
own.bpna=${OWN_BPNA:BPNA4444444444AA}
own.streetandnumber=${OWN_STREETANDNUMBER:Musterstrasse 35b}
own.zipcodeandcity=${OWN_ZIPCODEANDCITY:77777 Musterhausen}
own.country=${OWN_COUNTRY:Germany}
own.streetandnumber=${OWN_STREETANDNUMBER:13th Street 47}
own.zipcodeandcity=${OWN_ZIPCODEANDCITY:10011 New York}
own.country=${OWN_COUNTRY:USA}

server.ssl.enabled=false
#server.port=8443
Expand Down
14 changes: 7 additions & 7 deletions backend/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
own.bpnl=${OWN_BPNL:BPNL4444444444XX}

# Own name (self-description)
own.name=${OWN_NAME:Scenario Customer}
own.name=${OWN_NAME:Control Unit Creator Inc.}

# Own BPNS (optional: if this is set, then set own.site.name as well)
own.bpns=${OWN_BPNS:BPNS4444444444XY}
own.bpns=${OWN_BPNS:BPNS4444444444XX}
# Name of Site (see above)
own.site.name=${OWN_SITE:Hauptwerk Musterhausen}
own.site.name=${OWN_SITE:Control Unit Creator Production Site}

# If a BPNS is set, then this BPNA will be attached to it.
# Otherwise, it will be attached immediately to the BPNL (see above)
own.bpna=${OWN_BPNA:BPNA4444444444ZZ}
own.streetandnumber=${OWN_STREETANDNUMBER:Musterstrasse 35b}
own.zipcodeandcity=${OWN_ZIPCODEANDCITY:77777 Musterhausen}
own.country=${OWN_COUNTRY:Germany}
own.bpna=${OWN_BPNA:BPNA4444444444AA}
own.streetandnumber=${OWN_STREETANDNUMBER:13th Street 47}
own.zipcodeandcity=${OWN_ZIPCODEANDCITY:10011 New York}
own.country=${OWN_COUNTRY:USA}

# run with:
# ./mvnw spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application.properties"
129 changes: 129 additions & 0 deletions local/postman/Local Dev.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"id": "c99bfe48-fce6-47f2-8f4b-98a64f9dbecc",
"name": "Local Dev",
"values": [
{
"key": "CUSTOMER_PURIS_BACKEND_API_KEY",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_EDC_API_KEY",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_PURIS_BACKEND_API_KEY",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_EDC_API_KEY",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_EDC",
"value": "http://localhost:8181",
"type": "default",
"enabled": true
},
{
"key": "PROTOCOL_PATH",
"value": "api/v1/dsp",
"type": "default",
"enabled": true
},
{
"key": "MANAGEMENT_PATH",
"value": "management",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_EDC",
"value": "http://localhost:9181",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_BPNL",
"value": "BPNL1234567890ZZ",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_BPNL",
"value": "BPNL4444444444XX",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_EDC_EXT_HOSTNAME",
"value": "http://customer-control-plane:8184",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_PURIS_BACKEND",
"value": "http://localhost:8081",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_BPNS",
"value": "BPNS4444444444XX",
"type": "default",
"enabled": true
},
{
"key": "CUSTOMER_BPNA",
"value": "BPNA4444444444AA",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_EDC_EXT_HOSTNAME",
"value": "http://supplier-control-plane:9184",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_PURIS_BACKEND",
"value": "http://localhost:8082",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_BPNS",
"value": "BPNS1234567890ZZ",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_BPNA",
"value": "BPNA1234567890AA",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_BPNS2",
"value": "BPNS2222222222SS",
"type": "default",
"enabled": true
},
{
"key": "SUPPLIER_BPNA2",
"value": "BPNA2222222222AA",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-01-18T16:38:08.553Z",
"_postman_exported_using": "Postman/10.21.14"
}
Loading
Loading