当前位置: 首页>>代码示例>>Java>>正文


Java StringSubject类代码示例

本文整理汇总了Java中com.google.common.truth.StringSubject的典型用法代码示例。如果您正苦于以下问题:Java StringSubject类的具体用法?Java StringSubject怎么用?Java StringSubject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringSubject类属于com.google.common.truth包,在下文中一共展示了StringSubject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatesTemplateThat

import com.google.common.truth.StringSubject; //导入依赖的package包/类
StringSubject generatesTemplateThat() {
  generateCode();
  if (fileNode.numChildren() != 1) {
    fail("expected to only have 1 template: " + fileNode.getChildren());
  }
  TemplateNode template = fileNode.getChild(0);
  // we know that 'file' contains exactly one template.  so find it.
  int functionIndex = file.indexOf("function(");
  int startOfFunction = file.substring(0, functionIndex).lastIndexOf('\n') + 1;
  int endOfFunction = file.lastIndexOf("}\n") + 2; // +2 to capture the \n

  // if it is a delegate function we want to include the registration code which is a single
  // statement after the end of the template
  if (template instanceof TemplateDelegateNode) {
    endOfFunction = file.indexOf(";\n", endOfFunction) + 2;
  }
  // if we are generating jsdoc we want to capture that too
  String templateBody;
    int startOfJsDoc = file.substring(0, startOfFunction).lastIndexOf("/**");
    templateBody = file.substring(startOfJsDoc, endOfFunction);
  return check()
      .withMessage("Unexpected template body generated for %s:", actual())
      .that(templateBody);
}
 
开发者ID:google,项目名称:closure-templates,代码行数:25,代码来源:JsSrcSubject.java

示例2: testToString

import com.google.common.truth.StringSubject; //导入依赖的package包/类
@Test
void testToString() {
	Error objectUnderTest = new Error();
	objectUnderTest.setSourceIdentifier("sourceID");
	objectUnderTest.setDetails(Collections.singletonList(Detail.forErrorCode(ErrorCode.UNEXPECTED_ERROR)));
	objectUnderTest.setType("aType");
	objectUnderTest.setMessage("coolMessage");

	StringSubject subject = assertWithMessage("Must contain formatted string")
			.that(objectUnderTest.toString());
	subject.contains(String.valueOf(objectUnderTest.getSourceIdentifier()));
	subject.contains(String.valueOf(objectUnderTest.getDetails()));
	subject.contains(String.valueOf(objectUnderTest.getType()));
	subject.contains(String.valueOf(objectUnderTest.getMessage()));
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:16,代码来源:ErrorTest.java

示例3: is_used_as_default_applicationClass

import com.google.common.truth.StringSubject; //导入依赖的package包/类
@Test public void is_used_as_default_applicationClass() throws Exception {
  project.named("test").buildWithArguments("assemble");
  
  Execution original = ExecutableJar.at(project.file("build/libs/test.jar")).run();
  Execution capsule = CapsuleJar.at(project.file("build/libs/test-capsule.jar")).run();
  
  assertThat(original).succeeded();
  StringSubject capsuleOutput = assertThat(capsule).succeededAnd().standardOutput();
  capsuleOutput.isNotEmpty();
  capsuleOutput.isEqualTo(original.output);
}
 
开发者ID:jonas-l,项目名称:gradle-capsule-plugin,代码行数:12,代码来源:DeclaredJarMainClassManifestEntry.java

示例4: hasLogAtLevelWithMessage

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public Which<StringSubject> hasLogAtLevelWithMessage(Level level, String message) {
  List<String> messagesAtLevel = getMessagesAtLevel(level);
  check()
      .withMessage("Logs at level %s", level)
      .that(messagesAtLevel)
      .comparingElementsUsing(CONTAINS_CORRESPONDENCE)
      .contains(message);
  for (String messageCandidate : messagesAtLevel) {
    if (messageCandidate.contains(message)) {
      return new Which<>(assertThat(messageCandidate)
          .named(String.format("log message at %s matching '%s'", level, message)));
    }
  }
  throw new AssertionError("Message check passed yet matching message not found");
}
 
开发者ID:google,项目名称:nomulus,代码行数:16,代码来源:LogsSubject.java

示例5: textSymbolFile

import com.google.common.truth.StringSubject; //导入依赖的package包/类
@NonNull
public StringSubject textSymbolFile() throws IOException {
    InputStream stream = getInputStream("R.txt");

    return new StringSubject(failureStrategy,
            CharStreams.toString(new InputStreamReader(stream, Charsets.UTF_8)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AarSubject.java

示例6: asString

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public StringSubject asString() throws IOException {
  isNotNull();
  // We shouldn't close the BinaryResult within this method as it might still
  // be used afterwards. Besides, closing it doesn't have an effect for most
  // implementations of a BinaryResult.
  BinaryResult binaryResult = actual();
  return Truth.assertThat(binaryResult.asString());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:BinaryResultSubject.java

示例7: checkTopic

import com.google.common.truth.StringSubject; //导入依赖的package包/类
private void checkTopic(Result change, @Nullable String topic) throws RestApiException {
  ChangeInfo info = gApi.changes().id(change.getChangeId()).get();
  StringSubject t = assertThat(info.topic).named("topic");
  if (topic != null) {
    t.isEqualTo(topic);
  } else {
    t.isNull();
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:CorsIT.java

示例8: assertThatSourceString

import com.google.common.truth.StringSubject; //导入依赖的package包/类
private static StringSubject assertThatSourceString(TemplateNode node) {
  SoyFileNode parent = node.getParent().copy(new CopyState());
  new DesugarHtmlNodesPass().run(parent, new IncrementingIdGenerator());
  StringBuilder sb = new StringBuilder();
  parent.getChild(0).appendSourceStringForChildren(sb);
  return assertThat(sb.toString());
}
 
开发者ID:google,项目名称:closure-templates,代码行数:8,代码来源:HtmlRewritePassTest.java

示例9: contentsAsString

import com.google.common.truth.StringSubject; //导入依赖的package包/类
/**
 * Returns a {@link StringSubject} that makes assertions about the contents of the actual file as
 * a string.
 */
public StringSubject contentsAsString(Charset charset) {
  try {
    return check()
        .that(JavaFileObjects.asByteSource(actual()).asCharSource(charset).read())
        .named("the contents of " + actualAsString());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:google,项目名称:compile-testing,代码行数:14,代码来源:JavaFileObjectSubject.java

示例10: standardError

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public StringSubject standardError() {
  return Truth.assertThat(actual().error);
}
 
开发者ID:jonas-l,项目名称:gradle-capsule-plugin,代码行数:4,代码来源:ExecutionSubject.java

示例11: standardOutput

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public StringSubject standardOutput() {
  return Truth.assertThat(actual().output);
}
 
开发者ID:jonas-l,项目名称:gradle-capsule-plugin,代码行数:4,代码来源:ExecutionSubject.java

示例12: assertThat

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public static StringSubject assertThat(@Nullable String target) {
    return assert_().that(target);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:TruthHelper.java

示例13: diagnosticStream

import com.google.common.truth.StringSubject; //导入依赖的package包/类
StringSubject diagnosticStream() {
  String[] parseResult = parse();
  return assertThat(parseResult[1]);
}
 
开发者ID:angular,项目名称:clutz,代码行数:5,代码来源:ProgramSubject.java

示例14: commonLines

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public ListSubject<StringSubject, String> commonLines() {
  isNotNull();
  ContentEntry contentEntry = actual();
  return ListSubject.assertThat(contentEntry.ab, Truth::assertThat).named("common lines");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:ContentEntrySubject.java

示例15: linesOfA

import com.google.common.truth.StringSubject; //导入依赖的package包/类
public ListSubject<StringSubject, String> linesOfA() {
  isNotNull();
  ContentEntry contentEntry = actual();
  return ListSubject.assertThat(contentEntry.a, Truth::assertThat).named("lines of 'a'");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:ContentEntrySubject.java


注:本文中的com.google.common.truth.StringSubject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。