@Test public void test_getAllComponentsByNamespaceCode_not_exists() throws Exception{ when(dataObjectService.findMatching(Matchers.argThat( new ClassOrSubclassMatcher<ComponentBo>(ComponentBo.class)), any(QueryByCriteria.class))).thenReturn(null); when(dataObjectService.findMatching(Matchers.argThat( new ClassOrSubclassMatcher<DerivedComponentBo>(DerivedComponentBo.class)), any(QueryByCriteria.class))).thenReturn(null); List<Component> components = getComponentService().getAllComponentsByNamespaceCode("blah"); assertTrue("getAllComponentsByNamespaceCode not retrieved", components != null && components.isEmpty()); verify(dataObjectService,times(1)).findMatching(Matchers.argThat( new ClassOrSubclassMatcher<ComponentBo>(ComponentBo.class)), any(QueryByCriteria.class)); verify(dataObjectService,times(1)).findMatching(Matchers.argThat( new ClassOrSubclassMatcher<DerivedComponentBo>(DerivedComponentBo.class)), any(QueryByCriteria.class)); }
@Override public List<Component> getAllComponentsByNamespaceCode(String namespaceCode) { if (StringUtils.isBlank(namespaceCode)) { throw new RiceIllegalArgumentException("namespaceCode was a null or blank value"); } Map<String, String> criteria = new HashMap<String, String>(); criteria.put("namespaceCode", namespaceCode); QueryResults<ComponentBo> componentBos = getDataObjectService().findMatching(ComponentBo.class, QueryByCriteria.Builder.andAttributes(criteria).build()); QueryResults<DerivedComponentBo> derivedComponentBos = getDataObjectService().findMatching(DerivedComponentBo.class, QueryByCriteria.Builder.andAttributes( criteria).build()); return translateCollections(componentBos, derivedComponentBos); }
ComponentServiceImpl implements ComponentService { @Override public List<Component> getAllComponentsByNamespaceCode(String namespaceCode) { if (StringUtils.isBlank(namespaceCode)) { throw new RiceIllegalArgumentException("namespaceCode was a null or blank value"); } Map<String, String> criteria = new HashMap<String, String>(); criteria.put("namespaceCode", namespaceCode); QueryResults<ComponentBo> componentBos = getDataObjectService().findMatching(ComponentBo.class, QueryByCriteria.Builder.andAttributes(criteria).build()); QueryResults<DerivedComponentBo> derivedComponentBos = getDataObjectService().findMatching(DerivedComponentBo.class, QueryByCriteria.Builder.andAttributes( criteria).build()); return translateCollections(componentBos, derivedComponentBos); } }
ComponentServiceImpl implements ComponentService { @Override public List<Component> getAllComponentsByNamespaceCode(String namespaceCode) { if (StringUtils.isBlank(namespaceCode)) { throw new RiceIllegalArgumentException("namespaceCode was a null or blank value"); } Map<String, String> criteria = new HashMap<String, String>(); criteria.put("namespaceCode", namespaceCode); QueryResults<ComponentBo> componentBos = getDataObjectService().findMatching(ComponentBo.class, QueryByCriteria.Builder.andAttributes(criteria).build()); QueryResults<DerivedComponentBo> derivedComponentBos = getDataObjectService().findMatching(DerivedComponentBo.class, QueryByCriteria.Builder.andAttributes( criteria).build()); return translateCollections(componentBos, derivedComponentBos); }  }
ComponentServiceImpl implements ComponentService { @Override public List<Component> getAllComponentsByNamespaceCode(String namespaceCode) { if (StringUtils.isBlank(namespaceCode)) { throw new RiceIllegalArgumentException("namespaceCode was a null or blank value"); } Map<String, String> criteria = new HashMap<String, String>(); criteria.put("namespaceCode", namespaceCode); QueryResults<ComponentBo> componentBos = getDataObjectService().findMatching(ComponentBo.class, QueryByCriteria.Builder.andAttributes(criteria).build()); QueryResults<DerivedComponentBo> derivedComponentBos = getDataObjectService().findMatching(DerivedComponentBo.class, QueryByCriteria.Builder.andAttributes( criteria).build()); return translateCollections(componentBos, derivedComponentBos); }  @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); }
ComponentServiceImpl implements ComponentService { @Override public List<Component> getAllComponentsByNamespaceCode(String namespaceCode) { if (StringUtils.isBlank(namespaceCode)) { throw new RiceIllegalArgumentException("namespaceCode was a null or blank value"); } Map<String, String> criteria = new HashMap<String, String>(); criteria.put("namespaceCode", namespaceCode); QueryResults<ComponentBo> componentBos = getDataObjectService().findMatching(ComponentBo.class, QueryByCriteria.Builder.andAttributes(criteria).build()); QueryResults<DerivedComponentBo> derivedComponentBos = getDataObjectService().findMatching(DerivedComponentBo.class, QueryByCriteria.Builder.andAttributes( criteria).build()); return translateCollections(componentBos, derivedComponentBos); }  @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);  }