<NME> FieldMetaTypeTest.java
<BEF> ADDFILE
<MSG> Added a new Test class and test to test the FieldMetaType decoding

<DFF> @@ -0,0 +1,73 @@
+package org.numenta.nupic;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.joda.time.DateTime;
+import org.junit.Test;
+import org.numenta.nupic.encoders.DateEncoder;
+import org.numenta.nupic.util.Tuple;
+
+
+public class FieldMetaTypeTest {
+
+    /**
+     * Test decoding of 9 out of 10 types of {@link FieldMetaType}s.
+     */
+    @Test
+    public void testDecodeType() {
+        List<String> linput = new ArrayList<>();
+        linput.add("test");
+        String loutput = FieldMetaType.LIST.decodeType(linput.toString(), null);
+        assertEquals(linput.toString(), loutput);
+        
+        String catinput = "TestString";
+        String output = FieldMetaType.STRING.decodeType(catinput, null);
+        assertEquals(catinput, output);
+        
+        String binput = "true";
+        Double boutput = FieldMetaType.BOOLEAN.decodeType(binput, null);
+        assertEquals(new Double(1), boutput);
+        
+        String ginput = "100;200;5";
+        Tuple texpected = new Tuple(100.0, 200.0, 5.0);
+        Tuple tupleOut = FieldMetaType.GEO.decodeType(ginput, null);
+        assertEquals(texpected, tupleOut);
+        
+        String intinput = "1337";
+        double intoutput = FieldMetaType.INTEGER.decodeType(intinput, null);
+        assertEquals(1337.0d, intoutput, 0);
+        
+        intoutput = FieldMetaType.FLOAT.decodeType(intinput, null);
+        assertEquals(1337.0d, intoutput, 0);
+        
+        // DARR = Dense Array
+        int[] dainput = { 1, 0, 1, 0 };
+        int[] daoutput = FieldMetaType.DARR.decodeType(Arrays.toString(dainput), null);
+        assertTrue(Arrays.equals(dainput, daoutput));
+        
+        // SARR = Sparse Array
+        int[] sainput = { 0, 2 };
+        int[] saoutput = FieldMetaType.SARR.decodeType(Arrays.toString(sainput), null);
+        assertTrue(Arrays.equals(sainput, saoutput));
+        
+        DateTime comparison = new DateTime(2010, 11, 4, 13, 55, 01);
+        String compareString = "2010-11-04 13:55:01";
+        // 3 bits for season, 1 bit for day of week, 3 for weekend, 5 for time of day
+        // use of forced is not recommended, used here for readability.
+        DateEncoder.Builder builder = DateEncoder.builder();
+        builder.formatPattern("yyyy-MM-dd HH:mm:ss");
+
+        DateEncoder de = builder.season(3)
+            .dayOfWeek(1)
+            .weekend(3)
+            .timeOfDay(5).build();
+        
+        DateTime dateOutput = FieldMetaType.DATETIME.decodeType(compareString, de);
+        assertEquals(comparison, dateOutput);
+    }
+}

{'commit': 'diff --git a/src/test/java/org/numenta/nupic/FieldMetaTypeTest.java b/src/test/java/org/numenta/nupic/FieldMetaTypeTest.java\nnew file mode 100644\nindex 00000000..03df2a22\n--- /dev/null\n+++ b/src/test/java/org/numenta/nupic/FieldMetaTypeTest.java\n@@ -0,0 +1,73 @@\n+package org.numenta.nupic;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertTrue;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import org.joda.time.DateTime;\n+import org.junit.Test;\n+import org.numenta.nupic.encoders.DateEncoder;\n+import org.numenta.nupic.util.Tuple;\n+\n+\n+public class FieldMetaTypeTest {\n+\n+    /**\n+     * Test decoding of 9 out of 10 types of {@link FieldMetaType}s.\n+     */\n+    @Test\n+    public void testDecodeType() {\n+        List<String> linput = new ArrayList<>();\n+        linput.add("test");\n+        String loutput = FieldMetaType.LIST.decodeType(linput.toString(), null);\n+        assertEquals(linput.toString(), loutput);\n+        \n+        String catinput = "TestString";\n+        String output = FieldMetaType.STRING.decodeType(catinput, null);\n+        assertEquals(catinput, output);\n+        \n+        String binput = "true";\n+        Double boutput = FieldMetaType.BOOLEAN.decodeType(binput, null);\n+        assertEquals(new Double(1), boutput);\n+        \n+        String ginput = "100;200;5";\n+        Tuple texpected = new Tuple(100.0, 200.0, 5.0);\n+        Tuple tupleOut = FieldMetaType.GEO.decodeType(ginput, null);\n+        assertEquals(texpected, tupleOut);\n+        \n+        String intinput = "1337";\n+        double intoutput = FieldMetaType.INTEGER.decodeType(intinput, null);\n+        assertEquals(1337.0d, intoutput, 0);\n+        \n+        intoutput = FieldMetaType.FLOAT.decodeType(intinput, null);\n+        assertEquals(1337.0d, intoutput, 0);\n+        \n+        // DARR = Dense Array\n+        int[] dainput = { 1, 0, 1, 0 };\n+        int[] daoutput = FieldMetaType.DARR.decodeType(Arrays.toString(dainput), null);\n+        assertTrue(Arrays.equals(dainput, daoutput));\n+        \n+        // SARR = Sparse Array\n+        int[] sainput = { 0, 2 };\n+        int[] saoutput = FieldMetaType.SARR.decodeType(Arrays.toString(sainput), null);\n+        assertTrue(Arrays.equals(sainput, saoutput));\n+        \n+        DateTime comparison = new DateTime(2010, 11, 4, 13, 55, 01);\n+        String compareString = "2010-11-04 13:55:01";\n+        // 3 bits for season, 1 bit for day of week, 3 for weekend, 5 for time of day\n+        // use of forced is not recommended, used here for readability.\n+        DateEncoder.Builder builder = DateEncoder.builder();\n+        builder.formatPattern("yyyy-MM-dd HH:mm:ss");\n+\n+        DateEncoder de = builder.season(3)\n+            .dayOfWeek(1)\n+            .weekend(3)\n+            .timeOfDay(5).build();\n+        \n+        DateTime dateOutput = FieldMetaType.DATETIME.decodeType(compareString, de);\n+        assertEquals(comparison, dateOutput);\n+    }\n+}\n', 'commit_subject': 'Added a new Test class and test to test the FieldMetaType decoding', 'repo_name': 'numenta/htm.java', 'committer': {'name': 'cogmission', 'email': 'bae4fa7efebf6ce8b672362102a603df3894ac10@gmail.com', 'time_sec': '1494597138', 'tz_offset': '-300', 'date': {'seconds': '1494597138'}}, 'commit_tree': '011d7f07b8754a678f62861a761a4150a402bb76', 'commit_message': 'Added a new Test class and test to test the FieldMetaType decoding\n', 'language_name': 'Python', 'license': 'agpl-3.0', 'hunks': '@@ -0,0 +1,73 @@\n+package org.numenta.nupic;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertTrue;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import org.joda.time.DateTime;\n+import org.junit.Test;\n+import org.numenta.nupic.encoders.DateEncoder;\n+import org.numenta.nupic.util.Tuple;\n+\n+\n+public class FieldMetaTypeTest {\n+\n+    /**\n+     * Test decoding of 9 out of 10 types of {@link FieldMetaType}s.\n+     */\n+    @Test\n+    public void testDecodeType() {\n+        List<String> linput = new ArrayList<>();\n+        linput.add("test");\n+        String loutput = FieldMetaType.LIST.decodeType(linput.toString(), null);\n+        assertEquals(linput.toString(), loutput);\n+        \n+        String catinput = "TestString";\n+        String output = FieldMetaType.STRING.decodeType(catinput, null);\n+        assertEquals(catinput, output);\n+        \n+        String binput = "true";\n+        Double boutput = FieldMetaType.BOOLEAN.decodeType(binput, null);\n+        assertEquals(new Double(1), boutput);\n+        \n+        String ginput = "100;200;5";\n+        Tuple texpected = new Tuple(100.0, 200.0, 5.0);\n+        Tuple tupleOut = FieldMetaType.GEO.decodeType(ginput, null);\n+        assertEquals(texpected, tupleOut);\n+        \n+        String intinput = "1337";\n+        double intoutput = FieldMetaType.INTEGER.decodeType(intinput, null);\n+        assertEquals(1337.0d, intoutput, 0);\n+        \n+        intoutput = FieldMetaType.FLOAT.decodeType(intinput, null);\n+        assertEquals(1337.0d, intoutput, 0);\n+        \n+        // DARR = Dense Array\n+        int[] dainput = { 1, 0, 1, 0 };\n+        int[] daoutput = FieldMetaType.DARR.decodeType(Arrays.toString(dainput), null);\n+        assertTrue(Arrays.equals(dainput, daoutput));\n+        \n+        // SARR = Sparse Array\n+        int[] sainput = { 0, 2 };\n+        int[] saoutput = FieldMetaType.SARR.decodeType(Arrays.toString(sainput), null);\n+        assertTrue(Arrays.equals(sainput, saoutput));\n+        \n+        DateTime comparison = new DateTime(2010, 11, 4, 13, 55, 01);\n+        String compareString = "2010-11-04 13:55:01";\n+        // 3 bits for season, 1 bit for day of week, 3 for weekend, 5 for time of day\n+        // use of forced is not recommended, used here for readability.\n+        DateEncoder.Builder builder = DateEncoder.builder();\n+        builder.formatPattern("yyyy-MM-dd HH:mm:ss");\n+\n+        DateEncoder de = builder.season(3)\n+            .dayOfWeek(1)\n+            .weekend(3)\n+            .timeOfDay(5).build();\n+        \n+        DateTime dateOutput = FieldMetaType.DATETIME.decodeType(compareString, de);\n+        assertEquals(comparison, dateOutput);\n+    }\n+}\n', 'addition_count': 73, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/src/test/java/org/numenta/nupic/FieldMetaTypeTest.java', 'file_extension': '.java', 'before_file': 'ADDFILE', 'message': 'Added a new Test class and test to test the FieldMetaType decoding\n', 'author_name': 'cogmission', 'lang': 'java'}