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


Java VerifyException类代码示例

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


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

示例1: toJavaObject

import com.google.common.base.VerifyException; //导入依赖的package包/类
/**
 * Converts a {@link JsonValue} to its corresponding Java object. Values of type {@link
 * JsonObject} or {@link JsonArray} are converted as specified by {@link #toJavaMap} and {@link
 * #toJavaList}, respectively.
 */
@Nullable
public static Object toJavaObject(JsonValue value) {
  switch (value.getValueType()) {
    case ARRAY:
      return toJavaList((JsonArray) value);
    case FALSE:
      return Boolean.FALSE;
    case NULL:
      return null;
    case NUMBER:
      JsonNumber number = (JsonNumber) value;
      return number.isIntegral() ? number.intValue() : number.doubleValue();
    case OBJECT:
      return toJavaMap((JsonObject) value);
    case STRING:
      return ((JsonString) value).getString();
    case TRUE:
      return Boolean.TRUE;
    default:
      throw new VerifyException("Json value with unknown type: " + value);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:28,代码来源:JavaxJson.java

示例2: getSuperMethodSpecs

import com.google.common.base.VerifyException; //导入依赖的package包/类
private List<MethodSpec> getSuperMethodSpecs() {
    List<MethodSpec> methodSpecs = new ArrayList<>();
    this.annotatedClazz.annotatedElement.getEnclosedElements().stream()
            .filter(element -> element instanceof ExecutableElement)
            .map(element -> (ExecutableElement) element)
            .forEach(method -> {
                ClassName preferenceRoom = ClassName.get(PreferenceRoom.class);
                MethodSpec.Builder builder = MethodSpec.overriding(method);
                MethodSpec methodSpec = builder.addStatement("$T.inject($N)", preferenceRoom, method.getParameters().get(0).getSimpleName()).build();
                if(methodSpec.returnType != TypeName.get(Void.TYPE)) {
                    throw new VerifyException(String.format("Returned '%s'. only return type can be void.", methodSpec.returnType.toString()));
                }
                methodSpecs.add(methodSpec);
            });
    return methodSpecs;
}
 
开发者ID:skydoves,项目名称:PreferenceRoom,代码行数:17,代码来源:PreferenceComponentGenerator.java

示例3: processInjector

import com.google.common.base.VerifyException; //导入依赖的package包/类
private void processInjector(PreferenceComponentAnnotatedClass annotatedClass) throws VerifyException {
    try {
        annotatedClass.annotatedElement.getEnclosedElements().stream()
                .filter(element -> element instanceof ExecutableElement)
                .map(element -> (ExecutableElement) element)
                .forEach(method -> {
                    MethodSpec methodSpec = MethodSpec.overriding(method).build();
                    ParameterSpec parameterSpec = methodSpec.parameters.get(0);
                    TypeElement injectedElement = processingEnv.getElementUtils().getTypeElement(parameterSpec.type.toString());
                    generateProcessInjector(annotatedClass, injectedElement);
                });
    } catch (VerifyException e) {
        showErrorLog(e.getMessage(), annotatedClass.annotatedElement);
        e.printStackTrace();
    }
}
 
开发者ID:skydoves,项目名称:PreferenceRoom,代码行数:17,代码来源:PreferenceRoomProcessor.java

示例4: KickbackElementClass

import com.google.common.base.VerifyException; //导入依赖的package包/类
public KickbackElementClass(VariableElement variableElement, Elements elementUtils) throws VerifyException {
    KickbackElement kickbackElement = variableElement.getAnnotation(KickbackElement.class);
    Weak weak = variableElement.getAnnotation(Weak.class);
    Soft soft = variableElement.getAnnotation(Soft.class);
    PackageElement packageElement = elementUtils.getPackageOf(variableElement);
    this.variableElement = variableElement;
    this.packageName = packageElement.isUnnamed() ? null : packageElement.getQualifiedName().toString();
    this.typeName = TypeName.get(variableElement.asType());
    this.clazzName = variableElement.getSimpleName().toString();
    this.value = variableElement.getConstantValue();
    if(weak != null) this.isWeak = true;
    else this.isWeak = false;
    if(soft != null) this.isSoft = true;
    else this.isSoft = false;

    if(kickbackElement != null) {
        this.elementName =  StringUtils.toUpperCamel(Strings.isNullOrEmpty(kickbackElement.name()) ? this.clazzName : kickbackElement.name());
    } else {
        this.elementName = StringUtils.toUpperCamel(this.clazzName);
    }

    checkPrimitiveType();
    checkModifierValidate();
    checkAnnotationValidate();
}
 
开发者ID:skydoves,项目名称:Kickback,代码行数:26,代码来源:KickbackElementClass.java

示例5: provideJsonPayload

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Provides
@JsonPayload
@SuppressWarnings("unchecked")
static Map<String, Object> provideJsonPayload(
    @Header("Content-Type") MediaType contentType,
    @Payload String payload) {
  if (!JSON_UTF_8.is(contentType.withCharset(UTF_8))) {
    throw new UnsupportedMediaTypeException(
        String.format("Expected %s Content-Type", JSON_UTF_8.withoutParameters()));
  }
  try {
    return (Map<String, Object>) JSONValue.parseWithException(payload);
  } catch (ParseException e) {
    throw new BadRequestException(
        "Malformed JSON", new VerifyException("Malformed JSON:\n" + payload, e));
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:RequestModule.java

示例6: lookupPublicKey

import com.google.common.base.VerifyException; //导入依赖的package包/类
/**
 * Search for public key on keyring based on a substring (like an email address).
 *
 * @throws VerifyException if the key couldn't be found.
 * @see #lookupKeyPair
 */
public static PGPPublicKey lookupPublicKey(
    PGPPublicKeyRingCollection keyring, String query, KeyRequirement want) {
  try {
    // Safe by specification.
    @SuppressWarnings("unchecked")
    Iterator<PGPPublicKeyRing> results =
        keyring.getKeyRings(checkNotNull(query, "query"), true, true);
    verify(results.hasNext(), "No public key found matching substring: %s", query);
    while (results.hasNext()) {
      Optional<PGPPublicKey> result = lookupPublicSubkey(results.next(), want);
      if (result.isPresent()) {
        return result.get();
      }
    }
    throw new VerifyException(String.format(
        "No public key (%s) found matching substring: %s", want, query));
  } catch (PGPException e) {
    throw new VerifyException(String.format(
        "Public key lookup with query %s failed: %s", query, e.getMessage()));
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:28,代码来源:PgpHelper.java

示例7: lookupKeyPair

import com.google.common.base.VerifyException; //导入依赖的package包/类
/**
 * Same as {@link #lookupPublicKey} but also retrieves the associated private key.
 *
 * @throws VerifyException if either keys couldn't be found.
 * @see #lookupPublicKey
 */
@SuppressWarnings("deprecation")
public static PGPKeyPair lookupKeyPair(
    PGPPublicKeyRingCollection publics,
    PGPSecretKeyRingCollection privates,
    String query,
    KeyRequirement want) {
  PGPPublicKey publicKey = lookupPublicKey(publics, query, want);
  PGPPrivateKey privateKey;
  try {
    PGPSecretKey secret = verifyNotNull(privates.getSecretKey(publicKey.getKeyID()),
        "Keyring missing private key associated with public key id: %x (query '%s')",
        publicKey.getKeyID(), query);
    // We do not support putting a password on the private key so we're just going to
    // put char[0] here.
    privateKey = secret.extractPrivateKey(
        new BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider())
            .build(new char[0]));
  } catch (PGPException e) {
    throw new VerifyException(e.getMessage());
  }
  return new PGPKeyPair(publicKey, privateKey);
}
 
开发者ID:google,项目名称:nomulus,代码行数:29,代码来源:PgpHelper.java

示例8: testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe() throws Exception {
  VerifyException thrown =
      expectThrows(
          VerifyException.class,
          () ->
              ofy()
                  .transact(
                      new VoidWork() {
                        @Override
                        public void vrun() {
                          saveRevision("despondency", DateTime.parse("1984-12-18TZ"), FULL, 1);
                        }
                      }));
  assertThat(thrown).hasMessageThat().contains("object missing");
}
 
开发者ID:google,项目名称:nomulus,代码行数:17,代码来源:RdeRevisionTest.java

示例9: testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe() throws Exception {
  save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
  VerifyException thrown =
      expectThrows(
          VerifyException.class,
          () ->
              ofy()
                  .transact(
                      new VoidWork() {
                        @Override
                        public void vrun() {
                          saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
                        }
                      }));
  assertThat(thrown).hasMessageThat().contains("object already created");
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:RdeRevisionTest.java

示例10: testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe() throws Exception {
  save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0);
  VerifyException thrown =
      expectThrows(
          VerifyException.class,
          () ->
              ofy()
                  .transact(
                      new VoidWork() {
                        @Override
                        public void vrun() {
                          saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 2);
                        }
                      }));
  assertThat(thrown).hasMessageThat().contains("should be at 1 ");
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:RdeRevisionTest.java

示例11: testPublishDomainFails_whenDnsUpdateReturnsError

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
  DomainResource domain =
      persistActiveDomain("example.tld")
          .asBuilder()
          .setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
          .build();
  persistResource(domain);
  when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
  VerifyException thrown =
      expectThrows(
          VerifyException.class,
          () -> {
            writer.publishDomain("example.tld");
            writer.commit();
          });
  assertThat(thrown).hasMessageThat().contains("SERVFAIL");
}
 
开发者ID:google,项目名称:nomulus,代码行数:19,代码来源:DnsUpdateWriterTest.java

示例12: testPublishHostFails_whenDnsUpdateReturnsError

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception {
  HostResource host =
      persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld"))
          .asBuilder()
          .setInetAddresses(ImmutableSet.of(InetAddresses.forString("10.0.0.1")))
          .build();
  persistResource(host);
  when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
  VerifyException thrown =
      expectThrows(
          VerifyException.class,
          () -> {
            writer.publishHost("ns1.example.tld");
            writer.commit();
          });
  assertThat(thrown).hasMessageThat().contains("SERVFAIL");
}
 
开发者ID:google,项目名称:nomulus,代码行数:19,代码来源:DnsUpdateWriterTest.java

示例13: testRun_errorResponse

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test
public void testRun_errorResponse() throws Exception {
  reset(connection);
  command.setConnection(connection);
  when(connection.send(
      eq(CreatePremiumListAction.PATH),
      anyMapOf(String.class, String.class),
      any(MediaType.class),
      any(byte[].class)))
          .thenReturn(
              JSON_SAFETY_PREFIX + "{\"status\":\"error\",\"error\":\"foo already exists\"}");
  VerifyException thrown =
      expectThrows(
          VerifyException.class, () -> runCommandForced("-i=" + premiumTermsPath, "-n=foo"));
  assertThat(thrown).hasMessageThat().contains("Server error:");
}
 
开发者ID:google,项目名称:nomulus,代码行数:17,代码来源:CreatePremiumListCommandTest.java

示例14: testOnDataCaseLeafFail

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test(expected = VerifyException.class)
public void testOnDataCaseLeafFail() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
        DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
    final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
            TestModel.TEST_QNAME, "choice1"));
    final YangInstanceIdentifier ii = TestModel.TEST_PATH.node(choice1Id);
    final ChoiceNode choice1 = Builders.choiceBuilder().withNodeIdentifier(choice1Id)
            .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value")).build();

    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(ii, choice1);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:18,代码来源:ConfigStatementValidationTest.java

示例15: testYangFunctionContext

import com.google.common.base.VerifyException; //导入依赖的package包/类
@Test(expected = UnresolvableException.class)
public void testYangFunctionContext() throws UnresolvableException, FunctionCallException {
    final YangFunctionContext yangFun = YangFunctionContext.getInstance();
    assertNotNull(yangFun);
    final Function function = yangFun.getFunction("urn:opendaylight.test2", null, "current");
    assertNotNull(function);

    try {
        final Context context = mock(Context.class);
        final ArrayList<Object> list = new ArrayList<>();
        function.call(context, list);
        fail();
    } catch (VerifyException e) {
        // Expected
    }

    yangFun.getFunction("urn:opendaylight.test2", "test2", "root");
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:JaxenTest.java


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