DelegateHandler implements Refreshable, LoggableResource { protected String getDelegateName(final String uri) { Matcher nameMatcher = delegateNamePattern.matcher(uri); if ( nameMatcher.matches() ) { return nameMatcher.group(NAME_GROUP_INDEX); } return null; } DelegateHandler(final Vertx vertx, final HttpClient selfClient, final ResourceStorage delegateStorage,
                           final MonitoringHandler monitoringHandler, final String delegatesUri,
                           final Map<String, Object> properties,
                           final Handler<Void> doneHandler); void init(); boolean handle(final HttpServerRequest request); @Override void refresh(); @Override void enableResourceLogging(boolean resourceLoggingEnabled);  }
@Test public void testGetDelegateName_Recognition() { String delegateName = "aName"; Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName )); Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/")); Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/execution/xxx")); Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/execution/")); Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/execution")); Assert.assertEquals(delegateName, delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/definition")); Assert.assertNull(delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/blah")); Assert.assertNull(delegateHandler.getDelegateName(DELEGATE_URI + delegateName + "/definition/")); }