/** Test of applyFizzBuzz method, of class FizzBuzzWs. */ @Test public void testApplyFizzBuzz() { System.out.println("applyFizzBuzz"); HashMap<Integer, String> fizzBuzz = new HashMap<>(); // FizzBuzz value / result fizzBuzz.put(1, "1"); // Multiple not handled fizzBuzz.put(3, "Fizz"); // Multiple of 3 fizzBuzz.put(5, "Buzz"); // Multiple of 5 fizzBuzz.put(7, "Quxx"); // Multiple of 7 fizzBuzz.put(11, "Vitt"); // Multiple of 11 fizzBuzz.put(15, "FizzBuzz"); // Multiple of 3 & 5 fizzBuzz.put(21, "FizzQuxx"); // Multiple of 3 & 7 fizzBuzz.put(33, "FizzVitt"); // Multiple of 3 & 11 fizzBuzz.put(35, "BuzzQuxx"); // Multiple of 5 & 7 fizzBuzz.put(55, "BuzzVitt"); // Multiple of 5 & 11 fizzBuzz.put(77, "QuxxVitt"); // Multiple of 7 & 11 fizzBuzz.put(105, "FizzBuzzQuxx"); // Multiple of 3 & 5 & 7 fizzBuzz.put(165, "FizzBuzzVitt"); // Multiple of 3 & 5 & 11 fizzBuzz.put(1155, "FizzBuzzQuxxVitt"); // Multiple of 3 & 5 & 7 & 11 FizzBuzzWs instance = new FizzBuzzWs(); for (HashMap.Entry<Integer, String> entry : fizzBuzz.entrySet()) { assertEquals(entry.getValue(), instance.applyFizzBuzz(entry.getKey())); } }
/** Test of buildJson method, of class FizzBuzzWs. */ @Test public void testBuildJson_String() { System.out.println("buildJson"); String value = "5"; FizzBuzzWs instance = new FizzBuzzWs(); String expResult = "{ \"result\": \"5\" }"; String result = instance.buildJson(value); assertEquals(expResult, result); }
/** Test of buildJson method, of class FizzBuzzWs. */ @Test public void testBuildJson_ArrayList() { System.out.println("buildJson"); ArrayList<String> values = new ArrayList<>(); FizzBuzzWs instance = new FizzBuzzWs(); for (int i = 1; i < 6; ++i) { values.add(Integer.toString(i)); } String expResult = "{\n\t\"results\": [ \"1\", \"2\", \"3\", \"4\", \"5\" ]\n}"; String result = instance.buildJson(values); assertEquals(expResult, result); }