String Decode(expression, value1, mapping_string1, ..., valueN, mapping_stringN, other_string)
if (expression==value1) return mapping_string1; ...... else if (expression==valueN) return mapping_stringN; else return other_string;
161162163164165166167168169170171172173174175176177178179
t4.set(2, "Sales"); t4.set(3, 1); t4.set(4, "Engineering"); t4.set(5, "Other"); Decode func = new Decode(); String r = func.exec(t1); assertTrue(r.equals("Engineering")); r = func.exec(t2); assertTrue(r.equals("Other")); r = func.exec(t3); assertTrue(r==null); try { r = func.exec(t4); fail("Exception not triggered"); } catch (IOException e) { assertTrue(e.getMessage().equals("Decode : Encounter null in the input")); } }