@Test public void testListArchiveContents() throws Exception { byte[] archive = createContentArchive(); try (ByteArrayInputStream stream = new ByteArrayInputStream(archive)) { byte[] hash = repository.addContent(stream); // hash is different from the simple overlay.xhtml as we add the content folder name in the // computation assertThat(hash, is(notNullValue())); List<String> contents = repository .listContent(hash, "", ContentFilter.Factory.createContentFilter(-1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents.size(), is(5)); assertThat( contents, CoreMatchers.hasItems( "test.jsp", "overlay.xhtml", "test/empty-file.txt", "test/", "empty-dir/")); hash = repository.addContentToExploded( hash, Collections.singletonList(new ExplodedContent("test/empty-file.txt", emptyStream())), true); hash = repository.addContentToExploded( hash, Collections.singletonList(new ExplodedContent("empty-dir", null)), true); contents = repository .listContent(hash, "", ContentFilter.Factory.createContentFilter(1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents, is(notNullValue())); assertThat(contents.size(), is(4)); assertThat( contents, CoreMatchers.hasItems("test.jsp", "overlay.xhtml", "test/", "empty-dir/")); contents = repository .listContent(hash, "", ContentFilter.Factory.createFileFilter(-1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents, is(notNullValue())); assertThat(contents.size(), is(3)); assertThat( contents, CoreMatchers.hasItems("test.jsp", "overlay.xhtml", "test/empty-file.txt")); } }
@Test public void testBug56903() { Context context = new StandardContext(); context.setResourceOnlyServlets("a,b,c"); Assert.assertThat( Arrays.asList(context.getResourceOnlyServlets().split(",")), CoreMatchers.hasItems("a", "b", "c")); }
@Test public void test() throws Exception { IRecommendersCompletionContext sut = WORKSPACE.createProject().createFile(code).triggerContentAssist(); Set<ITypeName> result = sut.getExpectedTypeNames(); assertThat(result, CoreMatchers.hasItems(expectedTypes)); assertThat(result.size(), is(equalTo(expectedTypes.length))); }
private void testBase(String[] ARGS) throws IOException, GeneralSecurityException { // Run the pipeline. VariantSimilarity.main(ARGS); // Download the pipeline results. List<GraphResult> results = Lists.newArrayList(); for (GcsPath path : helper.gcsUtil.expand(GcsPath.fromUri(outputPrefix + "*"))) { BufferedReader reader = helper.openOutput(path.toString()); for (String line = reader.readLine(); line != null; line = reader.readLine()) { results.add(GraphResult.fromString(line)); } } // Check the pipeline results. assertEquals(helper.PLATINUM_GENOMES_NUMBER_OF_SAMPLES, results.size()); assertThat(results, CoreMatchers.allOf(CoreMatchers.hasItems(EXPECTED_RESULT))); }
@Test public void three_way_join() { List<Record> joined = RecordJoins.join(RecordJoins.join(books).on(authorId).to(id).manyToOne(authors)) .on(publisherId) .to(id) .manyToOne(publishers) .map(r -> r.select(publisherName, authorName, bookName)) .filter(authorName.is("Alan Goodyear")) .collect(Collectors.toList()); assertThat( joined, CoreMatchers.hasItems( $$( bookName.of("Amorous Encounters"), authorName.of("Alan Goodyear"), publisherName.of("Bills And Moon")), $$( bookName.of("The Cromulence Of Truths"), authorName.of("Alan Goodyear"), publisherName.of("Servo")))); }
@Test public void testListContents() throws Exception { byte[] archive = createArchive(Collections.singletonList("overlay.xhtml")); try (ByteArrayInputStream stream = new ByteArrayInputStream(archive)) { byte[] hash = repository.explodeContent(repository.addContent(stream)); String expResult = "b1f18e286615dda0643633ec31f1a17d90e48875"; // hash is different from the simple overlay.xhtml as we add the content folder name in the // computation assertThat(hash, is(notNullValue())); Path content = repository.getContent(hash).getPhysicalFile().toPath(); String contentHtml = readFileContent(content.resolve("overlay.xhtml")); String expectedContentHtml = readFileContent(getResourceAsStream("overlay.xhtml")); assertThat(contentHtml, is(expectedContentHtml)); assertThat(HashUtil.bytesToHexString(hash), is(expResult)); String updatedExpectedResult = "161a2c95b16d5ffede0721c2cec984ca51009082"; hash = repository.addContentToExploded( hash, Collections.singletonList( new ExplodedContent( "test.jsp", new ByteArrayInputStream("this is a test".getBytes(StandardCharsets.UTF_8)))), true); assertThat(hash, is(notNullValue())); assertThat(HashUtil.bytesToHexString(hash), is(updatedExpectedResult)); List<String> contents = repository .listContent(hash, "", ContentFilter.Factory.createContentFilter(-1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents.size(), is(2)); assertThat(contents, CoreMatchers.hasItems("test.jsp", "overlay.xhtml")); hash = repository.addContentToExploded( hash, Collections.singletonList(new ExplodedContent("test/empty-file.txt", emptyStream())), true); hash = repository.addContentToExploded( hash, Collections.singletonList(new ExplodedContent("empty-dir", null)), true); contents = repository .listContent(hash, "", ContentFilter.Factory.createContentFilter(-1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents, is(notNullValue())); assertThat(contents.size(), is(5)); assertThat( contents, CoreMatchers.hasItems( "test.jsp", "overlay.xhtml", "test/empty-file.txt", "test/", "empty-dir/")); hash = repository.removeContentFromExploded(hash, Collections.singletonList("test.jsp")); contents = repository .listContent(hash, "", ContentFilter.Factory.createFileFilter(-1, false)) .stream() .map(ContentRepositoryElement::getPath) .collect(Collectors.toList()); assertThat(contents, is(notNullValue())); assertThat(contents.size(), is(2)); assertThat(contents, CoreMatchers.hasItems("overlay.xhtml", "test/empty-file.txt")); } }