Skip to content

Commit

Permalink
test: Add AI studio tests (box/box-codegen#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Feb 19, 2025
1 parent 0da38a1 commit 69eba35
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "c1e6fc8", "specHash": "f20ba3f", "version": "0.5.0" }
{ "engineHash": "8a9cc1d", "specHash": "f20ba3f", "version": "0.5.0" }
25 changes: 20 additions & 5 deletions docs/aistudio.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ This operation is performed by calling function `getAiAgents`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-ai-agents/).

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

### Arguments

Expand All @@ -42,7 +45,10 @@ This operation is performed by calling function `createAiAgent`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/post-ai-agents/).

*Currently we don't have an example for calling `createAiAgent` in integration tests*
<!-- sample post_ai_agents -->
```
client.getAiStudio().createAiAgent(new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled").ask(new AiStudioAgentAsk("enabled", "desc1")).build())
```

### Arguments

Expand All @@ -68,7 +74,10 @@ This operation is performed by calling function `updateAiAgentById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/put-ai-agents-id/).

*Currently we don't have an example for calling `updateAiAgentById` in integration tests*
<!-- sample put_ai_agents_id -->
```
client.getAiStudio().updateAiAgentById(createdAgent.getId(), new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled").ask(new AiStudioAgentAsk("disabled", "desc2")).build())
```

### Arguments

Expand Down Expand Up @@ -96,7 +105,10 @@ This operation is performed by calling function `getAiAgentById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-ai-agents-id/).

*Currently we don't have an example for calling `getAiAgentById` in integration tests*
<!-- sample get_ai_agents_id -->
```
client.getAiStudio().getAiAgentById(createdAgent.getId(), new GetAiAgentByIdQueryParams.GetAiAgentByIdQueryParamsBuilder().fields(Arrays.asList("ask")).build())
```

### Arguments

Expand Down Expand Up @@ -124,7 +136,10 @@ This operation is performed by calling function `deleteAiAgentById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/delete-ai-agents-id/).

*Currently we don't have an example for calling `deleteAiAgentById` in integration tests*
<!-- sample delete_ai_agents_id -->
```
client.getAiStudio().deleteAiAgentById(createdAgent.getId())
```

### Arguments

Expand Down
61 changes: 61 additions & 0 deletions src/test/java/com/box/sdkgen/test/aistudio/AiStudioITest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.box.sdkgen.test.aistudio;

import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
import static com.box.sdkgen.internal.utils.UtilsManager.getUuid;
import static com.box.sdkgen.test.commons.CommonsManager.getDefaultClient;

import com.box.sdkgen.client.BoxClient;
import com.box.sdkgen.managers.aistudio.GetAiAgentByIdQueryParams;
import com.box.sdkgen.schemas.aimultipleagentresponse.AiMultipleAgentResponse;
import com.box.sdkgen.schemas.aisingleagentresponsefull.AiSingleAgentResponseFull;
import com.box.sdkgen.schemas.aistudioagentask.AiStudioAgentAsk;
import com.box.sdkgen.schemas.createaiagent.CreateAiAgent;
import java.util.Arrays;
import org.junit.jupiter.api.Test;

public class AiStudioITest {

private static final BoxClient client = getDefaultClient();

@Test
public void testAiStudioCrud() {
String agentName = getUuid();
AiSingleAgentResponseFull createdAgent =
client
.getAiStudio()
.createAiAgent(
new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled")
.ask(new AiStudioAgentAsk("enabled", "desc1"))
.build());
assert createdAgent.getName().equals(agentName);
AiMultipleAgentResponse agents = client.getAiStudio().getAiAgents();
int numAgents = agents.getEntries().size();
assert convertToString(agents.getEntries().get(0).getType()).equals("ai_agent");
AiSingleAgentResponseFull retrievedAgent =
client
.getAiStudio()
.getAiAgentById(
createdAgent.getId(),
new GetAiAgentByIdQueryParams.GetAiAgentByIdQueryParamsBuilder()
.fields(Arrays.asList("ask"))
.build());
assert retrievedAgent.getName().equals(agentName);
assert convertToString(retrievedAgent.getAccessState()).equals("enabled");
assert convertToString(retrievedAgent.getAsk().getAccessState()).equals("enabled");
assert retrievedAgent.getAsk().getDescription().equals("desc1");
AiSingleAgentResponseFull updatedAgent =
client
.getAiStudio()
.updateAiAgentById(
createdAgent.getId(),
new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled")
.ask(new AiStudioAgentAsk("disabled", "desc2"))
.build());
assert convertToString(updatedAgent.getAccessState()).equals("enabled");
assert convertToString(updatedAgent.getAsk().getAccessState()).equals("disabled");
assert updatedAgent.getAsk().getDescription().equals("desc2");
client.getAiStudio().deleteAiAgentById(createdAgent.getId());
AiMultipleAgentResponse agentsAfterDelete = client.getAiStudio().getAiAgents();
assert agentsAfterDelete.getEntries().size() == numAgents - 1;
}
}

0 comments on commit 69eba35

Please sign in to comment.