Skip to content

Commit

Permalink
SMHE-832: GetActualMeterRead file and test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Bolder committed Jun 28, 2022
1 parent 12cc6ac commit 3413b03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.opensmartgridplatform.domain.smartmetering.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;

@Data
Expand All @@ -15,8 +15,8 @@ public class CosemObject {
public int version;
public String obis;
public String group;
public ArrayList<String> meterTypes;
public ArrayList<Attribute> attributes;
public List<String> meterTypes;
public List<Attribute> attributes;

public Attribute getAttribute(final int id) {
return this.attributes.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

@Slf4j
class MeterConfigTest {

@Test
void loadJsonFile() throws IOException {
private ObjectMapper objectMapper;

final ObjectMapper objectMapper = new ObjectMapper();
@BeforeEach
void init() {
this.objectMapper = new ObjectMapper();
}

final Resource resource = new ClassPathResource("/meter-profile-config-SMR-5.0.json");
@Test
void loadJsonFile() throws IOException {

final MeterConfig meterConfig = objectMapper.readValue(resource.getFile(), MeterConfig.class);
final MeterConfig meterConfig =
this.objectMapper.readValue(
new ClassPathResource("/meter-profile-config-SMR-5.0.json").getFile(),
MeterConfig.class);

Assertions.assertNotNull(meterConfig);
Assertions.assertEquals(
Expand All @@ -40,14 +46,16 @@ void loadJsonFile() throws IOException {
@Test
void loadJsonFileAndGetActualMeterReads() throws IOException {

final ObjectMapper objectMapper = new ObjectMapper();

final Resource resource =
new ClassPathResource("/meter-profile-config-SMR-5.0-GetActualMeterReads.json");

final MeterConfig meterConfig = objectMapper.readValue(resource.getFile(), MeterConfig.class);
final MeterConfig meterConfig =
this.objectMapper.readValue(
new ClassPathResource("/meter-profile-config-SMR-5.0-GetActualMeterReads.json")
.getFile(),
MeterConfig.class);

Assertions.assertNotNull(meterConfig);
Assertions.assertEquals(
"MeterConfig(profile=SMR, version=5.0, description=Profile for Smart Meter Requirements 5.0 nieuw, settings=[Setting(firmwareUpdateType=SMR)], cosemObjects=[CosemObject(tag=CLOCK, description=Clock, classId=8, version=0, obis=0-0:1.0.0.255, group=ABSTRACT, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=time, datatype=octet-string, valuetype=DYNAMIC, value=CURRENT_LOCAL_DATE_AND_TIME, access=RW), Attribute(id=3, description=time_zone, datatype=long, valuetype=FIXED_IN_PROFILE, value=-60, access=RW), Attribute(id=4, description=status, datatype=clock_status, valuetype=DYNAMIC, value=OK, access=R)]), CosemObject(tag=ACTIVE_ENERGY_IMPORT, description=Active energy import (+A), classId=3, version=0, obis=1-0:1.8.0.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=10001, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)]), CosemObject(tag=ACTIVE_ENERGY_EXPORT, description=Active energy export (-A), classId=3, version=0, obis=1-0:2.8.0.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=20001, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)]), CosemObject(tag=ACTIVE_ENERGY_IMPORT_RATE_1, description=Active energy import (+A) rate 1, classId=3, version=0, obis=1-0:1.8.1.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=10002, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)]), CosemObject(tag=ACTIVE_ENERGY_IMPORT_RATE_2, description=Active energy import (+A) rate 2, classId=3, version=0, obis=1-0:1.8.2.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=10003, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)]), CosemObject(tag=ACTIVE_ENERGY_EXPORT_RATE_1, description=Active energy export (+A) rate 1, classId=3, version=0, obis=1-0:2.8.1.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=20002, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)]), CosemObject(tag=ACTIVE_ENERGY_EXPORT_RATE_2, description=Active energy export (+A) rate 2, classId=3, version=0, obis=1-0:2.8.2.255, group=ELECTRICITY, meterTypes=[SP, PP], attributes=[Attribute(id=2, description=value, datatype=double-long-unsigned, valuetype=DYNAMIC, value=20003, access=R), Attribute(id=3, description=scaler_unit, datatype=scal_unit_type, valuetype=FIXED_IN_PROFILE, value=0, Wh, access=R)])])",
meterConfig.toString());
log.debug("meterConfig=[{}]", meterConfig);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"profile": "SMR",
"version": "5.0",
"description": "Profile for Smart Meter Requirements 5.0",
"description": "Profile for Smart Meter Requirements 5.0 nieuw",
"settings": [
{
"firmware update type": "SMR"
Expand Down

0 comments on commit 3413b03

Please sign in to comment.