Skip to content

Commit

Permalink
Added call that copies a chart from a workspace to another workspace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Oct 16, 2023
1 parent 49c7755 commit 2676194
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/seatsio/charts/Charts.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ public Chart copyToWorkspace(String chartKey, String toWorkspaceKey) {
return gson().fromJson(response, Chart.class);
}

public Chart copyToWorkspace(String chartKey, String fromWorkspaceKey, String toWorkspaceKey) {
String response = unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{chartKey}/version/published/actions/copy/from/{fromWorkspaceKey}/to/{toWorkspaceKey}")
.routeParam("chartKey", chartKey)
.routeParam("fromWorkspaceKey", fromWorkspaceKey)
.routeParam("toWorkspaceKey", toWorkspaceKey));
return gson().fromJson(response, Chart.class);
}

public void addTag(String key, String tag) {
unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{key}/tags/{tag}")
.routeParam("key", key)
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/seatsio/charts/CopyChartFromWorkspaceToTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seatsio.charts;

import org.junit.jupiter.api.Test;
import seatsio.SeatsioClient;
import seatsio.SeatsioClientTest;
import seatsio.workspaces.Workspace;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

public class CopyChartFromWorkspaceToTest extends SeatsioClientTest {

@Test
public void test() {
Chart chart = client.charts.create("my chart", "BOOTHS");
Workspace toWorkspace = client.workspaces.create("my ws");

Chart copiedChart = client.charts.copyToWorkspace(chart.key, workspace.key, toWorkspace.key);

SeatsioClient workspaceClient = new SeatsioClient(toWorkspace.secretKey, null, apiUrl());
assertThat(copiedChart.name).isEqualTo("my chart");
Chart retrievedChart = workspaceClient.charts.retrieve(copiedChart.key);
assertThat(retrievedChart.name).isEqualTo("my chart");
Map<?, ?> drawing = workspaceClient.charts.retrievePublishedVersion(copiedChart.key);
assertThat(drawing.get("venueType")).isEqualTo("BOOTHS");
}

}

0 comments on commit 2676194

Please sign in to comment.