MdsRestFacadeRetriever { public MdsRestFacade getRestFacade(String entityName, String moduleName, String namespace) { String restId = ClassName.restId(entityName, moduleName, namespace); MdsRestFacade restFacade = null; try { String filter = String.format("(org.eclipse.gemini.blueprint.bean.name=%s)", restId); Collection<ServiceReference<MdsRestFacade>> refs = bundleContext.getServiceReferences( MdsRestFacade.class, filter); if (refs != null && refs.size() > 1 && LOGGER.isWarnEnabled()) { LOGGER.warn("More then one Rest Facade matching for entityName={}, module={}, namespace={}. " + "Using first one available.", entityName, moduleName, namespace); } if (refs != null && refs.size() > 0) { ServiceReference<MdsRestFacade> ref = refs.iterator().next(); restFacade = bundleContext.getService(ref); } } catch (InvalidSyntaxException e) { throw new IllegalArgumentException("Invalid Syntax for Rest Facade retrieval", e); } if (restFacade == null) { throw new RestNotSupportedException(entityName, moduleName, namespace); } return restFacade; }  MdsRestFacade getRestFacade(String entityName, String moduleName, String namespace);  }
@Test(expected = RestNotSupportedException.class) public void shouldThrowRestUnsupportedExceptionIfThereIsNoFacadeRef() { restFacadeRetriever.getRestFacade("unsupported", null, null); }