ComponentServiceImpl implements ComponentService { @Override @Transactional public void publishDerivedComponents(String componentSetId, List<Component> components) { if (StringUtils.isBlank(componentSetId)) { throw new RiceIllegalArgumentException("componentSetId was a null or blank value"); } components = validateAndNormalizeComponents(componentSetId, components); LOG.info("Requesting to publish " + components.size() + " derived components for componentSetId=" + componentSetId); ComponentSetBo componentSet = getDataObjectService().find(ComponentSetBo.class,componentSetId); if (componentSet == null) { componentSet = new ComponentSetBo(); componentSet.setComponentSetId(componentSetId); } String checksum = calculateChecksum(components); if (!checksum.equals(componentSet.getChecksum())) { LOG.info("Checksums were different, proceeding with update of derived components for componentSetId=" + componentSetId); componentSet.setChecksum(checksum); componentSet.setLastUpdateTimestamp(new Timestamp(System.currentTimeMillis())); if (getComponentSetDao().saveIgnoreLockingFailure(componentSet)) { updateDerivedComponents(componentSetId, components); } } else { LOG.info("Checksums were the same, no derived component update needed for componentSetId=" + componentSetId); } }  @Override Component getComponentByCode(String namespaceCode, String componentCode); @Override List<Component> getAllComponentsByNamespaceCode(String namespaceCode); @Override List<Component> getActiveComponentsByNamespaceCode(String namespaceCode); @Override List<Component> getDerivedComponentSet(String componentSetId); @Override @Transactional void publishDerivedComponents(String componentSetId, List<Component> components); ComponentSetDao getComponentSetDao(); void setComponentSetDao(ComponentSetDao componentSetDao); DataObjectService getDataObjectService(); @Required void setDataObjectService(DataObjectService dataObjectService);  }
@Test(expected = IllegalArgumentException.class) public void test_publishDerivedComponents_null_componentSetId() throws Exception{ List<Component> components = new ArrayList<Component>(); components.add(component); getComponentService().publishDerivedComponents(null, components); }
@Test(expected = IllegalArgumentException.class) public void test_publishDerivedComponents_empty_componentSetId() throws Exception{ List<Component> components = new ArrayList<Component>(); components.add(derivedComponent); getComponentService().publishDerivedComponents("", components); }
@Test(expected = IllegalArgumentException.class) public void test_publishDerivedComponents_blank_componentSetId() throws Exception{ List<Component> components = new ArrayList<Component>(); components.add(derivedComponent); getComponentService().publishDerivedComponents(" ", components); }
@Test(expected = IllegalArgumentException.class) public void test_publishDerivedComponents_invalidComponentSetId_onComponents() throws Exception{ Component.Builder builder = Component.Builder.create(component); builder.setComponentSetId("myComponentSet"); List<Component> components = new ArrayList<Component>(); components.add(builder.build()); getComponentService().publishDerivedComponents("blah", components); }