VOL-2073 Unit Test cases for utils.go

Change-Id: I94ecbb8ea15b05477a5cb57e81c506b28b7fd636
diff --git a/pkg/adapters/common/utils_test.go b/pkg/adapters/common/utils_test.go
new file mode 100644
index 0000000..a8d7a3f
--- /dev/null
+++ b/pkg/adapters/common/utils_test.go
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2018-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 common
+
+import (
+	"github.com/stretchr/testify/assert"
+	"strconv"
+	sp "strings"
+	"testing"
+)
+
+const sim = "0123456789abcdefABCDEF"
+const rstr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+func TestGetSerialNumber(t *testing.T) {
+
+	serial := GetRandomSerialNumber()
+	assert.NotNil(t, serial)
+
+	sparsed := sp.Split(serial, ".")
+	sparsed2 := sparsed[3]
+
+	for i := 0; i <= 2; i++ {
+		ioct, _ := strconv.ParseInt(sparsed[i], 10, 0)
+
+		assert.True(t, ioct <= 255 && ioct >= 0, "Octect %d IP octect wrong!", i)
+	}
+
+	sp3 := sp.Split(sparsed2, ":")
+	oct4, _ := strconv.ParseInt(sp3[0], 10, 0)
+
+	assert.True(t, oct4 <= 255 && oct4 >= 0, "Fourth IP octect wrong!")
+
+	port, _ := strconv.ParseInt(sp3[1], 10, 0)
+	assert.True(t, port <= 65535 && port >= 0)
+}
+func TestGetString(t *testing.T) {
+	str := GetRandomString(20)
+	strslide := sp.Split(str, "")
+	for i := 0; i < len(strslide); i++ {
+		assert.True(t, sp.Contains(rstr, strslide[i]), "Error! The string doesn't appears correct --> %s Expected in --> %s", str, rstr)
+	}
+	assert.NotNil(t, str)
+}
+func TestGetMacAddress(t *testing.T) {
+	mac := GetRandomMacAddress()
+	assert.NotNil(t, mac, "Mac address null")
+	smac := sp.Split(mac, ":")
+	assert.True(t, len(smac) == 6, "mac address not correctly formatted")
+
+	for i := 0; i < len(smac); i++ {
+		oct := sp.Split(smac[i], "")
+		assert.True(t, sp.Contains(sim, oct[0]))
+		assert.True(t, sp.Contains(sim, oct[1]))
+	}
+
+}