Skip to content

Commit ba6a96e

Browse files
chenkinsdkocher
authored andcommitted
Use set equals.
1 parent 18d0185 commit ba6a96e

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

s3/src/test/java/ch/cyberduck/core/cryptomator/UVFIntegrationTest.java

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import java.util.Arrays;
5656
import java.util.Collections;
5757
import java.util.EnumSet;
58+
import java.util.HashSet;
5859
import java.util.List;
5960
import java.util.stream.Collectors;
6061
import java.util.stream.Stream;
@@ -117,7 +118,7 @@ public void listMinio() throws BackgroundException, IOException {
117118
final Path file = new Path("/" + bucketName + "/" + fi, EnumSet.of(AbstractPath.Type.file));
118119
byte[] content = new byte[1000];
119120
final int size;
120-
try(InputStream in = UVFIntegrationTest.class.getResourceAsStream("/uvf/first_vault" + fi)) {
121+
try(final InputStream in = UVFIntegrationTest.class.getResourceAsStream("/uvf/first_vault" + fi)) {
121122
size = in.read(content);
122123
}
123124
final TransferStatus transferStatus = new TransferStatus().withLength(size);
@@ -146,37 +147,44 @@ public Credentials prompt(final Host bookmark, final String title, final String
146147
final Path home = vault.getHome().withAttributes(attr).withType(EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.vault));
147148
{
148149
final AttributedList<Path> list = storage.getFeature(ListService.class).list(home, new DisabledListProgressListener());
149-
assertEquals(2, list.size());
150-
final Path foo = new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted));
151-
assertTrue(Arrays.toString(list.toArray()), list.contains(foo));
152-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted))));
153-
154-
assertEquals("Hello Foo", readFile(storage, foo));
150+
assertEquals(
151+
new HashSet<>(Arrays.asList(
152+
new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)),
153+
new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))
154+
),
155+
new HashSet<>(list.toList()));
156+
assertEquals("Hello Foo", readFile(storage, new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
155157
}
156158
{
157159
final byte[] expected = writeRandomFile(storage, new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)), 57);
158160
final AttributedList<Path> list = storage.getFeature(ListService.class).list(home, new DisabledListProgressListener());
159-
assertEquals(3, list.size());
160-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
161-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
162-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted))));
161+
assertEquals(
162+
new HashSet<>(Arrays.asList(
163+
new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)),
164+
new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)),
165+
new Path("/cyberduckbucket/foo.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))),
166+
new HashSet<>(list.toList()));
163167

164168
assertEquals(new String(expected), readFile(storage, new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
165169
}
166170
{
167171
final PathAttributes subdir = storage.getFeature(AttributesFinder.class).find(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)));
168172
final AttributedList<Path> list = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)).withAttributes(subdir), new DisabledListProgressListener());
169-
assertEquals(1, list.size());
170-
final Path bar = new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted));
171-
assertTrue(Arrays.toString(list.toArray()), list.contains(bar));
172-
assertEquals("Hello Bar", readFile(storage, bar));
173+
assertEquals(
174+
new HashSet<>(Collections.singletonList(
175+
new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))
176+
),
177+
new HashSet<>(list.toList()));
178+
assertEquals("Hello Bar", readFile(storage, new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
173179
}
174180
{
175181
final byte[] expected = writeRandomFile(storage, new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)), 55);
176182
final AttributedList<Path> list = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)), new DisabledListProgressListener());
177-
assertEquals(2, list.size());
178-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
179-
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
183+
assertEquals(
184+
new HashSet<>(Arrays.asList(
185+
new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)),
186+
new Path("/cyberduckbucket/subdir/bar.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))),
187+
new HashSet<>(list.toList()));
180188

181189
assertEquals(new String(expected), readFile(storage, new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
182190
}
@@ -185,6 +193,11 @@ public Credentials prompt(final Host bookmark, final String title, final String
185193
final AttributedList<Path> list = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)), new DisabledListProgressListener());
186194
assertEquals(1, list.size());
187195
assertTrue(Arrays.toString(list.toArray()), list.contains(new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
196+
assertEquals(
197+
new HashSet<>(Collections.singletonList(
198+
new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))
199+
)),
200+
new HashSet<>(list.toList()));
188201
}
189202
{
190203
storage.getFeature(Move.class).move(
@@ -194,13 +207,19 @@ public Credentials prompt(final Host bookmark, final String title, final String
194207
);
195208

196209
final AttributedList<Path> listSubDir = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)), new DisabledListProgressListener());
197-
assertEquals(2, listSubDir.size());
198-
assertTrue(Arrays.toString(listSubDir.toArray()), listSubDir.contains(new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
199-
assertTrue(Arrays.toString(listSubDir.toArray()), listSubDir.contains(new Path("/cyberduckbucket/subdir/Dave.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
210+
assertEquals(
211+
new HashSet<>(Arrays.asList(
212+
new Path("/cyberduckbucket/subdir/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)),
213+
new Path("/cyberduckbucket/subdir/Dave.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)))
214+
),
215+
new HashSet<>(listSubDir.toList()));
200216
final AttributedList<Path> listHome = storage.getFeature(ListService.class).list(new Path("/cyberduckbucket/", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)), new DisabledListProgressListener());
201-
assertEquals(2, listHome.size());
202-
assertTrue(Arrays.toString(listHome.toArray()), listHome.contains(new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted))));
203-
assertTrue(Arrays.toString(listHome.toArray()), listHome.contains(new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted))));
217+
assertEquals(
218+
new HashSet<>(Arrays.asList(
219+
new Path("/cyberduckbucket/alice.txt", EnumSet.of(AbstractPath.Type.file, AbstractPath.Type.decrypted)),
220+
new Path("/cyberduckbucket/subdir", EnumSet.of(AbstractPath.Type.directory, AbstractPath.Type.placeholder, AbstractPath.Type.decrypted)))
221+
),
222+
new HashSet<>(listHome.toList()));
204223
}
205224
}
206225
finally {

0 commit comments

Comments
 (0)