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

Commit

Permalink
#4 Verify 4 properties where two gives error
Browse files Browse the repository at this point in the history
  • Loading branch information
baardl committed Apr 9, 2021
1 parent d8ee043 commit 16a76b8
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
"description": "FW Series Bacnet Device"
}
},
{
"property-identifier": "units",
"read-result": {
"propertyAccessError": {
"errorClass": "property",
"errorCode": "unknown-property"
}
}
},
{
"property-identifier": "present-value",
"read-result": {
Expand Down Expand Up @@ -98,7 +107,7 @@
class ReadObjectPropertiesResultParserTest {

@Test
void parse() throws BacnetParserException {
void parseSingleObjectMultipleProperties() throws BacnetParserException {
String hexString = "0c008000001e294d4e7514005549315f5a6f6e6554656d70657261747572654f291c4e750f00416e616c6f672056616c756520304f29754e915f4f29554e4441b3332c4f1f";
ParserResult<ReadObjectPropertiesResult> parserResult = ReadObjectPropertiesResultParser.parse(hexString);
assertNotNull(parserResult);
Expand All @@ -116,6 +125,26 @@ void parse() throws BacnetParserException {
assertEquals(Float.parseFloat("22.3999862670898"), resultList.get(3).getReadResult().get(PropertyIdentifier.PresentValue));
}

@Test
void parseSingleObjectMultiplePropertiesWithError() throws BacnetParserException {
String hexString = "0c020000081e294d4e75060046574643554f291c4e751800465720536572696573204261636e6574204465766963654f29755e910291205f29555e910291205f1f";
ParserResult<ReadObjectPropertiesResult> parserResult = ReadObjectPropertiesResultParser.parse(hexString);
assertNotNull(parserResult);
assertTrue(parserResult.isParsedOk());
ReadObjectPropertiesResult propertiesResult = parserResult.getParsedObject();
assertNotNull(propertiesResult);
ObjectId objectId = new ObjectId(ObjectType.Device, 8);
assertEquals(objectId, propertiesResult.getObjectId());
List<ReadPropertyResult> resultList = propertiesResult.getResults();
assertNotNull(resultList);
assertEquals(4, resultList.size());
assertEquals("FWFCU", resultList.get(0).getReadResult().get(PropertyIdentifier.ObjectName));
assertEquals("FW Series Bacnet Device", resultList.get(1).getReadResult().get(PropertyIdentifier.Description));
assertNotNull(resultList.get(2).getReadResult().get(PropertyIdentifier.XxError));
assertNotNull(resultList.get(3).getReadResult().get(PropertyIdentifier.XxError));
// assertEquals(Float.parseFloat("22.3999862670898"), resultList.get(3).getReadResult().get(PropertyIdentifier.PresentValue));
}

@Test
void unparsableHexString() {
String hexString = "0000";
Expand Down

0 comments on commit 16a76b8

Please sign in to comment.