PresetProviderImpl implements PresetProvider { @Override public String getProperty(String seriesID, String propertyName) throws NotFoundException { String propertyValue = ""; if (StringUtils.trimToNull(seriesID) != null) { try { propertyValue = seriesService.getSeriesProperty(seriesID, propertyName); } catch (NotFoundException e) { logger.debug("The property {} was not found in the series {} so we will try to find it in the organization.", propertyName, seriesID); } catch (Exception e) { logger.warn( "Unable to get the property {} from the series {} so we will try to find it in the organization. The exception was ", propertyName, seriesID, e); } } if (StringUtils.isBlank(propertyValue)) { propertyValue = securityService.getOrganization().getProperties().get(propertyName); if (StringUtils.isBlank(propertyValue)) { throw new NotFoundException("Unable to find the property in either the series or organization"); } } return propertyValue; }  void setSeriesService(SeriesService seriesService); void setSecurityService(SecurityService securityService); @Override String getProperty(String seriesID, String propertyName);  }
@Test public void propertyInSeries() throws NotFoundException { assertEquals(SERIES_PROPERTY_VALUE, presetProviderImpl.getProperty(SERIES_ID, SERIES_PROPERTY_NAME)); }
@Test public void propertyInOrganization() throws NotFoundException { assertEquals(ORG_PROPERTY_VALUE, presetProviderImpl.getProperty(SERIES_ID, ORG_PROPERTY_NAME)); }
@Test public void propertyInOrganizationNullSeries() throws NotFoundException { assertEquals(ORG_PROPERTY_VALUE, presetProviderImpl.getProperty(null, ORG_PROPERTY_NAME)); }
@Test public void propertyInOrganizationEmptySeries() throws NotFoundException { assertEquals(ORG_PROPERTY_VALUE, presetProviderImpl.getProperty("", ORG_PROPERTY_NAME)); }
@Test public void propertyIsNotSet() { try { assertEquals(SERIES_PROPERTY_VALUE, presetProviderImpl.getProperty(SERIES_ID, NOT_FOUND_NAME)); fail(); } catch (NotFoundException e) { } }