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


Java Data类代码示例

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


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

示例1: testGetZoneRecord

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testGetZoneRecord() throws DnsimpleException, IOException {
  Client client = mockClient(resource("getZoneRecord/success.http"));

  String accountId = "1";
  String zoneId = "example.com";
  String recordId = "2";

  GetZoneRecordResponse response = client.zones.getZoneRecord(accountId, zoneId, recordId);

  ZoneRecord record = response.getData();
  assertEquals(5, record.getId().intValue());
  assertEquals("example.com", record.getZoneId());
  assertTrue(Data.isNull(record.getParentId()));
  assertEquals("", record.getName());
  assertEquals("mxa.example.com", record.getContent());
  assertEquals(600, record.getTtl().intValue());
  assertEquals(10, record.getPriority().intValue());
  assertEquals("MX", record.getType());
  assertFalse(record.getSystemRecord());
  assertEquals("2016-10-05T09:51:35Z", record.getCreatedAt());
  assertEquals("2016-10-05T09:51:35Z", record.getUpdatedAt());
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:24,代码来源:ZoneRecordsTest.java

示例2: testInitiatePushProducesPush

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testInitiatePushProducesPush() throws DnsimpleException, IOException {
  Client client = mockClient(resource("initiatePush/success.http"));

  String accountId = "1";
  String domainId = "example.com";
  HashMap<String, Object> attributes = new HashMap<String, Object>();
  attributes.put("new_account_email", "[email protected]");

  InitiatePushResponse response = client.domains.initiatePush(accountId, domainId, attributes);
  Push push = response.getData();
  assertEquals(1, push.getId().intValue());
  assertEquals(100, push.getDomainId().intValue());
  assertTrue(Data.isNull(push.getContactId()));
  assertEquals("2016-08-11T10:16:03Z", push.getCreatedAt());
  assertEquals("2016-08-11T10:16:03Z", push.getUpdatedAt());
  assertTrue(Data.isNull(push.getAcceptedAt()));
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:19,代码来源:DomainPushesTest.java

示例3: testDownloadCertificate

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testDownloadCertificate() throws DnsimpleException, IOException {
  Client client = mockAndExpectClient("https://api.dnsimple.com/v2/1010/domains/weppos.net/certificates/1/download", HttpMethods.GET, resource("downloadCertificate/success.http"));

  String accountId = "1010";
  String domainId = "weppos.net";
  String certificateId = "1";

  DownloadCertificateResponse response = client.certificates.downloadCertificate(accountId, domainId, certificateId);

  CertificateBundle certificateBundle = response.getData();
  assertEquals(null, certificateBundle.getPrivateKey());
  assertEquals("-----BEGIN CERTIFICATE-----\nMIIE7TCCA9WgAwIBAgITAPpTe4O3vjuQ9L4gLsogi/ukujANBgkqhkiG9w0BAQsF\nADAiMSAwHgYDVQQDDBdGYWtlIExFIEludGVybWVkaWF0ZSBYMTAeFw0xNjA2MTEx\nNzQ4MDBaFw0xNjA5MDkxNzQ4MDBaMBkxFzAVBgNVBAMTDnd3dy53ZXBwb3MubmV0\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtzCcMfWoQRt5AMEY0HUb\n2GaraL1GsWOo6YXdPfe+YDvtnmDw23NcoTX7VSeCgU9M3RKs19AsCJcRNTLJ2dmD\nrAuyCTud9YTAaXQcTOLUhtO8T8+9AFVIva2OmAlKCR5saBW3JaRxW7V2aHEd/d1s\ns1CvNOO7jNppc9NwGSnDHcn3rqNv/U3MaU0gpJJRqsKkvcLU6IHJGgxyQ6AbpwJD\nIqBnzkjHu2IuhGEbRuMjyWLA2qtsjyVlfPotDxUdVouUQpz7dGHUFrLR7ma8QAYu\nOfl1ZMyrc901HGMa7zwbnFWurs3fed7vAosTRZIjnn72/3Wo7L9RiMB+vwr3NX7c\n9QIDAQABo4ICIzCCAh8wDgYD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tQO30DgNJBHX/fJEaHv6Wy8TF3J0wOGpzGbOwaTX8YAmEzC\nlzzjs+clg5MN5rd1g4POJtU=\n-----END CERTIFICATE-----\n", certificateBundle.getServerCertificate());
  assertTrue(Data.isNull(certificateBundle.getRootCertificate()));
  assertEquals(1, certificateBundle.getIntermediateCertificates().size());
  assertEquals("-----BEGIN CERTIFICATE-----\nMIIEqzCCApOgAwIBAgIRAIvhKg5ZRO08VGQx8JdhT+UwDQYJKoZIhvcNAQELBQAw\nGjEYMBYGA1UEAwwPRmFrZSBMRSBSb290IFgxMB4XDTE2MDUyMzIyMDc1OVoXDTM2\nMDUyMzIyMDc1OVowIjEgMB4GA1UEAwwXRmFrZSBMRSBJbnRlcm1lZGlhdGUgWDEw\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDtWKySDn7rWZc5ggjz3ZB0\n8jO4xti3uzINfD5sQ7Lj7hzetUT+wQob+iXSZkhnvx+IvdbXF5/yt8aWPpUKnPym\noLxsYiI5gQBLxNDzIec0OIaflWqAr29m7J8+NNtApEN8nZFnf3bhehZW7AxmS1m0\nZnSsdHw0Fw+bgixPg2MQ9k9oefFeqa+7Kqdlz5bbrUYV2volxhDFtnI4Mh8BiWCN\nxDH1Hizq+GKCcHsinDZWurCqder/afJBnQs+SBSL6MVApHt+d35zjBD92fO2Je56\ndhMfzCgOKXeJ340WhW3TjD1zqLZXeaCyUNRnfOmWZV8nEhtHOFbUCU7r/KkjMZO9\nAgMBAAGjgeMwgeAwDgYDVR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAw\nHQYDVR0OBBYEFMDMA0a5WCDMXHJw8+EuyyCm9Wg6MHoGCCsGAQUFBwEBBG4wbDA0\nBggrBgEFBQcwAYYoaHR0cDovL29jc3Auc3RnLXJvb3QteDEubGV0c2VuY3J5cHQu\nb3JnLzA0BggrBgEFBQcwAoYoaHR0cDovL2NlcnQuc3RnLXJvb3QteDEubGV0c2Vu\nY3J5cHQub3JnLzAfBgNVHSMEGDAWgBTBJnSkikSg5vogKNhcI5pFiBh54DANBgkq\nhkiG9w0BAQsFAAOCAgEABYSu4Il+fI0MYU42OTmEj+1HqQ5DvyAeyCA6sGuZdwjF\nUGeVOv3NnLyfofuUOjEbY5irFCDtnv+0ckukUZN9lz4Q2YjWGUpW4TTu3ieTsaC9\nAFvCSgNHJyWSVtWvB5XDxsqawl1KzHzzwr132bF2rtGtazSqVqK9E07sGHMCf+zp\nDQVDVVGtqZPHwX3KqUtefE621b8RI6VCl4oD30Olf8pjuzG4JKBFRFclzLRjo/h7\nIkkfjZ8wDa7faOjVXx6n+eUQ29cIMCzr8/rNWHS9pYGGQKJiY2xmVC9h12H99Xyf\nzWE9vb5zKP3MVG6neX1hSdo7PEAb9fqRhHkqVsqUvJlIRmvXvVKTwNCP3eCjRCCI\nPTAvjV+4ni786iXwwFYNz8l3PmPLCyQXWGohnJ8iBm+5nk7O2ynaPVW0U2W+pt2w\nSVuvdDM5zGv2f9ltNWUiYZHJ1mmO97jSY/6YfdOUH66iRtQtDkHBRdkNBsMbD+Em\n2TgBldtHNSJBfB3pm9FblgOcJ0FSWcUDWJ7vO0+NTXlgrRofRT6pVywzxVo6dND0\nWzYlTWeUVsO40xJqhgUQRER9YLOLxJ0O6C8i0xFxAMKOtSdodMB3RIwt7RFQ0uyt\nn5Z5MqkYhlMI3J1tPRTp1nEt9fyGspBOO05gi148Qasp+3N+svqKomoQglNoAxU=\n-----END CERTIFICATE-----", certificateBundle.getIntermediateCertificates().get(0));
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:18,代码来源:CertificatesTest.java

示例4: testGetDomain

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testGetDomain() throws DnsimpleException, IOException {
  Client client = mockClient(resource("getDomain/success.http"));

  String accountId = "1";
  String domainId = "example.com";

  GetDomainResponse response = client.domains.getDomain(accountId, domainId);

  Domain domain = response.getData();
  assertEquals(1, domain.getId().intValue());
  assertEquals(1010, domain.getAccountId().intValue());
  assertTrue(Data.isNull(domain.getRegistrantId()));
  assertEquals("example-alpha.com", domain.getName());
  assertEquals("example-alpha.com", domain.getUnicodeName());
  assertEquals("domain-token", domain.getToken());
  assertEquals("hosted", domain.getState());
  assertFalse(domain.getAutoRenew());
  assertFalse(domain.getPrivateWhois());
  assertTrue(Data.isNull(domain.getExpiresOn()));
  assertEquals("2014-12-06T15:56:55Z", domain.getCreatedAt());
  assertEquals("2015-12-09T00:20:56Z", domain.getUpdatedAt());
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:24,代码来源:DomainsTest.java

示例5: testExchangeAuthorizationForToken

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testExchangeAuthorizationForToken() throws DnsimpleException, IOException {
  String clientId = "super-client-id";
  String clientSecret = "super-client-secret";
  String code = "super-code";

  HashMap<String, Object> attributes = new HashMap<String, Object>();
  attributes.put("code", code);
  attributes.put("client_id", clientId);
  attributes.put("client_secret", clientSecret);
  attributes.put("grant_type", "authorization_code");

  Client client = mockAndExpectClient("https://api.dnsimple.com/v2/oauth/access_token", HttpMethods.POST, new HttpHeaders(), attributes, resource("oauthAccessToken/success.http"));

  OauthToken token = client.oauth.exchangeAuthorizationForToken(code, clientId, clientSecret);
  assertEquals("zKQ7OLqF5N1gylcJweA9WodA000BUNJD", token.getAccessToken());
  assertEquals("Bearer", token.getTokenType());
  assertTrue(Data.isNull(token.getScope()));
  assertEquals(1, token.getAccountId().intValue());
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:21,代码来源:OauthTest.java

示例6: testGetService

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testGetService() throws DnsimpleException, IOException {
  Client client = mockClient(resource("getService/success.http"));

  String serviceId = "1";

  GetServiceResponse response = client.services.getService(serviceId);

  Service service = response.getData();
  assertEquals(1, service.getId().intValue());
  assertEquals("Service 1", service.getName());
  assertEquals("service1", service.getShortName());
  assertEquals("First service example.", service.getDescription());
  assertTrue(Data.isNull(service.getSetupDescription()));
  assertTrue(service.getRequiresSetup());
  assertTrue(Data.isNull(service.getDefaultSubdomain()));
  assertEquals("2014-02-14T19:15:19Z", service.getCreatedAt());
  assertEquals("2016-03-04T09:23:27Z", service.getUpdatedAt());
  assertEquals(1, service.getSettings().size());
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:21,代码来源:ServicesTest.java

示例7: checkObject

import com.google.api.client.util.Data; //导入依赖的package包/类
private static Map<String, Object> checkObject(
    Object value, Map<String, Object> map, String name) {
  if (Data.isNull(value)) {
    // This is a JSON literal null.  When represented as an object, this is an
    // empty map.
    return Collections.<String, Object>emptyMap();
  }
  if (!(value instanceof Map)) {
    throw new IncorrectTypeException(name, map, "an object (not a map)");
  }
  @SuppressWarnings("unchecked")
  Map<String, Object> mapValue = (Map<String, Object>) value;
  if (!mapValue.containsKey(PropertyNames.OBJECT_TYPE_NAME)) {
    throw new IncorrectTypeException(
        name, map, "an object (no \"" + PropertyNames.OBJECT_TYPE_NAME + "\" field)");
  }
  return mapValue;
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:Structs.java

示例8: getDictionary

import com.google.api.client.util.Data; //导入依赖的package包/类
public static Map<String, Object> getDictionary(Map<String, Object> map, String name) {
  @Nullable Object value = map.get(name);
  if (value == null) {
    throw new ParameterNotFoundException(name, map);
  }
  if (Data.isNull(value)) {
    // This is a JSON literal null.  When represented as a dictionary, this is
    // an empty map.
    return Collections.<String, Object>emptyMap();
  }
  if (!(value instanceof Map)) {
    throw new IncorrectTypeException(name, map, "a dictionary");
  }
  @SuppressWarnings("unchecked")
  Map<String, Object> result = (Map<String, Object>) value;
  return result;
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:Structs.java

示例9: getScale

import com.google.api.client.util.Data; //导入依赖的package包/类
/**
 * <p>
 * <h1>Implementation Details:</h1><br>
 * Not implemented yet.
 * </p>
 *
 * @throws BQSQLException
 */
@Override
public int getScale(int column) throws SQLException {
    if (this.getColumnType(column) == java.sql.Types.DOUBLE) {
        int max = 0;
        for (int i = 0; i < this.result.getRows().size(); i++) {
            Object rowdataObject = this.result.getRows().get(i).getF().get(column - 1).getV();
            if (Data.isNull(rowdataObject)) {
                return 0;
            }
            String rowdata = (String) rowdataObject;
            if (rowdata.contains(".")) {
                int pointback = rowdata.length() - rowdata.indexOf(".");
                if (pointback > max) {
                    pointback = max;
                }
            }
        }
        return max;
    } else {
        return 0;
    }
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:31,代码来源:BQResultSetMetadata.java

示例10: extractPayload

import com.google.api.client.util.Data; //导入依赖的package包/类
private String extractPayload(HttpHeaders headers, @Nullable HttpContent content) {
  StringBuilder messageBuilder = new StringBuilder();
  if (headers != null) {
    appendMapAsString(messageBuilder, headers);
  }
  if (content != null) {
    messageBuilder.append(String.format("%nContent:%n"));
    if (content instanceof UrlEncodedContent) {
      UrlEncodedContent encodedContent = (UrlEncodedContent) content;
      appendMapAsString(messageBuilder, Data.mapOf(encodedContent.getData()));
    } else if (content != null) {
      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      try {
        content.writeTo(byteStream);
        messageBuilder.append(byteStream.toString(StandardCharsets.UTF_8.name()));
      } catch (IOException e) {
        messageBuilder.append("Unable to read request content due to exception: " + e);
      }
    }
  }
  return messageBuilder.toString();
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:23,代码来源:ReportServiceLogger.java

示例11: testExchangeAuthorizationForTokenWithOptions

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testExchangeAuthorizationForTokenWithOptions() throws DnsimpleException, IOException {
  String clientId = "super-client-id";
  String clientSecret = "super-client-secret";
  String code = "super-code";
  String state = "some-state";
  String redirectUri = "some-redirect-uri";

  HashMap<String, Object> options = new HashMap<String, Object>();
  options.put("state", state);
  options.put("redirect_uri", redirectUri);

  HashMap<String, Object> expectedAttributes = new HashMap<String, Object>();
  expectedAttributes.put("code", code);
  expectedAttributes.put("client_id", clientId);
  expectedAttributes.put("client_secret", clientSecret);
  expectedAttributes.put("grant_type", "authorization_code");
  expectedAttributes.put("state", state);
  expectedAttributes.put("redirect_uri", redirectUri);

  Client client = mockAndExpectClient("https://api.dnsimple.com/v2/oauth/access_token", HttpMethods.POST, new HttpHeaders(), expectedAttributes, resource("oauthAccessToken/success.http"));

  OauthToken token = client.oauth.exchangeAuthorizationForToken(code, clientId, clientSecret, options);
  assertEquals("zKQ7OLqF5N1gylcJweA9WodA000BUNJD", token.getAccessToken());
  assertEquals("Bearer", token.getTokenType());
  assertTrue(Data.isNull(token.getScope()));
  assertEquals(1, token.getAccountId().intValue());
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:29,代码来源:OauthTest.java

示例12: testWhoamiWithAccount

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testWhoamiWithAccount() throws DnsimpleException, IOException {
  Client client = mockClient(resource("whoami/success-account.http"));
  WhoamiResponse response = client.identity.whoami();
  Account account = response.getData().getAccount();
  assertEquals(1, account.getId().intValue());
  assertEquals("[email protected]", account.getEmail());
  assertTrue(Data.isNull(response.getData().getUser()));
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:10,代码来源:IdentityTest.java

示例13: testWhoamiWithUser

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testWhoamiWithUser() throws DnsimpleException, IOException {
  Client client = mockClient(resource("whoami/success-user.http"));
  WhoamiResponse response = client.identity.whoami();
  User user = response.getData().getUser();
  assertEquals(1, user.getId().intValue());
  assertEquals("[email protected]", user.getEmail());
  assertTrue(Data.isNull(response.getData().getAccount()));
}
 
开发者ID:dnsimple,项目名称:dnsimple-java,代码行数:10,代码来源:IdentityTest.java

示例14: testCoder_nullCell

import com.google.api.client.util.Data; //导入依赖的package包/类
@Test
public void testCoder_nullCell() throws CoderException {
  TableRow row = new TableRow();
  row.set("temperature", Data.nullOf(Object.class));
  row.set("max_temperature", Data.nullOf(Object.class));

  byte[] bytes = CoderUtils.encodeToByteArray(TableRowJsonCoder.of(), row);

  TableRow newRow = CoderUtils.decodeFromByteArray(TableRowJsonCoder.of(), bytes);
  byte[] newBytes = CoderUtils.encodeToByteArray(TableRowJsonCoder.of(), newRow);

  Assert.assertArrayEquals(bytes, newBytes);
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:BigQueryHelpersTest.java

示例15: getStrings

import com.google.api.client.util.Data; //导入依赖的package包/类
@Nullable
public static List<String> getStrings(
    Map<String, Object> map, String name, @Nullable List<String> defaultValue) {
  @Nullable Object value = map.get(name);
  if (value == null) {
    if (map.containsKey(name)) {
      throw new IncorrectTypeException(name, map, "a string or a list");
    }
    return defaultValue;
  }
  if (Data.isNull(value)) {
    // This is a JSON literal null.  When represented as a list of strings,
    // this is an empty list.
    return Collections.<String>emptyList();
  }
  @Nullable String singletonString = decodeValue(value, String.class);
  if (singletonString != null) {
    return Collections.singletonList(singletonString);
  }
  if (!(value instanceof List)) {
    throw new IncorrectTypeException(name, map, "a string or a list");
  }
  @SuppressWarnings("unchecked")
  List<Object> elements = (List<Object>) value;
  List<String> result = new ArrayList<>(elements.size());
  for (Object o : elements) {
    @Nullable String s = decodeValue(o, String.class);
    if (s == null) {
      throw new IncorrectTypeException(name, map, "a list of strings");
    }
    result.add(s);
  }
  return result;
}
 
开发者ID:apache,项目名称:beam,代码行数:35,代码来源:Structs.java


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