Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #66 from dcsaorg/DDT-1385-remove-reefers
Browse files Browse the repository at this point in the history
DDT-1385 removed reefers for publication
  • Loading branch information
pimg authored Dec 28, 2022
2 parents 656bae0 + d366b2d commit f37e405
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
- Publication**

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void createRequestedEquipments(
requestedEquipmentGroupMapper.toDAO(
re,
booking,
activeReeferSettingsService.createBookingActiveReeferSettings(re.activeReeferSettings()),
activeReeferSettingsService.createBookingActiveReeferSettings(null),
links
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
public class UtilizedTransportEquipmentService {

private final EquipmentService equipmentService;
private final ActiveReeferSettingsService activeReeferSettingsService;

private final UtilizedTransportEquipmentRepository utilizedTransportEquipmentRepository;
private final RequestedEquipmentGroupRepository requestedEquipmentGroupRepository;

private final UtilizedTransportEquipmentMapper utilizedTransportEquipmentMapper;

Expand All @@ -36,7 +34,7 @@ public Map<String, UtilizedTransportEquipment> createUtilizedTransportEquipment(
return utilizedTransportEquipmentRepository
.saveAll(
utilizedTransportEquipmentTOs.stream()
.map(ute -> utilizedTransportEquipmentMapper.toDAO(ute, createRequestedEquipmentGroup(ute)))
.map(ute -> utilizedTransportEquipmentMapper.toDAO(ute, null))
.toList())
.stream()
.collect(
Expand All @@ -46,17 +44,4 @@ public Map<String, UtilizedTransportEquipment> createUtilizedTransportEquipment(
utilizedTransportEquipment -> utilizedTransportEquipment));
}

private RequestedEquipmentGroup createRequestedEquipmentGroup(UtilizedTransportEquipmentTO uteTO) {
if (uteTO == null || uteTO.activeReeferSettings() == null) {
return null;
}

return requestedEquipmentGroupRepository.save(
RequestedEquipmentGroup.builder()
.confirmedEquipmentIsoEquipmentCode(uteTO.equipment().isoEquipmentCode())
.confirmedEquipmentUnits(uteTO.equipment().isoEquipmentCode() != null ? 1 : null)
.isShipperOwned(uteTO.isShipperOwned())
.activeReeferSettings(activeReeferSettingsService.createShippingInstructionActiveReeferSettings(uteTO.activeReeferSettings()))
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
public interface RequestedEquipmentGroupMapper {
@Mapping(source = "booking", target = "booking")
@Mapping(source = "booking.id", target = "id", ignore = true)
@Mapping(source = "activeReeferSettings", target = "activeReeferSettings")
@Mapping(source = "requestedEquipment.isoEquipmentCode", target = "requestedEquipmentIsoEquipmentCode")
@Mapping(source = "requestedEquipment.units", target = "requestedEquipmentUnits")
@Mapping(expression = "java(mapCommodityRequestedEquipmentLink(links, requestedEquipment.commodityRequestedEquipmentLink()))", target = "commodityRequestedEquipmentLink")
Expand All @@ -41,7 +40,6 @@ default CommodityRequestedEquipmentLink mapCommodityRequestedEquipmentLink(
@Mapping(source = "requestedEquipmentUnits", target = "units")
@Mapping(source = "requestedEquipmentIsoEquipmentCode", target = "isoEquipmentCode")
@Mapping(source = "requestedEquipment.commodityRequestedEquipmentLink.commodityRequestedEquipmentLink", target = "commodityRequestedEquipmentLink")
@Mapping(target = "activeReeferSettings", qualifiedByName = "toBookingActiveReeferSettingsTO")
RequestedEquipmentTO toTO(RequestedEquipmentGroup requestedEquipment);

default String mapEquipmentToEquipmentReference(Equipment equipment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ public interface UtilizedTransportEquipmentMapper {
@Mapping(source = "requestedEquipmentGroup.id", target = "id", ignore = true)
UtilizedTransportEquipment toDAO(UtilizedTransportEquipmentTO utilizedTransportEquipmentTO, RequestedEquipmentGroup requestedEquipmentGroup);

@Mapping(source = "utilizedTransportEquipment.requestedEquipmentGroup.activeReeferSettings", target = "activeReeferSettings", qualifiedByName = "toShippingInstructionActiveReeferSettingsTO")
UtilizedTransportEquipmentTO toDTO(UtilizedTransportEquipment utilizedTransportEquipment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public static RequestedEquipmentTO requestedEquipmentTORef1() {
.isoEquipmentCode("GP22")
.units(1)
.isShipperOwned(true)
.activeReeferSettings(BookingActiveReeferSettingsDataFactory.bkgFreezer())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class GetBooking {
@Spy private AddressMapper addressMapper = Mappers.getMapper(AddressMapper.class);
@Spy private RequestedEquipmentGroupMapper requestedEquipmentGroupMapper = Mappers.getMapper(RequestedEquipmentGroupMapper.class);
@Spy private CommodityRequestedEquipmentLinkMapper commodityRequestedEquipmentLinkMapper = new CommodityRequestedEquipmentLinkMapper();
@Spy private ActiveReeferSettingsMapper activeReeferSettingsMapper = Mappers.getMapper(ActiveReeferSettingsMapper.class);

@InjectMocks private BookingService service;

Expand All @@ -74,7 +73,6 @@ void setupMappers() {
ReflectionTestUtils.setField(bookingMapper, "displayedAddressMapper", displayedAddressMapper);
ReflectionTestUtils.setField(bookingMapper, "requestedEquipmentGroupMapper", requestedEquipmentGroupMapper);
ReflectionTestUtils.setField(bookingMapper, "commodityRequestedEquipmentLinkMapper", commodityRequestedEquipmentLinkMapper);
ReflectionTestUtils.setField(requestedEquipmentGroupMapper, "activeReeferSettingsMapper", activeReeferSettingsMapper);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testCreate_WithEquipmentReferences() {
// Verify
verify(equipmentService).resolveEquipments(eq(List.of(requestedEquipmentTO)), any(), any());
verify(requestedEquipmentGroupRepository).save(expectedGroup);
verify(activeReeferSettingsService).createBookingActiveReeferSettings(requestedEquipmentTO.activeReeferSettings());
verify(activeReeferSettingsService).createBookingActiveReeferSettings(null);
verify(utilizedTransportEquipmentRepository).saveAll(any());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ public record RequestedEquipmentTO(
Boolean isShipperOwned,

@Size(max = 100)
String commodityRequestedEquipmentLink,
String commodityRequestedEquipmentLink

BookingActiveReeferSettingsTO activeReeferSettings
) {
@Builder(toBuilder = true)
public RequestedEquipmentTO { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public record UtilizedTransportEquipmentTO(
Boolean isShipperOwned,

@Valid
List<SealTO> seals,

@Valid
ShippingInstructionActiveReeferSettingsTO activeReeferSettings
List<SealTO> seals
) {
@Builder
public UtilizedTransportEquipmentTO{}
Expand Down
Loading

0 comments on commit f37e405

Please sign in to comment.