Add kubevirt node related codec with unit tests

Change-Id: I0c68d4c3d0c7626a4b6b66e5c783631cb9be50a8
diff --git a/apps/kubevirt-node/app/src/test/java/org/onosproject/kubevirtnode/codec/KubevirtNodeJsonArrayMatcher.java b/apps/kubevirt-node/app/src/test/java/org/onosproject/kubevirtnode/codec/KubevirtNodeJsonArrayMatcher.java
new file mode 100644
index 0000000..1e51616
--- /dev/null
+++ b/apps/kubevirt-node/app/src/test/java/org/onosproject/kubevirtnode/codec/KubevirtNodeJsonArrayMatcher.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.kubevirtnode.codec;
+
+import com.eclipsesource.json.JsonArray;
+import com.eclipsesource.json.JsonObject;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+import org.onosproject.kubevirtnode.api.KubevirtNode;
+
+/**
+ * Hamcrest matcher for kubevirt node array.
+ */
+public class KubevirtNodeJsonArrayMatcher extends TypeSafeMatcher<JsonArray> {
+
+    private final KubevirtNode node;
+    private String reason = "";
+
+    public KubevirtNodeJsonArrayMatcher(KubevirtNode node) {
+        this.node = node;
+    }
+
+    @Override
+    protected boolean matchesSafely(JsonArray json) {
+        boolean nodeFound = false;
+        for (int jsonNodeIndex = 0; jsonNodeIndex < json.size(); jsonNodeIndex++) {
+            final JsonObject jsonNode = json.get(jsonNodeIndex).asObject();
+
+            final String hostname = node.hostname();
+            final String jsonHostname = jsonNode.get("hostname").asString();
+            if (jsonHostname.equals(hostname)) {
+                nodeFound = true;
+            }
+        }
+
+        if (!nodeFound) {
+            reason = "Node with hostname " + node.hostname() + " not found";
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(reason);
+    }
+
+    /**
+     * Factory to allocate a node array matcher.
+     *
+     * @param node node object we are looking for
+     * @return matcher
+     */
+    public static KubevirtNodeJsonArrayMatcher hasNode(KubevirtNode node) {
+        return new KubevirtNodeJsonArrayMatcher(node);
+    }
+}