Skip to content

Commit

Permalink
Adjust tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jun 14, 2023
1 parent 3d64013 commit 7740173
Showing 1 changed file with 39 additions and 19 deletions.
Expand Up @@ -213,7 +213,7 @@ public void testListRevisions() throws Exception {
assertEquals(Long.valueOf(1L), list.find(path -> path.attributes().isDuplicate()).attributes().getRevision());
}
// Add hide marker
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes().withVersionId(null)))), new DisabledLoginCallback(), new Delete.DisabledCallback());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
{
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
assertEquals(3, list.size());
Expand Down Expand Up @@ -268,17 +268,24 @@ public void testListFolder() throws Exception {
assertSame(folder1, list.find(new SimplePathPredicate(file1)).getParent());
assertSame(folder1, list.find(new SimplePathPredicate(folder2)).getParent());
// Nullify version to add delete marker
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file2.withAttributes(new PathAttributes(file2.attributes().withVersionId(null)))), new DisabledLoginCallback(), new Delete.DisabledCallback());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file2).withAttributes(new PathAttributes(file2.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder2, new DisabledListProgressListener()).isEmpty());
assertTrue(new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).isEmpty());
assertFalse(new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).isEmpty());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(folder2), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()));
assertTrue(new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).contains(file2));
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder2, new DisabledListProgressListener()));
// Nullify version to add delete marker
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file1.withAttributes(new PathAttributes(file1.attributes().withVersionId(null)))), new DisabledLoginCallback(), new Delete.DisabledCallback());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder1, new DisabledListProgressListener()).isEmpty());
assertTrue(new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()).isEmpty());
assertTrue(new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()).contains(folder2));
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(folder1), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()));
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder1, new DisabledListProgressListener()));
for(Path f : new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener())) {
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(f), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
for(Path f : new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener())) {
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(f), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand All @@ -290,15 +297,24 @@ public void testDisplayFolderInBucketMissingPlaceholder() throws Exception {
final Path folder1 = new Path(bucket, "1-d", EnumSet.of(Path.Type.directory));
final Path file1 = new B2TouchFeature(session, fileid).touch(new Path(folder1, "2-f", EnumSet.of(Path.Type.file)), new TransferStatus());
assertNotNull(file1.attributes().getVersionId());
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
assertEquals(1, list.size());
final Path foundFolder1 = list.iterator().next();
assertEquals(folder1, foundFolder1);
assertFalse(foundFolder1.attributes().isDuplicate());
{
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
assertEquals(1, list.size());
final Path foundFolder1 = list.iterator().next();
assertEquals(folder1, foundFolder1);
assertTrue(foundFolder1.attributes().isDuplicate());
}
// Nullify version to add delete marker
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file1.withAttributes(new PathAttributes(file1.attributes().withVersionId(null)))), new DisabledLoginCallback(), new Delete.DisabledCallback());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(new Path(file1).withAttributes(new PathAttributes(file1.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertTrue(new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(bucket, new DisabledListProgressListener()).isEmpty());
assertTrue(new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener()).isEmpty());
{
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(bucket, new DisabledListProgressListener());
assertEquals(1, list.size());
assertEquals(folder1, list.iterator().next());
}
for(Path f : new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener())) {
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(f), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand All @@ -316,21 +332,25 @@ public void testDisplayFolderInFolderMissingPlaceholder() throws Exception {
assertEquals(1, list.size());
final Path foundFolder1 = list.iterator().next();
assertEquals(folder1, foundFolder1);
assertFalse(foundFolder1.attributes().isDuplicate());
assertTrue(foundFolder1.attributes().isDuplicate());
}
{
final AttributedList<Path> list = new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener());
assertEquals(1, list.size());
final Path foundFolder2 = list.iterator().next();
assertEquals(folder2, foundFolder2);
assertFalse(foundFolder2.attributes().isDuplicate());
assertTrue(foundFolder2.attributes().isDuplicate());
}
// Nullify version to add delete marker
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes().withVersionId(null)))), new DisabledLoginCallback(), new Delete.DisabledCallback());
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(file.withAttributes(new PathAttributes(file.attributes()).withVersionId(null))), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(new DefaultFindFeature(session).find(folder1, new DisabledListProgressListener()));
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()));
assertTrue(new B2ObjectListService(session, fileid).list(folder1, new DisabledListProgressListener()).contains(folder2));
assertFalse(new DefaultFindFeature(session).find(folder2, new DisabledListProgressListener()));
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()));
assertEquals(2, new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener()).size());
assertThrows(NotfoundException.class, () -> new B2ObjectListService(session, fileid, 1, VersioningConfiguration.empty()).list(folder2, new DisabledListProgressListener()));
for(Path f : new B2ObjectListService(session, fileid).list(folder2, new DisabledListProgressListener())) {
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(f), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
new B2DeleteFeature(session, fileid).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand Down

0 comments on commit 7740173

Please sign in to comment.