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
12 changes: 12 additions & 0 deletions src/main/java/com/bynder/sdk/query/upload/SaveMediaQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public class SaveMediaQuery {
@ApiField
private String tags;


/**
* Flags if media asset should be set to public
*/
@ApiField
private Boolean isPublic;

/**
* Dictionary with (metaproperty) options to set on the asset upon upload.
*/
Expand Down Expand Up @@ -95,6 +102,11 @@ public SaveMediaQuery setMetaproperties(List<MetapropertyAttribute> metaproperti
return this;
}

public SaveMediaQuery setIsPublic(final boolean isPublic) {
this.isPublic = isPublic;
return this;
}

public SaveMediaQuery addMetaproperty(final MetapropertyAttribute metaproperty) {
this.metaproperties.add(metaproperty);
return this;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/bynder/sdk/query/upload/UploadQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public class UploadQuery {

private String fileName;

/**
* Flags if the media asset should be public or not.
*/
private Boolean isPublic;

public UploadQuery(final String filepath, final String brandId) {
this.filepath = filepath;
this.brandId = brandId;
Expand All @@ -80,6 +85,10 @@ public String getAssetName() {
return (assetName == null) ? getFilename() : assetName;
}

public Boolean getIsPublic() {
return isPublic;
}

public UploadQuery setMediaId(final String mediaId) {
this.mediaId = mediaId;
return this;
Expand All @@ -104,6 +113,11 @@ public UploadQuery setFileName(final String fileName) {
return this;
}

public UploadQuery setIsPublic(final Boolean isPublic) {
this.isPublic = isPublic;
return this;
}

public String getTags() {
return tags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private Completable pollProcessing(final String importId) {
private Single<SaveMediaResponse> saveUploadedMedia(final String importId, final UploadQuery uploadQuery) {
SaveMediaQuery saveMediaQuery = new SaveMediaQuery(importId)
.setAudit(uploadQuery.isAudit())
.setIsPublic(uploadQuery.getIsPublic())
.setMetaproperties(uploadQuery.getMetaproperties());

if (uploadQuery.getMediaId() == null) {
Expand Down
18 changes: 15 additions & 3 deletions src/test/java/com/bynder/sdk/query/upload/UploadQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotEquals;

/**
* Tests the {@link UploadQuery} class methods.
Expand Down Expand Up @@ -37,16 +37,18 @@ public void initializeUploadQuery() {
uploadQuery.setMediaId(EXPECTED_MEDIA_ID);
uploadQuery.setAudit(EXPECTED_AUDIT);
uploadQuery.setTags(Arrays.asList("tag1", "tag2"));
uploadQuery.setIsPublic(true);
uploadQuery.addMetaproperty(EXPECTED_METAPROPERTY_ID, EXPECTED_OPTION_NAME);

assertTrue(EXPECTED_METAPROPERTY.equals(uploadQuery.getMetaproperties().get(0)));
assertEquals(EXPECTED_METAPROPERTY, uploadQuery.getMetaproperties().get(0));
assertEquals(EXPECTED_FILE_PATH, uploadQuery.getFilepath());
assertEquals(EXPECTED_BRAND_ID, uploadQuery.getBrandId());
assertEquals(EXPECTED_MEDIA_ID, uploadQuery.getMediaId());
assertEquals(EXPECTED_AUDIT, uploadQuery.isAudit());
assertEquals(EXPECTED_TAGS, uploadQuery.getTags());
assertEquals(EXPECTED_FILE_NAME, uploadQuery.getFilename());
assertEquals(EXPECTED_FILE_NAME, uploadQuery.getAssetName());
assertEquals(true, uploadQuery.getIsPublic());
}

@Test
Expand Down Expand Up @@ -83,7 +85,7 @@ public void testCustomAssetAndFileName() {
assertEquals(EXPECTED_ASSET_NAME, uploadQuery.getAssetName());
}

@Test
@Test
public void testAddMetaproperty_multioption() {
String[] EXPECTED_METAPROPERTY_OPTIONS = new String[]{"EXPECTED_OPTION_1", "EXPECTED_OPTION_2"};
UploadQuery uploadQuery = new UploadQuery(EXPECTED_FILE_PATH, EXPECTED_BRAND_ID);
Expand All @@ -95,4 +97,14 @@ public void testAddMetaproperty_multioption() {
assertEquals(EXPECTED_METAPROPERTY_OPTIONS.length, actualOptions.length);
assertEquals(EXPECTED_METAPROPERTY_OPTIONS[0], actualOptions[0]);
}

@Test
public void testIsPublicDefaultValue() {
// default value not true
UploadQuery uploadQuery = new UploadQuery(EXPECTED_FILE_PATH, EXPECTED_BRAND_ID);
assertNotEquals(true, uploadQuery.getIsPublic());
// test true value
uploadQuery.setIsPublic(true);
assertEquals(true, uploadQuery.getIsPublic());
}
}
Loading