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
Expand Up @@ -11,6 +11,7 @@ public class AttachmentPTO implements ResponseData
private String description;
private Date createdDate;
private String createdByUserUid;
private String localeId;

public String getAttachmentUid()
{
Expand Down Expand Up @@ -61,4 +62,14 @@ public void setCreatedByUserUid(String createdByUserUid)
{
this.createdByUserUid = createdByUserUid;
}

public String getLocaleId()
{
return localeId;
}

public void setLocaleId(String localeId)
{
this.localeId = localeId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ public enum AttachmentType
{
JOBS(1),
ISSUES(2),
STRINGS(3);
STRINGS(3),
GLOSSARIES(4),
TRANSLATION_CERTIFICATE_BUNDLE(5),
LOCALE_TRANSLATION_CERTIFICATE(6);

private int value;

Expand All @@ -30,4 +33,9 @@ public static AttachmentType valueOf(Integer value)
}
return null;
}

public String toUrlSegment()
{
return name().toLowerCase().replace("_", "-");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public class AttachmentUploadPTO
@FormParam("description")
@PartType("text/plain")
private String description;

@FormParam("localeId")
@PartType("text/plain")
private String localeId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,52 @@ public void testUploadAttachment() throws Exception
assertEquals(expectedPTO.getCreatedByUserUid(), response.getCreatedByUserUid());
}

@Test
public void testUploadAttachmentWithLocaleId() throws Exception
{
// given
AttachmentPTO expectedPTO = createAttachmentPTO();
expectedPTO.setLocaleId("en-US");
assignResponse(HttpStatus.SC_OK, MediaType.APPLICATION_JSON, jsonResponse(expectedPTO));

AttachmentUploadPTO attachment = new AttachmentUploadPTO();
attachment.setFile(new ByteArrayInputStream("content".getBytes()));
attachment.setName("certificate.pdf");
attachment.setEntityUids(asList("jobUuid1"));
attachment.setLocaleId("en-US");

// when
AttachmentPTO response = attachmentsApi.uploadAttachment(ACCOUNT_UID, ATTACHMENT_TYPE, attachment);

// then
RecordedRequest request = getRequestWithValidation(HttpMethod.POST, ATTACHMENTS, ACCOUNT_UID, ATTACHMENT_TYPE);
String requestBody = request.getBody().readUtf8();

assertTrue(requestBody.contains(
"Content-Disposition: form-data; name=\"localeId\"\r\n" +
"Content-Type: text/plain\r\n" +
"\r\n" +
"en-US\r\n"));

assertEquals(expectedPTO.getLocaleId(), response.getLocaleId());
}

@Test
public void testAttachmentTypeNewValues()
{
assertEquals(4, AttachmentType.GLOSSARIES.getValue());
assertEquals(5, AttachmentType.TRANSLATION_CERTIFICATE_BUNDLE.getValue());
assertEquals(6, AttachmentType.LOCALE_TRANSLATION_CERTIFICATE.getValue());

assertEquals(AttachmentType.GLOSSARIES, AttachmentType.valueOf(4));
assertEquals(AttachmentType.TRANSLATION_CERTIFICATE_BUNDLE, AttachmentType.valueOf(5));
assertEquals(AttachmentType.LOCALE_TRANSLATION_CERTIFICATE, AttachmentType.valueOf(6));

assertEquals("glossaries", AttachmentType.GLOSSARIES.toUrlSegment());
assertEquals("translation-certificate-bundle", AttachmentType.TRANSLATION_CERTIFICATE_BUNDLE.toUrlSegment());
assertEquals("locale-translation-certificate", AttachmentType.LOCALE_TRANSLATION_CERTIFICATE.toUrlSegment());
}

@Test
public void testDownloadAttachment() throws IOException, InterruptedException {
// given
Expand Down