ParameterRepositoryServiceImpl implements ParameterRepositoryService { @Override public Boolean getParameterValueAsBoolean(ParameterKey key) { final ParameterBo p = getParameterBo(key); final String value = p != null ? p.getValue() : null; return Truth.strToBooleanIgnoreCase(value); }  @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_value_as_boolean_null() throws Exception{ when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(null); assertNull(getParameterRepositoryService().getParameterValueAsBoolean(key)); verify(dataObjectService, times(2)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }
@Test public void test_get_parameter_value_as_boolean_not_null_not_boolean() throws Exception{ bo.setValue("not boolean"); when(dataObjectService.find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class))).thenReturn(bo); assertNull(getParameterRepositoryService().getParameterValueAsBoolean(key)); verify(dataObjectService, times(1)).find(Matchers.argThat(new ClassOrSubclassMatcher<ParameterBo>( ParameterBo.class)), any(QueryByCriteria.class)); }