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
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "de55410", "specHash": "1e0848d", "version": "5.2.0" }
{ "engineHash": "c370934", "specHash": "1e0848d", "version": "5.2.0" }
65 changes: 52 additions & 13 deletions docs/sdkgen/metadatataxonomies.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ This operation is performed by calling function `createMetadataTaxonomy`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-metadata-taxonomies/).

*Currently we don't have an example for calling `createMetadataTaxonomy` in integration tests*
<!-- sample post_metadata_taxonomies -->
```
client.getMetadataTaxonomies().createMetadataTaxonomy(new CreateMetadataTaxonomyRequestBody.Builder(displayName, namespace).key(taxonomyKey).build())
```

### Arguments

Expand All @@ -53,7 +56,10 @@ This operation is performed by calling function `getMetadataTaxonomies`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id/).

*Currently we don't have an example for calling `getMetadataTaxonomies` in integration tests*
<!-- sample get_metadata_taxonomies_id -->
```
client.getMetadataTaxonomies().getMetadataTaxonomies(namespace)
```

### Arguments

Expand Down Expand Up @@ -82,7 +88,10 @@ This operation is performed by calling function `getMetadataTaxonomyByKey`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id/).

*Currently we don't have an example for calling `getMetadataTaxonomyByKey` in integration tests*
<!-- sample get_metadata_taxonomies_id_id -->
```
client.getMetadataTaxonomies().getMetadataTaxonomyByKey(namespace, taxonomyKey)
```

### Arguments

Expand Down Expand Up @@ -110,7 +119,10 @@ This operation is performed by calling function `updateMetadataTaxonomy`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/patch-metadata-taxonomies-id-id/).

*Currently we don't have an example for calling `updateMetadataTaxonomy` in integration tests*
<!-- sample patch_metadata_taxonomies_id_id -->
```
client.getMetadataTaxonomies().updateMetadataTaxonomy(namespace, taxonomyKey, new UpdateMetadataTaxonomyRequestBody(updatedDisplayName))
```

### Arguments

Expand Down Expand Up @@ -141,7 +153,10 @@ This operation is performed by calling function `deleteMetadataTaxonomy`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/delete-metadata-taxonomies-id-id/).

*Currently we don't have an example for calling `deleteMetadataTaxonomy` in integration tests*
<!-- sample delete_metadata_taxonomies_id_id -->
```
client.getMetadataTaxonomies().deleteMetadataTaxonomy(namespace, taxonomyKey)
```

### Arguments

Expand Down Expand Up @@ -169,7 +184,10 @@ This operation is performed by calling function `createMetadataTaxonomyLevel`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels/).

*Currently we don't have an example for calling `createMetadataTaxonomyLevel` in integration tests*
<!-- sample post_metadata_taxonomies_id_id_levels -->
```
client.getMetadataTaxonomies().createMetadataTaxonomyLevel(namespace, taxonomyKey, Arrays.asList(new MetadataTaxonomyLevel.Builder().displayName("Continent").description("Continent Level").build(), new MetadataTaxonomyLevel.Builder().displayName("Country").description("Country Level").build()))
```

### Arguments

Expand Down Expand Up @@ -232,7 +250,10 @@ This operation is performed by calling function `addMetadataTaxonomyLevel`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels:append/).

*Currently we don't have an example for calling `addMetadataTaxonomyLevel` in integration tests*
<!-- sample post_metadata_taxonomies_id_id_levels:append -->
```
client.getMetadataTaxonomies().addMetadataTaxonomyLevel(namespace, taxonomyKey, new AddMetadataTaxonomyLevelRequestBody.Builder("Region").description("Region Description").build())
```

### Arguments

Expand Down Expand Up @@ -262,7 +283,10 @@ This operation is performed by calling function `deleteMetadataTaxonomyLevel`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-levels:trim/).

*Currently we don't have an example for calling `deleteMetadataTaxonomyLevel` in integration tests*
<!-- sample post_metadata_taxonomies_id_id_levels:trim -->
```
client.getMetadataTaxonomies().deleteMetadataTaxonomyLevel(namespace, taxonomyKey)
```

### Arguments

Expand Down Expand Up @@ -292,7 +316,10 @@ This operation is performed by calling function `getMetadataTaxonomyNodes`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id-nodes/).

*Currently we don't have an example for calling `getMetadataTaxonomyNodes` in integration tests*
<!-- sample get_metadata_taxonomies_id_id_nodes -->
```
client.getMetadataTaxonomies().getMetadataTaxonomyNodes(namespace, taxonomyKey)
```

### Arguments

Expand Down Expand Up @@ -322,7 +349,10 @@ This operation is performed by calling function `createMetadataTaxonomyNode`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-metadata-taxonomies-id-id-nodes/).

*Currently we don't have an example for calling `createMetadataTaxonomyNode` in integration tests*
<!-- sample post_metadata_taxonomies_id_id_nodes -->
```
client.getMetadataTaxonomies().createMetadataTaxonomyNode(namespace, taxonomyKey, new CreateMetadataTaxonomyNodeRequestBody("Europe", 1))
```

### Arguments

Expand Down Expand Up @@ -352,7 +382,10 @@ This operation is performed by calling function `getMetadataTaxonomyNodeById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-metadata-taxonomies-id-id-nodes-id/).

*Currently we don't have an example for calling `getMetadataTaxonomyNodeById` in integration tests*
<!-- sample get_metadata_taxonomies_id_id_nodes_id -->
```
client.getMetadataTaxonomies().getMetadataTaxonomyNodeById(namespace, taxonomyKey, countryNode.getId())
```

### Arguments

Expand Down Expand Up @@ -382,7 +415,10 @@ This operation is performed by calling function `updateMetadataTaxonomyNode`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/patch-metadata-taxonomies-id-id-nodes-id/).

*Currently we don't have an example for calling `updateMetadataTaxonomyNode` in integration tests*
<!-- sample patch_metadata_taxonomies_id_id_nodes_id -->
```
client.getMetadataTaxonomies().updateMetadataTaxonomyNode(namespace, taxonomyKey, countryNode.getId(), new UpdateMetadataTaxonomyNodeRequestBody.Builder().displayName("Poland UPDATED").build())
```

### Arguments

Expand Down Expand Up @@ -416,7 +452,10 @@ This operation is performed by calling function `deleteMetadataTaxonomyNode`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/delete-metadata-taxonomies-id-id-nodes-id/).

*Currently we don't have an example for calling `deleteMetadataTaxonomyNode` in integration tests*
<!-- sample delete_metadata_taxonomies_id_id_nodes_id -->
```
client.getMetadataTaxonomies().deleteMetadataTaxonomyNode(namespace, taxonomyKey, countryNode.getId())
```

### Arguments

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package com.box.sdkgen.metadatataxonomies;

import static com.box.sdkgen.commons.CommonsManager.getDefaultClient;
import static com.box.sdkgen.internal.utils.UtilsManager.delayInSeconds;
import static com.box.sdkgen.internal.utils.UtilsManager.getEnvVar;
import static com.box.sdkgen.internal.utils.UtilsManager.getUuid;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.box.sdkgen.client.BoxClient;
import com.box.sdkgen.managers.metadatataxonomies.AddMetadataTaxonomyLevelRequestBody;
import com.box.sdkgen.managers.metadatataxonomies.CreateMetadataTaxonomyNodeRequestBody;
import com.box.sdkgen.managers.metadatataxonomies.CreateMetadataTaxonomyRequestBody;
import com.box.sdkgen.managers.metadatataxonomies.UpdateMetadataTaxonomyNodeRequestBody;
import com.box.sdkgen.managers.metadatataxonomies.UpdateMetadataTaxonomyRequestBody;
import com.box.sdkgen.schemas.metadatataxonomies.MetadataTaxonomies;
import com.box.sdkgen.schemas.metadatataxonomy.MetadataTaxonomy;
import com.box.sdkgen.schemas.metadatataxonomylevel.MetadataTaxonomyLevel;
import com.box.sdkgen.schemas.metadatataxonomylevels.MetadataTaxonomyLevels;
import com.box.sdkgen.schemas.metadatataxonomynode.MetadataTaxonomyNode;
import com.box.sdkgen.schemas.metadatataxonomynodes.MetadataTaxonomyNodes;
import java.util.Arrays;
import org.junit.jupiter.api.Test;

public class MetadataTaxonomiesITest {

private static final BoxClient client = getDefaultClient();

@Test
public void testMetadataTaxonomiesCrud() {
String namespace = String.join("", "enterprise_", getEnvVar("ENTERPRISE_ID"));
String uuid = getUuid();
String taxonomyKey = String.join("", "geography", uuid);
String displayName = String.join("", "Geography Taxonomy", uuid);
MetadataTaxonomy createdTaxonomy =
client
.getMetadataTaxonomies()
.createMetadataTaxonomy(
new CreateMetadataTaxonomyRequestBody.Builder(displayName, namespace)
.key(taxonomyKey)
.build());
assert createdTaxonomy.getDisplayName().equals(displayName);
assert createdTaxonomy.getNamespace().equals(namespace);
MetadataTaxonomies taxonomies = client.getMetadataTaxonomies().getMetadataTaxonomies(namespace);
assert taxonomies.getEntries().size() > 0;
assert taxonomies.getEntries().get(0).getNamespace().equals(namespace);
String updatedDisplayName = String.join("", "Geography Taxonomy UPDATED", uuid);
MetadataTaxonomy updatedTaxonomy =
client
.getMetadataTaxonomies()
.updateMetadataTaxonomy(
namespace, taxonomyKey, new UpdateMetadataTaxonomyRequestBody(updatedDisplayName));
assert updatedTaxonomy.getDisplayName().equals(updatedDisplayName);
assert updatedTaxonomy.getNamespace().equals(namespace);
assert updatedTaxonomy.getId().equals(createdTaxonomy.getId());
MetadataTaxonomy getTaxonomy =
client.getMetadataTaxonomies().getMetadataTaxonomyByKey(namespace, taxonomyKey);
assert getTaxonomy.getDisplayName().equals(updatedDisplayName);
assert getTaxonomy.getNamespace().equals(namespace);
assert getTaxonomy.getId().equals(createdTaxonomy.getId());
client.getMetadataTaxonomies().deleteMetadataTaxonomy(namespace, taxonomyKey);
assertThrows(
RuntimeException.class,
() -> client.getMetadataTaxonomies().getMetadataTaxonomyByKey(namespace, taxonomyKey));
}

@Test
public void testMetadataTaxonomiesNodes() {
String namespace = String.join("", "enterprise_", getEnvVar("ENTERPRISE_ID"));
String uuid = getUuid();
String taxonomyKey = String.join("", "geography", uuid);
String displayName = String.join("", "Geography Taxonomy", uuid);
MetadataTaxonomy createdTaxonomy =
client
.getMetadataTaxonomies()
.createMetadataTaxonomy(
new CreateMetadataTaxonomyRequestBody.Builder(displayName, namespace)
.key(taxonomyKey)
.build());
assert createdTaxonomy.getDisplayName().equals(displayName);
assert createdTaxonomy.getNamespace().equals(namespace);
MetadataTaxonomyLevels taxonomyLevels =
client
.getMetadataTaxonomies()
.createMetadataTaxonomyLevel(
namespace,
taxonomyKey,
Arrays.asList(
new MetadataTaxonomyLevel.Builder()
.displayName("Continent")
.description("Continent Level")
.build(),
new MetadataTaxonomyLevel.Builder()
.displayName("Country")
.description("Country Level")
.build()));
assert taxonomyLevels.getEntries().size() == 2;
assert taxonomyLevels.getEntries().get(0).getDisplayName().equals("Continent");
assert taxonomyLevels.getEntries().get(1).getDisplayName().equals("Country");
MetadataTaxonomyLevels taxonomyLevelsAfterAddition =
client
.getMetadataTaxonomies()
.addMetadataTaxonomyLevel(
namespace,
taxonomyKey,
new AddMetadataTaxonomyLevelRequestBody.Builder("Region")
.description("Region Description")
.build());
assert taxonomyLevelsAfterAddition.getEntries().size() == 3;
assert taxonomyLevelsAfterAddition.getEntries().get(2).getDisplayName().equals("Region");
MetadataTaxonomyLevels taxonomyLevelsAfterDeletion =
client.getMetadataTaxonomies().deleteMetadataTaxonomyLevel(namespace, taxonomyKey);
assert taxonomyLevelsAfterDeletion.getEntries().size() == 2;
assert taxonomyLevelsAfterDeletion.getEntries().get(0).getDisplayName().equals("Continent");
assert taxonomyLevelsAfterDeletion.getEntries().get(1).getDisplayName().equals("Country");
MetadataTaxonomyNode continentNode =
client
.getMetadataTaxonomies()
.createMetadataTaxonomyNode(
namespace, taxonomyKey, new CreateMetadataTaxonomyNodeRequestBody("Europe", 1));
assert continentNode.getDisplayName().equals("Europe");
assert continentNode.getLevel() == 1;
MetadataTaxonomyNode countryNode =
client
.getMetadataTaxonomies()
.createMetadataTaxonomyNode(
namespace,
taxonomyKey,
new CreateMetadataTaxonomyNodeRequestBody.Builder("Poland", 2)
.parentId(continentNode.getId())
.build());
assert countryNode.getDisplayName().equals("Poland");
assert countryNode.getLevel() == 2;
assert countryNode.getParentId().equals(continentNode.getId());
delayInSeconds(5);
MetadataTaxonomyNodes allNodes =
client.getMetadataTaxonomies().getMetadataTaxonomyNodes(namespace, taxonomyKey);
assert allNodes.getEntries().size() == 2;
MetadataTaxonomyNode updatedCountryNode =
client
.getMetadataTaxonomies()
.updateMetadataTaxonomyNode(
namespace,
taxonomyKey,
countryNode.getId(),
new UpdateMetadataTaxonomyNodeRequestBody.Builder()
.displayName("Poland UPDATED")
.build());
assert updatedCountryNode.getDisplayName().equals("Poland UPDATED");
assert updatedCountryNode.getLevel() == 2;
assert updatedCountryNode.getParentId().equals(countryNode.getParentId());
assert updatedCountryNode.getId().equals(countryNode.getId());
MetadataTaxonomyNode getCountryNode =
client
.getMetadataTaxonomies()
.getMetadataTaxonomyNodeById(namespace, taxonomyKey, countryNode.getId());
assert getCountryNode.getDisplayName().equals("Poland UPDATED");
assert getCountryNode.getId().equals(countryNode.getId());
client
.getMetadataTaxonomies()
.deleteMetadataTaxonomyNode(namespace, taxonomyKey, countryNode.getId());
client
.getMetadataTaxonomies()
.deleteMetadataTaxonomyNode(namespace, taxonomyKey, continentNode.getId());
delayInSeconds(5);
MetadataTaxonomyNodes allNodesAfterDeletion =
client.getMetadataTaxonomies().getMetadataTaxonomyNodes(namespace, taxonomyKey);
assert allNodesAfterDeletion.getEntries().size() == 0;
client.getMetadataTaxonomies().deleteMetadataTaxonomy(namespace, taxonomyKey);
}
}