Skip to content

Commit

Permalink
[conluz-74] Supported isThirdParty setting for get and update supplies
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorKhan committed Jun 9, 2024
1 parent 2010827 commit fbe758c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public class SupplyResponse {
@Schema(description = "Whether the supply is enabled or disabled", example = "true")
private final Boolean enabled;
@Schema(description = "Date on which the supply point was registered as valid", example = "true")
private final LocalDate validDateFrom;
private final LocalDate datadisValidDateFrom;
@Schema(description = "Name of the distribution company", example = "Endesa")
private final String distributor;
private final String datadisDistributor;
@Schema(description = "Code of the distribution company", example = "2")
private final String distributorCode;
private final String datadisDistributorCode;
@Schema(description = "Type of measurement point", example = "3")
private final Integer pointType;
private final Integer datadisPointType;
@Schema(description = "Whether is an authorized third parth supply or not", example = "true")
private final Boolean datadisIsThirdParty;
@Schema(description = "MAC address of the Shelly", example = "24:4c:ab:41:99:f6")
private final String shellyMac;
@Schema(description = "Unique identifier of the Shelly", example = "shellyem-244CAB4199F6")
Expand All @@ -47,10 +49,11 @@ public SupplyResponse(Supply supply) {
this.partitionCoefficient = supply.getPartitionCoefficient();
this.enabled = supply.getEnabled();
this.user = supply.getUser() != null ? new UserResponse(supply.getUser()) : null;
this.validDateFrom = supply.getDatadisValidDateFrom();
this.distributor = supply.getDatadisDistributor();
this.distributorCode = supply.getDatadisDistributorCode();
this.pointType = supply.getDatadisPointType();
this.datadisIsThirdParty = supply.getDatadisIsThirdParty();
this.datadisValidDateFrom = supply.getDatadisValidDateFrom();
this.datadisDistributor = supply.getDatadisDistributor();
this.datadisDistributorCode = supply.getDatadisDistributorCode();
this.datadisPointType = supply.getDatadisPointType();
this.shellyMac = supply.getShellyMac();
this.shellyId = supply.getShellyId();
this.shellyMqttPrefix = supply.getShellyMqttPrefix();
Expand Down Expand Up @@ -83,20 +86,24 @@ public Boolean getEnabled() {
return enabled;
}

public LocalDate getValidDateFrom() {
return validDateFrom;
public LocalDate getDatadisValidDateFrom() {
return datadisValidDateFrom;
}

public String getDistributor() {
return distributor;
public String getDatadisDistributor() {
return datadisDistributor;
}

public String getDistributorCode() {
return distributorCode;
public String getDatadisDistributorCode() {
return datadisDistributorCode;
}

public Integer getPointType() {
return pointType;
public Integer getDatadisPointType() {
return datadisPointType;
}

public Boolean getDatadisIsThirdParty() {
return datadisIsThirdParty;
}

public String getShellyMac() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class UpdateSupplyBody {
private String datadisDistributor;
private String datadisDistributorCode;
private Integer datadisPointType;
private Boolean datadisIsThirdParty;
private String shellyMac;
private String shellyId;
private String shellyMqttPrefix;
Expand Down Expand Up @@ -102,6 +103,14 @@ public void setDatadisPointType(Integer datadisPointType) {
this.datadisPointType = datadisPointType;
}

public Boolean getDatadisIsThirdParty() {
return datadisIsThirdParty;
}

public void setDatadisIsThirdParty(Boolean datadisIsThirdParty) {
this.datadisIsThirdParty = datadisIsThirdParty;
}

public String getShellyMac() {
return shellyMac;
}
Expand Down Expand Up @@ -139,6 +148,7 @@ public Supply mapToSupply(UUID supplyId) {
.withDatadisDistributor(datadisDistributor)
.withDatadisDistributorCode(datadisDistributorCode)
.withDatadisPointType(datadisPointType)
.withDatadisIsThirdParty(datadisIsThirdParty)
.withShellyMac(shellyMac)
.withShellyId(shellyId)
.withShellyMqttPrefix(shellyMqttPrefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public Supply update(Supply supply) {
currentSupply.setDatadisDistributor(supply.getDatadisDistributor());
currentSupply.setDatadisDistributorCode(supply.getDatadisDistributorCode());
currentSupply.setDatadisPointType(supply.getDatadisPointType());
currentSupply.setDatadisIsThirdParty(supply.getDatadisIsThirdParty());

currentSupply.setShellyMac(supply.getShellyMac());
currentSupply.setShellyId(supply.getShellyId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ void testUpdateSupplyModifyingAll() throws Exception {
.andExpect(jsonPath("$.address").value(supplyModified.getAddress()))
.andExpect(jsonPath("$.partitionCoefficient").value(supplyModified.getPartitionCoefficient()))
.andExpect(jsonPath("$.enabled").value(supply.getEnabled()))
.andExpect(jsonPath("$.validDateFrom").value(supplyModified.getDatadisValidDateFrom()))
.andExpect(jsonPath("$.distributor").value(supplyModified.getDatadisDistributor()))
.andExpect(jsonPath("$.distributorCode").value(supplyModified.getDatadisDistributorCode()))
.andExpect(jsonPath("$.pointType").value(supplyModified.getDatadisPointType()))
.andExpect(jsonPath("$.datadisValidDateFrom").value(supplyModified.getDatadisValidDateFrom()))
.andExpect(jsonPath("$.datadisDistributor").value(supplyModified.getDatadisDistributor()))
.andExpect(jsonPath("$.datadisDistributorCode").value(supplyModified.getDatadisDistributorCode()))
.andExpect(jsonPath("$.datadisPointType").value(supplyModified.getDatadisPointType()))
.andExpect(jsonPath("$.datadisIsThirdParty").value(supplyModified.getDatadisIsThirdParty()))
.andExpect(jsonPath("$.shellyMac").value(supplyModified.getShellyMac()))
.andExpect(jsonPath("$.shellyId").value(supplyModified.getShellyId()))
.andExpect(jsonPath("$.shellyMqttPrefix").value(supplyModified.getShellyMqttPrefix()))
Expand Down Expand Up @@ -118,10 +119,11 @@ void testWithMissingNotRequiredFields() throws Exception {
.andExpect(jsonPath("$.address").value(supplyModified.getAddress()))
.andExpect(jsonPath("$.partitionCoefficient").value(supplyModified.getPartitionCoefficient()))
.andExpect(jsonPath("$.enabled").value(supply.getEnabled()))
.andExpect(jsonPath("$.validDateFrom").isEmpty())
.andExpect(jsonPath("$.distributor").isEmpty())
.andExpect(jsonPath("$.distributorCode").isEmpty())
.andExpect(jsonPath("$.pointType").isEmpty())
.andExpect(jsonPath("$.datadisValidDateFrom").isEmpty())
.andExpect(jsonPath("$.datadisDistributor").isEmpty())
.andExpect(jsonPath("$.datadisDistributorCode").isEmpty())
.andExpect(jsonPath("$.datadisPointType").isEmpty())
.andExpect(jsonPath("$.datadisIsThirdParty").isEmpty())
.andExpect(jsonPath("$.shellyMac").isEmpty())
.andExpect(jsonPath("$.shellyId").isEmpty())
.andExpect(jsonPath("$.shellyMqttPrefix").isEmpty())
Expand Down

0 comments on commit fbe758c

Please sign in to comment.