@Test public void gitAppImportTests() throws Exception { HttpPost postRequest; CloseableHttpResponse response; postRequest = new HttpPost("http: postRequest.setEntity(new StringEntity("{}")); postRequest.setHeader("Content-Type", MediaType.GIT_APP_JSON.toString()); response = httpClient.execute(postRequest); assertThat(response).isNotNull(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(406); response.close(); postRequest = new HttpPost("http: postRequest.setEntity(new StringEntity("{ \"url\": \"\" }")); postRequest.setHeader("Content-Type", MediaType.GIT_APP_JSON.toString()); response = httpClient.execute(postRequest); assertThat(response).isNotNull(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(406); response.close(); postRequest = new HttpPost("http: postRequest.setEntity(new StringEntity("{ \"url\": \"http: postRequest.setHeader("Content-Type", MediaType.GIT_APP_JSON.toString()); response = httpClient.execute(postRequest); assertThat(response).isNotNull(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(406); response.close(); CompletableFuture<StompMessage> appCreationNotification = new CompletableFuture<>(); StompClient stompClient = new StompClient(); CountDownLatch subscriptionLatch = new CountDownLatch(1); stompClient.connect("localhost", 8080, (client) -> { stompClient.subscribe("/admin/applications/*", (subscription) -> { subscription.onMessage((msg) -> { System.err.println( "******* MESSAGE: "+ msg ); if (msg.headers().get("location").equals("/admin/applications/liveoak-example-chat-html")) { appCreationNotification.complete(msg); } }); subscription.onReceipt(() -> { subscriptionLatch.countDown(); }); }); }); subscriptionLatch.await(); postRequest = new HttpPost("http: postRequest.setEntity(new StringEntity("{ \"url\": \"https: postRequest.setHeader("Content-Type", MediaType.GIT_APP_JSON.toString()); response = httpClient.execute(postRequest); awaitStability(); assertThat(response).isNotNull(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(201); ResourceState state = decode(response); assertThat(state).isNotNull(); assertThat(state).isInstanceOf(ResourceState.class); assertThat(state.id()).isNotNull(); assertThat(state.id()).isEqualTo("liveoak-example-chat-html"); assertThat(state.getProperty(LiveOak.NAME)).isEqualTo("liveoak-example-chat-html"); assertThat(state.getProperty("visible")).isEqualTo(true); StompMessage obj = appCreationNotification.get(30, TimeUnit.SECONDS); assertThat(obj).isNotNull(); ResourceState appObjState = decode(obj.content()); assertThat(appObjState.getProperty(LiveOak.NAME)).isEqualTo("liveoak-example-chat-html"); assertThat(state.getProperty(LiveOak.ID)).isEqualTo(appObjState.getProperty(LiveOak.ID)); response.close(); File myApp = new File(appsDir, "liveoak-example-chat-html"); assertThat(new File(myApp, ".git").exists()).isTrue(); postRequest = new HttpPost("http: postRequest.setEntity(new StringEntity("{ \"id\": \"chat-html\", \"url\": \"https: postRequest.setHeader("Content-Type", MediaType.GIT_APP_JSON.toString()); response = httpClient.execute(postRequest); awaitStability(); assertThat(response).isNotNull(); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(201); state = decode(response); assertThat(state).isNotNull(); assertThat(state).isInstanceOf(ResourceState.class); assertThat(state.id()).isNotNull(); assertThat(state.id()).isEqualTo("chat-html"); assertThat(state.getProperty(LiveOak.NAME)).isEqualTo("chat-html"); assertThat(state.getProperty("visible")).isEqualTo(true); myApp = new File(appsDir, "chat-html"); assertThat(new File(myApp, ".git").exists()).isTrue(); }
@Override public String id() { return "applications"; }
GitApplicationsResource implements RootResource, SynchronousResource { @Override public String id() { return "applications"; } }
GitApplicationsResource implements RootResource, SynchronousResource { @Override public String id() { return "applications"; } GitApplicationsResource(InternalApplicationRegistry registry, File appsDir); }
GitApplicationsResource implements RootResource, SynchronousResource { @Override public String id() { return "applications"; } GitApplicationsResource(InternalApplicationRegistry registry, File appsDir); @Override void parent(Resource parent); @Override Resource parent(); @Override String id(); @Override void createMember(RequestContext ctx, ResourceState state, Responder responder); @Override void readMember(RequestContext ctx, String id, Responder responder); @Override void updateProperties(RequestContext ctx, ResourceState state, Responder responder); @Override void delete(RequestContext ctx, Responder responder); }
GitApplicationsResource implements RootResource, SynchronousResource { @Override public String id() { return "applications"; } GitApplicationsResource(InternalApplicationRegistry registry, File appsDir); @Override void parent(Resource parent); @Override Resource parent(); @Override String id(); @Override void createMember(RequestContext ctx, ResourceState state, Responder responder); @Override void readMember(RequestContext ctx, String id, Responder responder); @Override void updateProperties(RequestContext ctx, ResourceState state, Responder responder); @Override void delete(RequestContext ctx, Responder responder);  }