You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/11/09 15:41:32 UTC

[incubator-plc4x] branch master updated: - Testing of the Default message types in driver base - Fixing a bug in DefaultPlcReadResponse calling isValidDateTime instead of isValidByteArray to validate a byte array

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e482fd  - Testing of the Default message types in driver base - Fixing a bug in DefaultPlcReadResponse calling isValidDateTime instead of isValidByteArray to validate a byte array
8e482fd is described below

commit 8e482fd3821de44427ab0cfb2d529c348bf6a5e4
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri Nov 9 16:41:28 2018 +0100

    - Testing of the Default message types in driver base
    - Fixing a bug in DefaultPlcReadResponse calling isValidDateTime instead of isValidByteArray to validate a byte array
---
 .../java/base/messages/DefaultPlcReadResponse.java |  11 +-
 .../messages/DefaultPlcReadResponseSpec.groovy     |   1 +
 .../base/messages/DefaultPlcReadResponseTest.java  | 340 ++++-----------------
 .../messages/DefaultPlcSubscriptionEventTest.java  | 324 ++------------------
 .../DefaultPlcSubscriptionResponseTest.java        |  32 +-
 .../base/messages/DefaultPlcWriteResponseTest.java |  41 +++
 6 files changed, 151 insertions(+), 598 deletions(-)

diff --git a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
index fdd44fb..6048e55 100644
--- a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
+++ b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
@@ -536,7 +536,7 @@ public class DefaultPlcReadResponse implements InternalPlcReadResponse {
     @Override
     public boolean isValidByteArray(String name, int index) {
         BaseDefaultFieldItem fieldInternal = getFieldInternal(name);
-        return fieldInternal.isValidDateTime(index);
+        return fieldInternal.isValidByteArray(index);
     }
 
     @Override
@@ -566,16 +566,13 @@ public class DefaultPlcReadResponse implements InternalPlcReadResponse {
         Objects.requireNonNull(name, "Name argument required");
         // If this field doesn't exist, ignore it.
         if (values.get(name) == null) {
-            throw new PlcRuntimeException("No field with name '" + name + "' present in the response");
+            throw new PlcInvalidFieldException(name);
         }
         if (values.get(name).getKey() != PlcResponseCode.OK) {
             throw new PlcRuntimeException("Field '" + name + "' could not be fetched, response was " + values.get(name).getKey());
         }
-        BaseDefaultFieldItem value = values.get(name).getValue();
-        if (value == null) {
-            throw new IllegalStateException(String.format("Null field detected for field name %s", name));
-        }
-        return value;
+        // No need to check for "null" as this is already captured by the constructors.
+        return values.get(name).getValue();
     }
 
 }
diff --git a/plc4j/protocols/driver-bases/base/src/test/groovy/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseSpec.groovy b/plc4j/protocols/driver-bases/base/src/test/groovy/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseSpec.groovy
index f41dc54..744dcb2 100644
--- a/plc4j/protocols/driver-bases/base/src/test/groovy/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseSpec.groovy
+++ b/plc4j/protocols/driver-bases/base/src/test/groovy/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseSpec.groovy
@@ -37,6 +37,7 @@ class DefaultPlcReadResponseSpec extends Specification {
         setup:
         InternalPlcReadRequest request = Mock(InternalPlcReadRequest)
         request.getFieldNames() >> ['foo']
+
         when:
         DefaultPlcReadResponse SUT = new DefaultPlcReadResponse(request,
             ["foo": new ImmutablePair<>(PlcResponseCode.OK, fieldType.newInstance(*fieldValues))])
diff --git a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseTest.java b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseTest.java
index ed3e926..223390e 100644
--- a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseTest.java
+++ b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponseTest.java
@@ -19,330 +19,102 @@
 
 package org.apache.plc4x.java.base.messages;
 
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
+import org.apache.plc4x.java.api.model.PlcField;
+import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.base.messages.items.BaseDefaultFieldItem;
+import org.apache.plc4x.java.base.messages.items.DefaultByteArrayFieldItem;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
 class DefaultPlcReadResponseTest {
 
+    @Mock
+    private InternalPlcReadRequest request;
+    private DefaultPlcReadResponse SUT;
+
     @BeforeEach
     void setUp() {
+        Byte[] data = new Byte[] {(byte) 0x42, (byte) 0x23};
+        Map<String, Pair<PlcResponseCode, BaseDefaultFieldItem>> fields = new HashMap<>();
+        fields.put("foo", new ImmutablePair<>(PlcResponseCode.OK, new DefaultByteArrayFieldItem(data)));
+        fields.put("bar", new ImmutablePair<>(PlcResponseCode.NOT_FOUND, new DefaultByteArrayFieldItem(data)));
+        SUT = new DefaultPlcReadResponse(request, fields);
     }
 
     @Test
     void getRequest() {
-    }
-
-    @Test
-    void getNumberOfValues() {
-    }
-
-    @Test
-    void getFieldNames() {
+        assertThat(SUT.getRequest(), equalTo(request));
     }
 
     @Test
     void getField() {
+        when(request.getField("foo")).thenReturn(mock(PlcField.class));
+        PlcField field = SUT.getField("foo");
+        assertThat(field, notNullValue());
     }
 
     @Test
-    void getResponseCode() {
-    }
-
-    @Test
-    void getValues() {
-    }
-
-    @Test
-    void getObject() {
-    }
-
-    @Test
-    void getObjectWithName() {
-    }
-
-    @Test
-    void getAllObjects() {
-    }
-
-    @Test
-    void isValidBoolean() {
-    }
-
-    @Test
-    void isValidBooleanWithName() {
-    }
-
-    @Test
-    void getBoolean() {
-    }
-
-    @Test
-    void getBooleanWithName() {
-    }
-
-    @Test
-    void getAllBooleans() {
-    }
-
-    @Test
-    void isValidByte() {
-    }
-
-    @Test
-    void isValidByteWithName() {
-    }
-
-    @Test
-    void getByte() {
-    }
-
-    @Test
-    void getByteWithName() {
-    }
-
-    @Test
-    void getAllBytes() {
-    }
-
-    @Test
-    void isValidShort() {
-    }
-
-    @Test
-    void isValidShortWithName() {
-    }
-
-    @Test
-    void getShort() {
-    }
-
-    @Test
-    void getShortWithName() {
-    }
-
-    @Test
-    void getAllShorts() {
-    }
-
-    @Test
-    void isValidInteger() {
-    }
-
-    @Test
-    void isValidIntegerWithName() {
-    }
-
-    @Test
-    void getInteger() {
-    }
-
-    @Test
-    void getIntegerWithName() {
-    }
-
-    @Test
-    void getAllIntegers() {
-    }
-
-    @Test
-    void isValidBigInteger() {
-    }
-
-    @Test
-    void isValidBigIntegerWithName() {
-    }
-
-    @Test
-    void getBigInteger() {
-    }
-
-    @Test
-    void getBigIntegerWithName() {
-    }
-
-    @Test
-    void getAllBigIntegers() {
-    }
-
-    @Test
-    void isValidLong() {
-    }
-
-    @Test
-    void isValidLongWithName() {
-    }
-
-    @Test
-    void getLong() {
-    }
-
-    @Test
-    void getLongWithName() {
-    }
-
-    @Test
-    void getAllLongs() {
-    }
-
-    @Test
-    void isValidFloat() {
-    }
-
-    @Test
-    void isValidFloatWithName() {
-    }
-
-    @Test
-    void getFloat() {
-    }
-
-    @Test
-    void getFloatWithName() {
-    }
-
-    @Test
-    void getAllFloats() {
-    }
-
-    @Test
-    void isValidDouble() {
-    }
-
-    @Test
-    void isValidDoubleWithName() {
-    }
-
-    @Test
-    void getDouble() {
-    }
-
-    @Test
-    void getDoubleWithName() {
-    }
-
-    @Test
-    void getAllDoubles() {
-    }
-
-    @Test
-    void isValidBigDecimal() {
-    }
-
-    @Test
-    void isValidBigDecimalWithName() {
-    }
-
-    @Test
-    void getBigDecimal() {
-    }
-
-    @Test
-    void getBigDecimalWithName() {
-    }
-
-    @Test
-    void getAllBigDecimals() {
-    }
-
-    @Test
-    void isValidString() {
-    }
-
-    @Test
-    void isValidStringWithName() {
-    }
-
-    @Test
-    void getString() {
-    }
-
-    @Test
-    void getStringWithName() {
-    }
-
-    @Test
-    void getAllStrings() {
-    }
-
-    @Test
-    void isValidTime() {
+    void getResponseCodeForNonexistentField() {
+        assertThrows(PlcInvalidFieldException.class, () -> SUT.getResponseCode("hurz"));
     }
 
     @Test
-    void isValidTimeWithName() {
-    }
-
-    @Test
-    void getTime() {
-    }
-
-    @Test
-    void getTimeWithName() {
-    }
-
-    @Test
-    void getAllTimes() {
-    }
-
-    @Test
-    void isValidDate() {
-    }
-
-    @Test
-    void isValidDateWithName() {
-    }
-
-    @Test
-    void getDate() {
-    }
-
-    @Test
-    void getDateWithName() {
-    }
-
-    @Test
-    void getAllDates() {
-    }
-
-    @Test
-    void isValidDateTime() {
-    }
-
-    @Test
-    void isValidDateTimeWithName() {
-    }
-
-    @Test
-    void getDateTime() {
-    }
-
-    @Test
-    void getDateTimeWithName() {
+    void isValidByteArray() {
+        boolean valid = SUT.isValidByteArray("foo");
+        assertThat(valid, equalTo(true));
     }
 
     @Test
-    void getAllDateTimes() {
+    void checkInvalidField() {
+        assertThrows(PlcInvalidFieldException.class, () -> SUT.isValidByteArray("hurz"));
     }
 
     @Test
-    void isValidByteArray() {
+    void checkNonOkResponseCode() {
+        assertThrows(PlcRuntimeException.class, () -> SUT.isValidByteArray("bar"));
     }
 
     @Test
-    void isValidByteArrayWithName() {
+    void isValidByteArrayWithIndex() {
+        boolean valid = SUT.isValidByteArray("foo", 0);
+        assertThat(valid, equalTo(true));
     }
 
     @Test
     void getByteArray() {
+        Byte[] data = SUT.getByteArray("foo");
+        assertThat(data, notNullValue());
     }
 
     @Test
-    void getByteArrayWithName() {
+    void getByteArrayWithIndex() {
+        Byte[] data = SUT.getByteArray("foo", 0);
+        assertThat(data, notNullValue());
     }
 
     @Test
     void getAllByteArrays() {
+        Collection<Byte[]> byteArrays = SUT.getAllByteArrays("foo");
+        assertThat(byteArrays, notNullValue());
     }
 
-
 }
\ No newline at end of file
diff --git a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionEventTest.java b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionEventTest.java
index a6b04bf..f2affa4 100644
--- a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionEventTest.java
+++ b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionEventTest.java
@@ -19,324 +19,48 @@
 
 package org.apache.plc4x.java.base.messages;
 
+import org.apache.commons.lang3.NotImplementedException;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.base.messages.items.BaseDefaultFieldItem;
+import org.apache.plc4x.java.base.messages.items.DefaultByteFieldItem;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-class DefaultPlcSubscriptionEventTest {
-
-    @BeforeEach
-    void setUp() {
-    }
-
-    @Test
-    void getNumberOfValues() {
-    }
-
-    @Test
-    void getObject() {
-    }
-
-    @Test
-    void getObject1() {
-    }
-
-    @Test
-    void getAllObjects() {
-    }
-
-    @Test
-    void isValidBoolean() {
-    }
-
-    @Test
-    void isValidBoolean1() {
-    }
-
-    @Test
-    void getBoolean() {
-    }
-
-    @Test
-    void getBoolean1() {
-    }
-
-    @Test
-    void getAllBooleans() {
-    }
-
-    @Test
-    void isValidByte() {
-    }
-
-    @Test
-    void isValidByte1() {
-    }
-
-    @Test
-    void getByte() {
-    }
-
-    @Test
-    void getByte1() {
-    }
-
-    @Test
-    void getAllBytes() {
-    }
-
-    @Test
-    void isValidShort() {
-    }
-
-    @Test
-    void isValidShort1() {
-    }
-
-    @Test
-    void getShort() {
-    }
-
-    @Test
-    void getShort1() {
-    }
-
-    @Test
-    void getAllShorts() {
-    }
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
 
-    @Test
-    void isValidInteger() {
-    }
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-    @Test
-    void isValidInteger1() {
-    }
-
-    @Test
-    void getInteger() {
-    }
-
-    @Test
-    void getInteger1() {
-    }
-
-    @Test
-    void getAllIntegers() {
-    }
-
-    @Test
-    void isValidBigInteger() {
-    }
-
-    @Test
-    void isValidBigInteger1() {
-    }
-
-    @Test
-    void getBigInteger() {
-    }
-
-    @Test
-    void getBigInteger1() {
-    }
-
-    @Test
-    void getAllBigIntegers() {
-    }
-
-    @Test
-    void isValidLong() {
-    }
-
-    @Test
-    void isValidLong1() {
-    }
-
-    @Test
-    void getLong() {
-    }
-
-    @Test
-    void getLong1() {
-    }
-
-    @Test
-    void getAllLongs() {
-    }
-
-    @Test
-    void isValidFloat() {
-    }
-
-    @Test
-    void isValidFloat1() {
-    }
-
-    @Test
-    void getFloat() {
-    }
-
-    @Test
-    void getFloat1() {
-    }
-
-    @Test
-    void getAllFloats() {
-    }
-
-    @Test
-    void isValidDouble() {
-    }
-
-    @Test
-    void isValidDouble1() {
-    }
-
-    @Test
-    void getDouble() {
-    }
-
-    @Test
-    void getDouble1() {
-    }
-
-    @Test
-    void getAllDoubles() {
-    }
-
-    @Test
-    void isValidBigDecimal() {
-    }
-
-    @Test
-    void isValidBigDecimal1() {
-    }
-
-    @Test
-    void getBigDecimal() {
-    }
-
-    @Test
-    void getBigDecimal1() {
-    }
-
-    @Test
-    void getAllBigDecimals() {
-    }
-
-    @Test
-    void isValidString() {
-    }
-
-    @Test
-    void isValidString1() {
-    }
-
-    @Test
-    void getString() {
-    }
-
-    @Test
-    void getString1() {
-    }
-
-    @Test
-    void getAllStrings() {
-    }
-
-    @Test
-    void isValidTime() {
-    }
-
-    @Test
-    void isValidTime1() {
-    }
-
-    @Test
-    void getTime() {
-    }
-
-    @Test
-    void getTime1() {
-    }
-
-    @Test
-    void getAllTimes() {
-    }
-
-    @Test
-    void isValidDate() {
-    }
-
-    @Test
-    void isValidDate1() {
-    }
-
-    @Test
-    void getDate() {
-    }
-
-    @Test
-    void getDate1() {
-    }
-
-    @Test
-    void getAllDates() {
-    }
-
-    @Test
-    void isValidDateTime() {
-    }
-
-    @Test
-    void isValidDateTime1() {
-    }
-
-    @Test
-    void getDateTime() {
-    }
-
-    @Test
-    void getDateTime1() {
-    }
-
-    @Test
-    void getAllDateTimes() {
-    }
-
-    @Test
-    void isValidByteArray() {
-    }
-
-    @Test
-    void isValidByteArray1() {
-    }
-
-    @Test
-    void getByteArray() {
-    }
+class DefaultPlcSubscriptionEventTest {
 
-    @Test
-    void getByteArray1() {
-    }
+    private DefaultPlcSubscriptionEvent SUT;
 
-    @Test
-    void getAllByteArrays() {
+    @BeforeEach
+    void setUp() {
+        Map<String, Pair<PlcResponseCode, BaseDefaultFieldItem>> fields = new HashMap<>();
+        fields.put("foo", new ImmutablePair<>(PlcResponseCode.OK, new DefaultByteFieldItem((byte) 0x42)));
+        SUT = new DefaultPlcSubscriptionEvent(Instant.now(), fields);
     }
 
     @Test
     void getFieldNames() {
+        assertThrows(NotImplementedException.class, () -> SUT.getFieldNames());
     }
 
     @Test
     void getField() {
+        assertThrows(NotImplementedException.class, () -> SUT.getField("foo"));
     }
 
     @Test
-    void getResponseCode() {
+    void getTimestamp() {
+        Instant timestamp = SUT.getTimestamp();
+        assertThat(timestamp, notNullValue());
     }
 
-    @Test
-    void getRequest() {
-    }
 }
\ No newline at end of file
diff --git a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionResponseTest.java b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionResponseTest.java
index e4cfba0..7916bda 100644
--- a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionResponseTest.java
+++ b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcSubscriptionResponseTest.java
@@ -22,6 +22,7 @@ package org.apache.plc4x.java.base.messages;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.plc4x.java.api.exceptions.PlcNotImplementedException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
 import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
 import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
@@ -29,13 +30,14 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.hamcrest.core.IsNull.notNullValue;
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.mock;
 
@@ -51,7 +53,9 @@ class DefaultPlcSubscriptionResponseTest {
     void setUp() {
         mockRequest = mock(InternalPlcSubscriptionRequest.class);
         mockSubscriptionHandle = mock(PlcSubscriptionHandle.class);
-        mockValues = Collections.singletonMap("foo", new ImmutablePair(PlcResponseCode.OK, mockSubscriptionHandle));
+        mockValues = new HashMap<>();
+        mockValues.put("foo", new ImmutablePair(PlcResponseCode.OK, mockSubscriptionHandle));
+        mockValues.put("bar", new ImmutablePair(PlcResponseCode.NOT_FOUND, mock(PlcSubscriptionHandle.class)));
         SUT = new DefaultPlcSubscriptionResponse(mockRequest, mockValues);
     }
 
@@ -59,15 +63,20 @@ class DefaultPlcSubscriptionResponseTest {
     void getSubscriptionHandle() {
         PlcSubscriptionHandle foo = SUT.getSubscriptionHandle("foo");
         assertThat(foo, equalTo(mockSubscriptionHandle));
-        assertThat(SUT.getSubscriptionHandle("bar"), nullValue());
+        assertThrows(PlcRuntimeException.class, () -> SUT.getSubscriptionHandle("bar"));
+        assertThat(SUT.getSubscriptionHandle("hurz"), nullValue());
     }
 
     @Test
     void getFieldNames() {
         Collection<String> fieldNames = SUT.getFieldNames();
         assertThat(fieldNames, notNullValue());
-        assertThat(fieldNames.size(), equalTo(1));
-        assertThat(fieldNames.iterator().next(), equalTo("foo"));
+        assertThat(fieldNames.size(), equalTo(2));
+        for (String fieldName : fieldNames) {
+            if(!"foo".equals(fieldName) && !"bar".equals(fieldName)) {
+                fail();
+            }
+        }
     }
 
     @Test
@@ -80,6 +89,9 @@ class DefaultPlcSubscriptionResponseTest {
         PlcResponseCode responseCode = SUT.getResponseCode("foo");
         assertThat(responseCode, notNullValue());
         assertThat(responseCode, equalTo(PlcResponseCode.OK));
+
+        responseCode = SUT.getResponseCode("hurz");
+        assertThat(responseCode, nullValue());
     }
 
     @Test
@@ -92,8 +104,14 @@ class DefaultPlcSubscriptionResponseTest {
     void getSubscriptionHandles() {
         Collection<PlcSubscriptionHandle> subscriptionHandles = SUT.getSubscriptionHandles();
         assertThat(subscriptionHandles, notNullValue());
-        assertThat(subscriptionHandles.size(), equalTo(1));
-        assertThat(subscriptionHandles.iterator().next(), equalTo(mockSubscriptionHandle));
+        assertThat(subscriptionHandles.size(), equalTo(2));
+        boolean found = false;
+        for (PlcSubscriptionHandle subscriptionHandle : subscriptionHandles) {
+            if(subscriptionHandle.equals(mockSubscriptionHandle)) {
+                found = true;
+            }
+        }
+        assertThat(found, equalTo(true));
     }
 
     @Test
diff --git a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcWriteResponseTest.java b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcWriteResponseTest.java
index 85faf05..3776c9c 100644
--- a/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcWriteResponseTest.java
+++ b/plc4j/protocols/driver-bases/base/src/test/java/org/apache/plc4x/java/base/messages/DefaultPlcWriteResponseTest.java
@@ -19,32 +19,73 @@
 
 package org.apache.plc4x.java.base.messages;
 
+import org.apache.plc4x.java.api.model.PlcField;
+import org.apache.plc4x.java.api.types.PlcResponseCode;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
 class DefaultPlcWriteResponseTest {
 
+    @Mock
+    private InternalPlcWriteRequest request;
+    private DefaultPlcWriteResponse SUT;
+
     @BeforeEach
     void setUp() {
+        SUT = new DefaultPlcWriteResponse(request, Collections.singletonMap("foo", PlcResponseCode.OK));
     }
 
     @Test
     void getValues() {
+        Map<String, PlcResponseCode> values = SUT.getValues();
+        assertThat(values, notNullValue());
+        assertThat(values.size(), equalTo(1));
+        assertThat(values.keySet().iterator().next(), equalTo("foo"));
+        assertThat(values.values().iterator().next(), equalTo(PlcResponseCode.OK));
     }
 
     @Test
     void getRequest() {
+        InternalPlcWriteRequest actRequest = SUT.getRequest();
+        assertThat(actRequest, equalTo(request));
     }
 
     @Test
     void getFieldNames() {
+        when(request.getFieldNames()).thenReturn(new LinkedHashSet<>(Collections.singletonList("foo")));
+        Collection<String> fieldNames = SUT.getFieldNames();
+        assertThat(fieldNames, notNullValue());
+        assertThat(fieldNames.size(), equalTo(1));
+        assertThat(fieldNames.iterator().next(), equalTo("foo"));
     }
 
     @Test
     void getField() {
+        when(request.getField("foo")).thenReturn(mock(PlcField.class));
+        PlcField field = SUT.getField("foo");
+        assertThat(field, notNullValue());
     }
 
     @Test
     void getResponseCode() {
+        PlcResponseCode responseCode = SUT.getResponseCode("foo");
+        assertThat(responseCode, notNullValue());
+        assertThat(responseCode, equalTo(PlcResponseCode.OK));
     }
+
 }
\ No newline at end of file