1010import com .smartling .api .jobbatches .v2 .pto .CreateJobResponsePTO ;
1111import com .smartling .api .jobbatches .v2 .pto .RegisterBatchActionRequestPTO ;
1212import com .smartling .api .jobbatches .v2 .pto .WorkflowPTO ;
13+ import com .smartling .api .jobbatches .v2 .pto .ContentAssignmentPTO ;
1314import com .smartling .api .v2 .client .ClientConfiguration ;
1415import com .smartling .api .v2 .client .DefaultClientConfiguration ;
1516import 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