ServiceResourceService { public ServiceResource[] getByNodeTypes(String nodeType, String nodeTypeVersion) { return alienDAO.buildQuery(ServiceResource.class) .setFilters(fromKeyValueCouples("nodeInstance.nodeTemplate.type", nodeType, "nodeInstance.typeVersion", nodeTypeVersion)).prepareSearch() .search(0, Integer.MAX_VALUE).getData(); }  String create(String serviceName, String serviceVersion, String serviceNodeType, String serviceNodeVersion); String create(String serviceName, String serviceVersion, String serviceNodeType, String serviceNodeVersion, String environmentId); GetMultipleDataResult<ServiceResource> list(int from, int count); FacetedSearchResult<ServiceResource> search(String searchText, Map<String, String[]> filters, String sortField, boolean desc, int from,
            int count); ServiceResource getOrFail(String id); void update(String resourceId, String name, String version, String description, String nodeType, String nodeTypeVersion,
            Map<String, AbstractPropertyValue> nodeProperties, Map<String, Capability> nodeCapabilities, Map<String, String> nodeAttributeValues,
            String[] locations, Map<String, String> capabilitiesRelationshipTypes, Map<String, String> requirementsRelationshipTypes); String duplicate(String serviceId); void patch(String resourceId, String name, String version, String description, String nodeType, String nodeTypeVersion,
            Map<String, AbstractPropertyValue> nodeProperties, Map<String, Capability> nodeCapabilities, Map<String, String> nodeAttributeValues,
            String[] locations, Map<String, String> capabilitiesRelationshipTypes, Map<String, String> requirementsRelationshipTypes); synchronized void save(ServiceResource serviceResource, boolean ensureUniqueness); synchronized void save(ServiceResource serviceResource); synchronized void delete(String id); @EventListener synchronized void handleLocationDeleted(AfterLocationDeleted event); List<ServiceResource> searchByLocation(String locationId); ServiceResource[] getByNodeTypes(String nodeType, String nodeTypeVersion); void isLocationAuthorized(String serviceId, String locationId); @EventListener void reportArchiveUsage(ArchiveUsageRequestEvent event);  }
@Test public void testGetByNodeTypes() { ServiceResource serviceResource = new ServiceResource(); serviceResource.setId("service1"); serviceResource.setNodeInstance(new NodeInstance()); serviceResource.getNodeInstance().setTypeVersion("1.0.0-SNAPSHOT"); serviceResource.getNodeInstance().setNodeTemplate(new NodeTemplate()); serviceResource.getNodeInstance().getNodeTemplate().setType("org.alien4cloud.nodes.MyType"); alienDao.save(serviceResource); ServiceResource[] services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.MyType", "1.0.0-SNAPSHOT"); Assert.assertNotNull(services); Assert.assertEquals(1, services.length); services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.UnusedType", "1.0.0-SNAPSHOT"); Assert.assertNotNull(services); Assert.assertEquals(0, services.length); services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.MyType", "1.0.0"); Assert.assertNotNull(services); Assert.assertEquals(0, services.length); }