ParameterRepositoryServiceImpl implements ParameterRepositoryService { @Override public Collection<String> getParameterValuesAsString(ParameterKey key) { return splitOn(getParameterValueAsString(key), ";"); }  @Override @Transactional Parameter createParameter(Parameter parameter); @Override @Transactional Parameter updateParameter(Parameter parameter); @Override Parameter getParameter(ParameterKey key); @Override String getParameterValueAsString(ParameterKey key); @Override Boolean getParameterValueAsBoolean(ParameterKey key); @Override Collection<String> getParameterValuesAsString(ParameterKey key); @Override String getSubParameterValueAsString(ParameterKey key, String subParameterName); @Override Collection<String> getSubParameterValuesAsString(ParameterKey key, String subParameterName); @Override ParameterQueryResults findParameters(QueryByCriteria queryByCriteria); DataObjectService getDataObjectService(); @Required void setDataObjectService(DataObjectService dataObjectService);  }
@Test public void test_get_parameter_values_as_string_null() throws Exception{ when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(null); Collection<String> parameterList = getParameterRepositoryService().getParameterValuesAsString(key); assertTrue(parameterList.isEmpty()); assertImmutableList(parameterList); verify(dataObjectService, times(2)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }
@Test public void test_get_parameter_values_as_string_not_null_multiple_values() throws Exception{ bo.setValue("foo; bar ; baz "); when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(bo); Collection<String> paramValueList = getParameterRepositoryService().getParameterValuesAsString(key); assertTrue(paramValueList != null && paramValueList.size() == 3 && paramValueList.contains("foo") && paramValueList.contains("bar") && paramValueList.contains("baz")); assertImmutableList(paramValueList); verify(dataObjectService, times(1)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }
@Test public void test_get_parameter_values_as_string_not_null_single_values() throws Exception{ bo.setValue("a value "); when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(bo); Collection<String> paramValueList = getParameterRepositoryService().getParameterValuesAsString(key); assertTrue(paramValueList != null && paramValueList.size() == 1 && paramValueList.contains("a value")); assertImmutableList(paramValueList); verify(dataObjectService, times(1)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }