Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
#14 Renaming for better understanding.
Browse files Browse the repository at this point in the history
  • Loading branch information
baardl committed Sep 10, 2020
1 parent 0bc3c96 commit 710cf34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
public class ObservationParser {
private static final Logger log = getLogger(ObservationParser.class);

public static ObservationList mapToChangeOfValueObservation(Service service, String changeOfValueHexString) {
/**
* Transform a BacNet message notification describing values updated. Each message may contain a single update,
* or multiple updates from multiple sensors.
* @param service detect if the notification is single, multiple, confirmed or unconfirmed.
* @param changeOfValueHexString BacNet hex string where the BVLC and NPDU part is previously parsed, and removed.
* @return list of individual observations seen in this COV Notification.
*/
public static ObservationList parseChangeOfValueNotification(Service service, String changeOfValueHexString) {

/*
Confirmed COV 060109121c020003e92c008000013a012b4e09552e44000000002f096f2e8204002f4f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.slf4j.Logger;

import static no.entra.bacnet.json.configuration.ConfigurationParser.*;
import static no.entra.bacnet.json.observation.ObservationParser.mapToChangeOfValueObservation;
import static no.entra.bacnet.json.observation.ObservationParser.parseChangeOfValueNotification;
import static org.slf4j.LoggerFactory.getLogger;

public class UnconfirmedService extends Service {
Expand Down Expand Up @@ -47,7 +47,7 @@ public static BacnetMessage tryToUnderstandUnconfirmedRequest(Service service) {
break;
case UnconfirmedCovNotification:
String changeOfValueHexString = service.getUnprocessedHexString();
bacnetMessage = mapToChangeOfValueObservation(service, changeOfValueHexString);
bacnetMessage = parseChangeOfValueNotification(service, changeOfValueHexString);
break;
default:
log.trace("I do not know how to parse this service: {}", service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.List;

import static no.entra.bacnet.json.observation.ObservationParser.mapToChangeOfValueObservation;
import static no.entra.bacnet.json.observation.ObservationParser.parseChangeOfValueNotification;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -36,7 +36,7 @@ void validateUnConfirmedCovNotificationTest() {
String apduHexString = npduResult.getUnprocessedHexString();
Service service = ServiceParser.fromApduHexString(apduHexString);
String covHexString = service.getUnprocessedHexString();
ObservationList observations = mapToChangeOfValueObservation(service, covHexString);
ObservationList observations = parseChangeOfValueNotification(service, covHexString);
assertNotNull(observations);
Source source = observations.getObservations().get(0).getSource();
assertEquals("1001", source.getDeviceId());
Expand Down Expand Up @@ -69,7 +69,7 @@ void buildObservationFromUnConfirmedCovNotificationTest() {
String apduHexString = npduResult.getUnprocessedHexString();
Service service = ServiceParser.fromApduHexString(apduHexString);
String covHexString = service.getUnprocessedHexString();
ObservationList observations = mapToChangeOfValueObservation(service, covHexString);
ObservationList observations = parseChangeOfValueNotification(service, covHexString);
assertNotNull(observations);
assertEquals(2, observations.getObservations().size());
}
Expand All @@ -84,7 +84,7 @@ void buildObservationFromConfirmedCovNotificationTest() {
String apduHexString = npduResult.getUnprocessedHexString();
Service service = ServiceParser.fromApduHexString(apduHexString);
String covHexString = service.getUnprocessedHexString();
ObservationList observations = mapToChangeOfValueObservation(service, covHexString);
ObservationList observations = parseChangeOfValueNotification(service, covHexString);
assertNotNull(observations);
Source source = observations.getObservations().get(0).getSource();
assertEquals("1001", source.getDeviceId());
Expand All @@ -111,7 +111,7 @@ void buildObservationFromConfirmedCovNotificationTest() {
void validateConfirmedCovNotificationWithPresentValue() {
String covHexString = "0f0109121c020200252c0000000039004e095519012e4441a4cccd2f4f";
Service service = new Service(PduType.ConfirmedRequest, null);
ObservationList observations = mapToChangeOfValueObservation(service, covHexString);
ObservationList observations = parseChangeOfValueNotification(service, covHexString);
// ObservationList observations = parseConfirmedCOVNotification(covHexString);
Observation observation = observations.getObservations().get(0);
assertEquals("131109", observation.getSource().getDeviceId());
Expand All @@ -131,10 +131,9 @@ void validateRestartTime() {
String apduHexString = npduResult.getUnprocessedHexString();
Service service = ServiceParser.fromApduHexString(apduHexString);
String covHexString = service.getUnprocessedHexString();
ObservationList observations = mapToChangeOfValueObservation(service, covHexString);
ObservationList observations = parseChangeOfValueNotification(service, covHexString);
assertNotNull(observations);
assertEquals(2, observations.getObservations().size());
//#13 Fix test to fail, then succed
}

@Test
Expand Down

0 comments on commit 710cf34

Please sign in to comment.