Java源码示例:org.hamcrest.core.StringEndsWith
示例1
@Test
public void extendsExistingMap() throws Exception {
MatcherAssert.assertThat(
"Can't extend an existing map",
new Sticky<String, String>(
new Sticky<String, String>(
new MapEntry<>("make", "Mercedes-Benz"),
new MapEntry<>("cost", "$95,000")
),
new MapEntry<>("year", "2017"),
new MapEntry<>("mileage", "12,000")
),
new IsMapContaining<>(
new IsAnything<>(),
new StringEndsWith(",000")
)
);
}
示例2
@Test
public void test() throws IOException {
final ReferenceTextBuilder builder = ReferenceTextBuilder.createDiploid();
builder.addSequence("foo", Sex.EITHER, Ploidy.DIPLOID, true);
builder.addSequence("moo", Sex.MALE, Ploidy.HAPLOID, false);
assertEquals(EXPECTED, builder.toString());
try (TestDirectory dir = new TestDirectory()) {
final File refText = new File(dir, "someName");
builder.writeToFile(refText);
assertEquals(EXPECTED, FileHelper.fileToString(refText));
final File sdf = ReaderTestUtils.getDNADir(">seq\nacagtacgt\n", new File(dir, "sdf"));
builder.writeToSdfDir(sdf);
assertEquals(EXPECTED, FileHelper.fileToString(new File(sdf, ReferenceGenome.REFERENCE_FILE)));
final File notSdf = new File(dir, "notSdf");
assertTrue(notSdf.mkdir());
mExpectedException.expect(IOException.class);
mExpectedException.expectMessage(StringEndsWith.endsWith("is not an SDF"));
builder.writeToSdfDir(notSdf);
}
}
示例3
@Test
public void requiredArgumentsDefaultValues() throws Exception {
// setup
// Add the required parameters
arguments.addAll(Arrays.asList(PROJECT_BASE_ARGS[0], baseDir.toString(), INPUT_ARGS[0], inputDir.toString()));
// test
command = FeedCommand.parse(FeedCommand.class, arguments);
// verify required
assertThat(command.getPriorityDirectories().size(), equalTo(1));
assertThat(command.getPriorityDirectories().get(0).getDirectoryName(), equalTo(inputDir.toString() + "/"));
assertThat(command.getProjectBase(), equalTo(baseDir));
// verify defaults
assertThat(command.getBundleSize(), equalTo(1));
assertThat(command.getCaseClass(), equalTo(""));
assertThat(command.getCaseId(), equalTo("auto"));
assertThat(command.getClientPattern(), equalTo("INITIAL.FILE_PICK_UP_CLIENT.INPUT.*"));
assertThat(command.getEatPrefix(), equalTo(""));
assertThat(command.getHost(), equalTo("localhost"));
assertThat(command.getLogbackConfig(), equalTo(baseDir + "/config/logback.xml"));
assertThat(command.getOutputRoot(), StringEndsWith.endsWith("/DoneParsedData"));
assertThat(command.getPort(), equalTo(7001));
assertThat(command.getSort(), equalTo(null));
assertThat(command.getWorkspaceClass(), equalTo("emissary.pickup.WorkSpace"));
assertThat(command.getWorkspaceName(), equalTo("WorkSpace"));
assertThat(command.isFileTimestamp(), equalTo(false));
assertThat(command.isSimple(), equalTo(false));
assertThat(command.isIncludeDirs(), equalTo(false));
assertThat(command.isLoop(), equalTo(true));
assertThat(command.isRetry(), equalTo(true));
assertThat(command.isSkipDotFile(), equalTo(true));
}
示例4
@Test
public void decoratesEntries() throws Exception {
MatcherAssert.assertThat(
"Can't decorate a list of entries",
new Sticky<String, String>(
new MapEntry<>("first", "Jeffrey"),
new MapEntry<>("last", "Lebowski")
),
new IsMapContaining<>(
new IsAnything<>(),
new StringEndsWith("ski")
)
);
}
示例5
@Test
void uriValuesDoNotEndInSlash() {
liveServers.getServers().stream()
.map(ServerProperties::getUri)
.filter(Objects::nonNull)
.map(URI::toString)
.forEach(uriString -> assertThat(uriString, not(StringEndsWith.endsWith("/"))));
}
示例6
private static Collection<String> getClassesInPackage(String packageName, String sampleClass) {
String sampleClassPathSuffix = sampleClass.replaceAll("\\.", "/") + ".class";
String sampleClassPath = CheckParserUsagesDT.class.getClassLoader().getResource(sampleClassPathSuffix).getPath();
assertThat(sampleClassPath, new StringEndsWith(sampleClassPathSuffix));
String packagePath = sampleClassPath.substring(0,sampleClassPath.length()-sampleClassPathSuffix.length()) +
packageName.replaceAll("\\.", "/");
return getAllClassesInDirectory(new File(packagePath));
}
示例7
@Test
public void testDuplicateExits() throws ConfigurationException {
Adapter adapter = new Adapter();
PipeLine pipeline = new PipeLine();
PipeLineExit exit = new PipeLineExit();
exit.setPath("success");
exit.setState("SUCCESS");
pipeline.registerPipeLineExit(exit);
pipeline.registerPipeLineExit(exit);
adapter.registerPipeLine(pipeline);
String lastWarning = ConfigurationWarnings.getInstance().getLast();
assertThat(lastWarning,StringEndsWith.endsWith("PipeLine exit named [success] already exists"));
}