Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.smartling.api.jobbatches.v2.pto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ContentAssignmentPTO
{
private String workflowStepUid;
private List<String> userUids;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -13,4 +15,5 @@ public class WorkflowPTO
{
private String targetLocaleId;
private String workflowUid;
private List<ContentAssignmentPTO> contentAssignments;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.smartling.api.jobbatches.v2.pto.CreateJobResponsePTO;
import com.smartling.api.jobbatches.v2.pto.RegisterBatchActionRequestPTO;
import com.smartling.api.jobbatches.v2.pto.WorkflowPTO;
import com.smartling.api.jobbatches.v2.pto.ContentAssignmentPTO;
import com.smartling.api.v2.client.ClientConfiguration;
import com.smartling.api.v2.client.DefaultClientConfiguration;
import com.smartling.api.v2.client.auth.BearerAuthStaticTokenFilter;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void testCreateBatch() throws Exception
+ "\"translationJobUid\":\"jobUid\","
+ "\"authorize\":true,"
+ "\"fileUris\":[\"fileUri.json\"],"
+ "\"localeWorkflows\":[{\"targetLocaleId\":\"fr-FR\",\"workflowUid\":\"workflowUid\"}]"
+ "\"localeWorkflows\":[{\"targetLocaleId\":\"fr-FR\",\"workflowUid\":\"workflowUid\",\"contentAssignments\":null}]"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if [{\"targetLocaleId\":\"fr-FR\",\"workflowUid\":\"workflowUid\"}] is passed (without \"contentAssignments\":null)? It must be possible to pass without it for backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"contentAssignments" field is not required and nullable.

So I think it will be ok to use it without contentAssignments as now.

Tests were added in another PR to cover this case: https://github.com/Smartling/jobs-facade/pull/135

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with pavel, I'd remain this test data as is, and add another with contentAssignements field.

Copy link
Contributor Author

@alubenskyi alubenskyi Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests were added in another PR for job-facade service to cover this case: https://github.com/Smartling/jobs-facade/pull/135

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Here I setuped input pto without contentAssignments array, as is on prod for now.
requestString contains contentAssignments = null because request.getBody().readUtf8() prints all fields from pto's with default values if such field explicitly is not defined.

+ "}";

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

@Test
public void testCreateBatchWithWorkflowStepAssignments() throws Exception
{
assignResponse(HttpStatus.SC_OK, String.format(SUCCESS_RESPONSE_ENVELOPE, "{\"batchUid\" : \"createdBatchUid\"}"));

String workflowStepUid = "workflowStepUid1";
String userUid = "userUid1";
String strategy = "strategy";
// language=JSON
String requestString = "{"
+ "\"translationJobUid\":\"jobUid\","
+ "\"authorize\":true,"
+ "\"fileUris\":[\"fileUri.json\"],"
+ "\"localeWorkflows\":["
+ "{"
+ "\"targetLocaleId\":\"fr-FR\","
+ "\"workflowUid\":\"workflowUid\","
+ "\"contentAssignments\":["
+ "{"
+ "\"workflowStepUid\":\"workflowStepUid1\","
+ "\"userUids\":[\"userUid1\"]"
+ "}"
+ "]"
+ "}"
+ "]"
+ "}";

CreateBatchRequestPTO requestBody = CreateBatchRequestPTO.builder()
.translationJobUid("jobUid")
.authorize(true)
.fileUris(Collections.singletonList("fileUri.json"))
.localeWorkflows(Collections.singletonList(WorkflowPTO.builder()
.targetLocaleId("fr-FR")
.workflowUid("workflowUid")
.contentAssignments(
Collections.singletonList(
ContentAssignmentPTO.builder()
.workflowStepUid(workflowStepUid)
.userUids(Collections.singletonList(userUid))
.build()
)
)
.build()
))
.build();

CreateBatchResponsePTO response = jobBatchesApi.createBatch(PROJECT_ID, requestBody);

assertEquals("createdBatchUid", response.getBatchUid());

RecordedRequest request = mockWebServer.takeRequest();
assertEquals(POST, request.getMethod());
assertEquals(requestString, request.getBody().readUtf8());
assertTrue(request.getPath().startsWith(("/job-batches-api/v2/projects/" + PROJECT_ID + "/batches")));
}

@Test
public void testGetBatch() throws Exception
{
Expand Down
Loading