Skip to content

Commit

Permalink
Implement Issue #107 - add properties "options" and "id" to class Met… (
Browse files Browse the repository at this point in the history
#109)

* Implement Issue #107 - add properties "options" and "id" to class MetapropertiesQuery to support getting all metaproperties without options and retrieving individual metaproperties (with options if needed)

* replace property "id" with "ids" in MetapropertyQuery to ensure a dictionary (Map) is returned, and so not break the retrofix introspection. Add basic unit tests for MetapropertyQuery.

---------

Co-authored-by: Colin Manning <[email protected]>
  • Loading branch information
colinmanning and Colin Manning authored Sep 27, 2023
1 parent bf9abb6 commit e78f26a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/com/bynder/sdk/query/MetapropertyQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ public class MetapropertyQuery {
*/
@ApiField
private MediaType type;
/**
* Make it possible to get metaproperties without options, to avoid possible timeout if the number
* of metapropertiy/options is very large (e.g. with Stockholm National Museum taxonomies)
* @author Colin Manning - zetcom
*/
@ApiField
private Boolean options;
/**
* A collection id of a Metaproperty, to get the information for specific metaproperties
* Most common use case will be to fetch a single metaproperty,
* but we need to use "ids" and not "id" to get a Map back or else the API breaks
* @author Colin Manning - zetcom
*/
@ApiField
private String ids;

public Boolean getCount() {
return count;
Expand All @@ -44,4 +59,21 @@ public MetapropertyQuery setType(final MediaType type) {
this.type = type;
return this;
}

public Boolean getOptions() {
return options;
}

public MetapropertyQuery setOptions(final Boolean options) {
this.options = options;
return this;
}
public String getIds() {
return ids;
}

public MetapropertyQuery setIds(final String ids) {
this.ids = ids;
return this;
}
}
51 changes: 51 additions & 0 deletions src/test/java/com/bynder/sdk/query/MetapropertyQueryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.bynder.sdk.query;

import com.bynder.sdk.model.MediaType;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/**
* Tests the {@link MetapropertyQuery} class methods.
*/
public class MetapropertyQueryTest {

public static final MediaType EXPECTED_MEDIA_TYPE = MediaType.IMAGE;
public static final int EXPECTED_INTEGER = 1;
public static final Boolean EXPECTED_BOOLEAN = Boolean.TRUE;

public static final String EXPECTED_ID_LIST = "1,2,3,4,5";

private MetapropertyQuery metapropertyQuery;

@Before
public void setUp() {
this.metapropertyQuery = new MetapropertyQuery();
}

@Test
public void initializeEmptyMetapropertyQuery() {
assertNull(metapropertyQuery.getType());
assertNull(metapropertyQuery.getCount());
assertNull(metapropertyQuery.getOptions());
assertNull(metapropertyQuery.getIds());
}

@Test
public void setValuesForMediaQuery() {
metapropertyQuery.setType(EXPECTED_MEDIA_TYPE);
assertEquals(EXPECTED_MEDIA_TYPE, metapropertyQuery.getType());

metapropertyQuery.setCount(EXPECTED_BOOLEAN);
assertEquals(EXPECTED_BOOLEAN, metapropertyQuery.getCount());

metapropertyQuery.setOptions(EXPECTED_BOOLEAN);
assertEquals(EXPECTED_BOOLEAN, metapropertyQuery.getOptions());

metapropertyQuery.setIds(EXPECTED_ID_LIST);
assertEquals(EXPECTED_ID_LIST, metapropertyQuery.getIds());

}
}

0 comments on commit e78f26a

Please sign in to comment.