Skip to content

Commit e1b9172

Browse files
authored
feat: con 592 update job batches v2 endpoint (#109)
feat: con 592 update job batches v2 endpoint
1 parent ee57376 commit e1b9172

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.smartling.api.jobbatches.v2.pto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.util.List;
9+
10+
@Data
11+
@NoArgsConstructor
12+
@AllArgsConstructor
13+
@Builder
14+
public class ContentAssignmentPTO
15+
{
16+
private String workflowStepUid;
17+
private List<String> userUids;
18+
}

smartling-job-batches-api/src/main/java/com/smartling/api/jobbatches/v2/pto/WorkflowPTO.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import lombok.Data;
66
import lombok.NoArgsConstructor;
77

8+
import java.util.List;
9+
810
@Data
911
@NoArgsConstructor
1012
@AllArgsConstructor
@@ -13,4 +15,5 @@ public class WorkflowPTO
1315
{
1416
private String targetLocaleId;
1517
private String workflowUid;
18+
private List<ContentAssignmentPTO> contentAssignments;
1619
}

smartling-job-batches-api/src/test/java/com/smartling/api/jobbatches/v2/JobBatchesApiTest.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.smartling.api.jobbatches.v2.pto.CreateJobResponsePTO;
1111
import com.smartling.api.jobbatches.v2.pto.RegisterBatchActionRequestPTO;
1212
import com.smartling.api.jobbatches.v2.pto.WorkflowPTO;
13+
import com.smartling.api.jobbatches.v2.pto.ContentAssignmentPTO;
1314
import com.smartling.api.v2.client.ClientConfiguration;
1415
import com.smartling.api.v2.client.DefaultClientConfiguration;
1516
import com.smartling.api.v2.client.auth.BearerAuthStaticTokenFilter;
@@ -81,7 +82,7 @@ public void testCreateBatch() throws Exception
8182
+ "\"translationJobUid\":\"jobUid\","
8283
+ "\"authorize\":true,"
8384
+ "\"fileUris\":[\"fileUri.json\"],"
84-
+ "\"localeWorkflows\":[{\"targetLocaleId\":\"fr-FR\",\"workflowUid\":\"workflowUid\"}]"
85+
+ "\"localeWorkflows\":[{\"targetLocaleId\":\"fr-FR\",\"workflowUid\":\"workflowUid\",\"contentAssignments\":null}]"
8586
+ "}";
8687

8788
CreateBatchRequestPTO requestBody = CreateBatchRequestPTO.builder()
@@ -105,6 +106,62 @@ public void testCreateBatch() throws Exception
105106
assertTrue(request.getPath().startsWith(("/job-batches-api/v2/projects/" + PROJECT_ID + "/batches")));
106107
}
107108

109+
@Test
110+
public void testCreateBatchWithWorkflowStepAssignments() throws Exception
111+
{
112+
assignResponse(HttpStatus.SC_OK, String.format(SUCCESS_RESPONSE_ENVELOPE, "{\"batchUid\" : \"createdBatchUid\"}"));
113+
114+
String workflowStepUid = "workflowStepUid1";
115+
String userUid = "userUid1";
116+
String strategy = "strategy";
117+
// language=JSON
118+
String requestString = "{"
119+
+ "\"translationJobUid\":\"jobUid\","
120+
+ "\"authorize\":true,"
121+
+ "\"fileUris\":[\"fileUri.json\"],"
122+
+ "\"localeWorkflows\":["
123+
+ "{"
124+
+ "\"targetLocaleId\":\"fr-FR\","
125+
+ "\"workflowUid\":\"workflowUid\","
126+
+ "\"contentAssignments\":["
127+
+ "{"
128+
+ "\"workflowStepUid\":\"workflowStepUid1\","
129+
+ "\"userUids\":[\"userUid1\"]"
130+
+ "}"
131+
+ "]"
132+
+ "}"
133+
+ "]"
134+
+ "}";
135+
136+
CreateBatchRequestPTO requestBody = CreateBatchRequestPTO.builder()
137+
.translationJobUid("jobUid")
138+
.authorize(true)
139+
.fileUris(Collections.singletonList("fileUri.json"))
140+
.localeWorkflows(Collections.singletonList(WorkflowPTO.builder()
141+
.targetLocaleId("fr-FR")
142+
.workflowUid("workflowUid")
143+
.contentAssignments(
144+
Collections.singletonList(
145+
ContentAssignmentPTO.builder()
146+
.workflowStepUid(workflowStepUid)
147+
.userUids(Collections.singletonList(userUid))
148+
.build()
149+
)
150+
)
151+
.build()
152+
))
153+
.build();
154+
155+
CreateBatchResponsePTO response = jobBatchesApi.createBatch(PROJECT_ID, requestBody);
156+
157+
assertEquals("createdBatchUid", response.getBatchUid());
158+
159+
RecordedRequest request = mockWebServer.takeRequest();
160+
assertEquals(POST, request.getMethod());
161+
assertEquals(requestString, request.getBody().readUtf8());
162+
assertTrue(request.getPath().startsWith(("/job-batches-api/v2/projects/" + PROJECT_ID + "/batches")));
163+
}
164+
108165
@Test
109166
public void testGetBatch() throws Exception
110167
{

0 commit comments

Comments
 (0)