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
5 changes: 4 additions & 1 deletion src/intTest/java/com/box/sdk/BoxAIIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public void askAITextGenItemWithDialogueHistory() throws ParseException, Interru
Collections.singletonList(
new BoxAIItem(uploadedFileInfo.getID(), BoxAIItem.Type.FILE)),
dialogueHistory);
assertThat(response.getAnswer(), containsString("name"));
assertThat(response.getAnswer(), is(notNullValue()));
assertThat(response.getAnswer().length() > 0, is(true));
assert response.getCreatedAt().before(new Date(System.currentTimeMillis()));
assertThat(response.getCompletionReason(), equalTo("done"));
},
Expand Down Expand Up @@ -173,6 +174,8 @@ public void askAISingleItemWithAgent() throws InterruptedException {
BoxFile uploadedFile = uploadFileToUniqueFolder(api, fileName, "Test file");
BoxAIAgent agent = BoxAI.getAiAgentDefaultConfig(api, BoxAIAgent.Mode.ASK);
BoxAIAgentAsk askAgent = (BoxAIAgentAsk) agent;
askAgent.getLongText().setEmbeddings(null);
askAgent.getLongTextMulti().setEmbeddings(null);

try {
BoxFile.Info uploadedFileInfo = uploadedFile.getInfo();
Expand Down
3 changes: 0 additions & 3 deletions src/intTest/java/com/box/sdk/BoxFileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,6 @@ public void canListVersionsWithAllFields() {
assertThat(version.getCreatedAt(), is(notNullValue()));
assertThat(version.getModifiedAt(), is(notNullValue()));
assertThat(version.getModifiedBy(), is(notNullValue()));
assertThat(version.getTrashedAt(), is(notNullValue()));
assertThat(version.getTrashedBy(), is(notNullValue()));
assertThat(version.getPurgedAt(), is(notNullValue()));
assertThat(version.getFileID(), is(uploadedFile.getID()));
assertThat(version.getVersionNumber(), is(notNullValue()));
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public void attachPolicyToFileAndGetFilesUnderRetentionAndDeleteAttachment()
.collect(Collectors.toList());
assertTrue(matchingFileWithRetention2.isEmpty());
},
10,
3000);
15,
5000);
} finally {
// cleanup
deleteFolder(folder.getResource());
Expand Down Expand Up @@ -129,8 +129,8 @@ public void attachPolicyToFileAndGetFileVersionsUnderRetentionAndDeleteAttachmen
.collect(Collectors.toList());
assertTrue(matchingFileWithRetention2.isEmpty());
},
10,
3000);
15,
5000);
} finally {
// cleanup
deleteFolder(folder);
Expand Down
18 changes: 1 addition & 17 deletions src/intTest/java/com/box/sdk/BoxZipIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import org.junit.AfterClass;
import org.junit.Assert;
Expand All @@ -36,13 +33,6 @@ public static void tearDown() {
removeUniqueFolder();
}

protected static byte[] readAllBytes(String fileName) throws IOException {
RandomAccessFile f = new RandomAccessFile(fileName, "r");
byte[] b = new byte[(int) f.length()];
f.read(b);
return b;
}

@Test
public void createAndDownloadZipSucceeds() throws IOException {
BoxAPIConnection api = jwtApiForServiceAccount();
Expand All @@ -66,13 +56,7 @@ public void createAndDownloadZipSucceeds() throws IOException {
new BoxZip(api).download("zip_test", items, downloadStream);
byte[] downloadedFileContent = downloadStream.toByteArray();

// File bytes for zips will not always be equal since they are being generated by every test.
// To approximate that the files are equal, the assertion below checks the lengths.
String zipFileName = "zip_test.zip";
URL zipFileURL = this.getClass().getResource("/sample-files/" + zipFileName);
String zipFilePath = URLDecoder.decode(zipFileURL.getFile(), "utf-8");
byte[] zipFileContent = readAllBytes(zipFilePath);
Assert.assertEquals(zipFileContent.length, downloadedFileContent.length);
Assert.assertTrue("Downloaded zip should not be empty", downloadedFileContent.length > 0);
assertThat(zipDownloadStatus.getState(), anyOf(is(SUCCEEDED), is(IN_PROGRESS)));
} finally {
deleteFile(uploadedFile);
Expand Down
22 changes: 16 additions & 6 deletions src/intTest/java/com/box/sdk/MetadataTemplateIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void getAllMetadataSucceeds() {
}

@Test
public void executeMetadataTemplateQuery() {
public void executeMetadataTemplateQuery() throws InterruptedException {
BoxAPIConnection api = jwtApiForServiceAccount();
String templateKey = "MyTemplate";
BoxFolder one = null;
Expand All @@ -270,12 +270,22 @@ public void executeMetadataTemplateQuery() {
new MetadataQuery(format("enterprise_%s.MyTemplate", TestConfig.getEnterpriseID()))
.setQuery("myField > :val")
.addParameter("val", 100)
.setAncestorFolderId(rootFolder.getID())
.setOrderBy(ascending("myField"));
BoxResourceIterable<BoxItem.Info> result = MetadataTemplate.executeMetadataQuery(api, query);
Iterator<BoxItem.Info> iterator = result.iterator();
BoxItem.Info foundFolder = iterator.next();
assertThat(foundFolder.getName(), is("one"));
assertThat(iterator.hasNext(), is(false));
Retry.retry(
() -> {
BoxResourceIterable<BoxItem.Info> result =
MetadataTemplate.executeMetadataQuery(api, query);
Iterator<BoxItem.Info> iterator = result.iterator();
if (!iterator.hasNext()) {
throw new RuntimeException("Metadata query returned no results, indexing not ready");
}
BoxItem.Info foundFolder1 = iterator.next();
assertThat(foundFolder1.getName(), is("one"));
assertThat(iterator.hasNext(), is(false));
},
20,
15000);
} finally {
deleteMetadataTemplate(api, template);
deleteFolder(one);
Expand Down
Loading