Skip to content

Commit

Permalink
Tpp Model Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea committed Oct 29, 2024
1 parent a958fa7 commit d80b832
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/it/gov/pagopa/tpp/dto/TppDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;

@Data
@SuperBuilder
@NoArgsConstructor
Expand All @@ -18,4 +20,6 @@ public class TppDTO {
private AuthenticationType authenticationType;
private Contact contact;
private Boolean state;
private LocalDateTime creationDate;
private LocalDateTime lastUpdateDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public TppDTO map(Tpp tpp){
.businessName(tpp.getBusinessName())
.contact(tpp.getContact())
.entityId(tpp.getEntityId())
.creationDate(tpp.getCreationDate())
.lastUpdateDate(tpp.getLastUpdateDate())
.build();
}
}
6 changes: 5 additions & 1 deletion src/main/java/it/gov/pagopa/tpp/model/Tpp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import lombok.experimental.SuperBuilder;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

@Document(collection = "tpp")
@Data
@SuperBuilder
Expand All @@ -20,6 +22,8 @@ public class Tpp {
private String messageUrl;
private String authenticationUrl;
private AuthenticationType authenticationType;
private Contact contact;
private Boolean state;
private Contact contact;
private LocalDateTime creationDate;
private LocalDateTime lastUpdateDate;
}
5 changes: 4 additions & 1 deletion src/main/java/it/gov/pagopa/tpp/service/TppServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import reactor.core.publisher.Mono;


import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -48,7 +49,6 @@ public Mono<List<TppDTO>> getEnabledList(List<String> tppIdList) {
}


//TODO Definire i campi non aggiornabili
@Override
public Mono<TppDTO> upsert(TppDTO tppDTO) {
log.info("[EMD-TPP][UPSERT] Received tppDTO: {}", inputSanify(tppDTO.toString()));
Expand All @@ -57,13 +57,16 @@ public Mono<TppDTO> upsert(TppDTO tppDTO) {
.flatMap(tppDB -> {
log.info("[EMD-TPP][UPSERT] TPP with tppId:[{}] already exists",(tppDTO.getTppId()));
tppReceived.setId(tppDB.getId());
tppReceived.setLastUpdateDate(LocalDateTime.now());
return tppRepository.save(tppReceived)
.map(mapperToDTO::map)
.doOnSuccess(savedTpp -> log.info("[EMD-TPP][UPSERT] Updated existing TPP"));
})
.switchIfEmpty(
Mono.defer(() -> {
tppReceived.setTppId("%s_%d".formatted(UUID.randomUUID().toString(), System.currentTimeMillis()));
tppReceived.setCreationDate(LocalDateTime.now());
tppReceived.setLastUpdateDate(LocalDateTime.now());
return tppRepository.save(tppReceived)
.map(mapperToDTO::map)
.doOnSuccess(savedTpp -> log.info("[EMD-TPP][UPSERT] Created TPP"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void stateUpdate_Ok() {
.consumeWith(response -> {
TppDTO resultResponse = response.getResponseBody();
Assertions.assertNotNull(resultResponse);
Assertions.assertEquals(resultResponse,mockTppDTO);
});
}

Expand All @@ -85,6 +86,7 @@ void get_Ok() {
.consumeWith(response -> {
TppDTO resultResponse = response.getResponseBody();
Assertions.assertNotNull(resultResponse);
Assertions.assertEquals(resultResponse,mockTppDTO);
});
}

Expand Down

0 comments on commit d80b832

Please sign in to comment.