Fixed minor issues found during integration testing.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Fri, 19 Feb 2016 14:36:30 +0000 (20:06 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 22 Feb 2016 00:35:53 +0000 (00:35 +0000)
Correction in validation of primitive data.

Change-Id: Iceb2df5d82354b63138fb388d68117158058d7cd
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5083
Reviewed-by: Harish Marappa <h.marappa@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/simulator/java/sdk/src/org/oic/simulator/ArrayValueValidator.java
service/simulator/java/sdk/src/org/oic/simulator/DoubleProperty.java
service/simulator/java/sdk/src/org/oic/simulator/IntegerProperty.java
service/simulator/java/sdk/src/org/oic/simulator/StringProperty.java

index fad211a..99f7d4f 100644 (file)
@@ -155,7 +155,7 @@ class ArrayValueValidator implements
 
         // Validating elements of array
         AttributeProperty elementProperty = mProperty.getElementProperty();
-        if (!elementProperty.isInteger()) {
+        if (!elementProperty.isString()) {
             return false;
         }
 
index 95f5b9c..2daff28 100644 (file)
@@ -88,8 +88,7 @@ public class DoubleProperty extends AttributeProperty {
     public boolean validate(double value) {
         if (mHasRange && (value < mMin || value > mMax)) {
             return false;
-        } else if (mValues.length > 0
-                && -1 == Arrays.binarySearch(mValues, value)) {
+        } else if (hasValues() && 0 > Arrays.binarySearch(mValues, value)) {
             return false;
         }
 
index 0220718..2448c2e 100644 (file)
@@ -87,8 +87,7 @@ public class IntegerProperty extends AttributeProperty {
     public boolean validate(int value) {
         if (mHasRange && (value < mMin || value > mMax)) {
             return false;
-        } else if (mValues.length > 0
-                && -1 == Arrays.binarySearch(mValues, value)) {
+        } else if (hasValues() && 0 > Arrays.binarySearch(mValues, value)) {
             return false;
         }
 
index 39945eb..0660d5b 100644 (file)
@@ -42,7 +42,8 @@ public class StringProperty extends AttributeProperty {
     private StringProperty(String value, String[] values) {
         super(Type.STRING);
         mDefaultValue = value;
-        mValues = values;
+        mValues = Arrays.copyOf(values, values.length);
+        Arrays.sort(mValues);
     }
 
     @Override
@@ -88,8 +89,7 @@ public class StringProperty extends AttributeProperty {
         int length = value.length();
         if (mHasRange && (length < mMin || length > mMax)) {
             return false;
-        } else if (mValues.length > 0
-                && -1 == Arrays.binarySearch(mValues, value)) {
+        } else if (hasValues() && 0 > Arrays.binarySearch(mValues, value)) {
             return false;
         }