@Test public void should_return_null_given_zerotData_when_use_getFormatResult() { List<String> itemList = new ArrayList<>(); format = new FormatFactory().statrFormat(":", itemList); HashMap<String, Double> result = format.getFormatResult(); assertThat(result.size(), is(0)); }
@Test public void should_return_hashMap_given_correctData_when_use_getFormatResult() { format = new FormatFactory().statrFormat("-", ShopData.cart); HashMap<String, Double> result = format.getFormatResult(); assertThat(result.size(), is(3)); assertThat(result.get("ITEM000001"), is(3.0)); assertThat(result.get("ITEM000003"), is(2.0)); assertThat(result.get("ITEM000005"), is(2.0)); }
@Test public void should_return_exception_given_wrongSymblo_when_use_getFormatResult() { List<String> itemList = new ArrayList<>(); itemList.add("ITEM000001:40"); format = new FormatFactory().statrFormat(":", itemList); try { String result = format.getFormatResult().toString(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("bad format item")); } }