ParameterRepositoryServiceImpl implements ParameterRepositoryService { @Override public Parameter getParameter(ParameterKey key) { return ParameterBo.to(getParameterBo(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(expected = IllegalArgumentException.class) public void test_get_parameter_null_key() throws Exception{ getParameterRepositoryService().getParameter(null); }
@Test public void test_get_parameter_exists() throws Exception{ when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(bo); Parameter param = getParameterRepositoryService().getParameter(key); assertEquals("Parameters are equal",param,parameter); verify(dataObjectService, times(1)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }
@Test public void test_get_parameter_does_not_exist() throws Exception{ when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(null); assertNull("Returned null parameter",getParameterRepositoryService().getParameter(key)); verify(dataObjectService, times(2)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }