@Test public void testForkSnapshot() throws Exception { String networkName = "network"; String snapshotName = "snapshot"; String baseSnapshotName = "baseSnapshot"; ForkSnapshotBean forkSnapshotBean = new ForkSnapshotBean( baseSnapshotName, snapshotName, null, null, ImmutableList.of("node1"), null, null, null, null); try (Response response = getForkSnapshotTarget(networkName).post(Entity.json(forkSnapshotBean))) { assertThat(response.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } Main.getWorkMgr().initNetwork(networkName, null); try (Response response = getForkSnapshotTarget(networkName).post(Entity.json(forkSnapshotBean))) { assertThat(response.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } uploadTestSnapshot(networkName, baseSnapshotName, _folder); try (Response response = getForkSnapshotTarget(networkName).post(Entity.json(forkSnapshotBean))) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); } try (Response response = getForkSnapshotTarget(networkName).post(Entity.json(forkSnapshotBean))) { assertThat(response.getStatus(), equalTo(BAD_REQUEST.getStatusCode())); } }
@POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response forkSnapshot(ForkSnapshotBean forkSnapshotBean) { try { checkArgument( !isNullOrEmpty(forkSnapshotBean.newSnapshot), "Parameter %s is required", "new snapshot"); checkArgument( !isNullOrEmpty(forkSnapshotBean.baseSnapshot), "Parameter %s is required", "base snapshot"); if (GlobalTracer.get().activeSpan() != null) { GlobalTracer.get() .activeSpan() .setTag("network-name", _name) .setTag("snapshot-name", forkSnapshotBean.newSnapshot); } Main.getWorkMgr().forkSnapshot(_name, forkSnapshotBean); return Response.ok().build(); } catch (FileNotFoundException e) { return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); } catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } }
NetworkResource { @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response forkSnapshot(ForkSnapshotBean forkSnapshotBean) { try { checkArgument( !isNullOrEmpty(forkSnapshotBean.newSnapshot), "Parameter %s is required", "new snapshot"); checkArgument( !isNullOrEmpty(forkSnapshotBean.baseSnapshot), "Parameter %s is required", "base snapshot"); if (GlobalTracer.get().activeSpan() != null) { GlobalTracer.get() .activeSpan() .setTag("network-name", _name) .setTag("snapshot-name", forkSnapshotBean.newSnapshot); } Main.getWorkMgr().forkSnapshot(_name, forkSnapshotBean); return Response.ok().build(); } catch (FileNotFoundException e) { return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); } catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } } }
NetworkResource { @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response forkSnapshot(ForkSnapshotBean forkSnapshotBean) { try { checkArgument( !isNullOrEmpty(forkSnapshotBean.newSnapshot), "Parameter %s is required", "new snapshot"); checkArgument( !isNullOrEmpty(forkSnapshotBean.baseSnapshot), "Parameter %s is required", "base snapshot"); if (GlobalTracer.get().activeSpan() != null) { GlobalTracer.get() .activeSpan() .setTag("network-name", _name) .setTag("snapshot-name", forkSnapshotBean.newSnapshot); } Main.getWorkMgr().forkSnapshot(_name, forkSnapshotBean); return Response.ok().build(); } catch (FileNotFoundException e) { return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); } catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } } NetworkResource(String apiKey, String name); }
NetworkResource { @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response forkSnapshot(ForkSnapshotBean forkSnapshotBean) { try { checkArgument( !isNullOrEmpty(forkSnapshotBean.newSnapshot), "Parameter %s is required", "new snapshot"); checkArgument( !isNullOrEmpty(forkSnapshotBean.baseSnapshot), "Parameter %s is required", "base snapshot"); if (GlobalTracer.get().activeSpan() != null) { GlobalTracer.get() .activeSpan() .setTag("network-name", _name) .setTag("snapshot-name", forkSnapshotBean.newSnapshot); } Main.getWorkMgr().forkSnapshot(_name, forkSnapshotBean); return Response.ok().build(); } catch (FileNotFoundException e) { return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); } catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } } NetworkResource(String apiKey, String name); @Path(RSC_ANALYSES) AnalysesResource getAnalysesResource(); @GET Response getContainer(); @Path(RSC_OBJECTS) NetworkObjectsResource getNetworkObjectsResource(); @Path(RSC_NODE_ROLES) NetworkNodeRolesResource getNodeRolesResource(); @Path(RSC_QUESTIONS) QuestionsResource getAdHocQuestionsResource(); @Path(RSC_REFERENCE_LIBRARY) ReferenceLibraryResource getReferenceLibraryResource(); @DELETE Response deleteNetwork(); @Path(RSC_SNAPSHOTS) SnapshotsResource getSnapshotsResource(); @Path(RSC_WORK) WorkResource getWorkResource(); @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response forkSnapshot(ForkSnapshotBean forkSnapshotBean); }
NetworkResource { @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response forkSnapshot(ForkSnapshotBean forkSnapshotBean) { try { checkArgument( !isNullOrEmpty(forkSnapshotBean.newSnapshot), "Parameter %s is required", "new snapshot"); checkArgument( !isNullOrEmpty(forkSnapshotBean.baseSnapshot), "Parameter %s is required", "base snapshot"); if (GlobalTracer.get().activeSpan() != null) { GlobalTracer.get() .activeSpan() .setTag("network-name", _name) .setTag("snapshot-name", forkSnapshotBean.newSnapshot); } Main.getWorkMgr().forkSnapshot(_name, forkSnapshotBean); return Response.ok().build(); } catch (FileNotFoundException e) { return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); } catch (IllegalArgumentException e) { return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } } NetworkResource(String apiKey, String name); @Path(RSC_ANALYSES) AnalysesResource getAnalysesResource(); @GET Response getContainer(); @Path(RSC_OBJECTS) NetworkObjectsResource getNetworkObjectsResource(); @Path(RSC_NODE_ROLES) NetworkNodeRolesResource getNodeRolesResource(); @Path(RSC_QUESTIONS) QuestionsResource getAdHocQuestionsResource(); @Path(RSC_REFERENCE_LIBRARY) ReferenceLibraryResource getReferenceLibraryResource(); @DELETE Response deleteNetwork(); @Path(RSC_SNAPSHOTS) SnapshotsResource getSnapshotsResource(); @Path(RSC_WORK) WorkResource getWorkResource(); @POST @Path(RSC_SNAPSHOTS + ":" + RSC_FORK) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response forkSnapshot(ForkSnapshotBean forkSnapshotBean);  }