Examples of GsonFactory


Examples of com.google.api.client.json.gson.GsonFactory

  private final static String CLIENT_SECRETS = "{\"installed\": {\"client_id\": \"" + CLIENT_ID
      + "\",\"client_secret\": \"" + CLIENT_SECRET + "\"}}";

  public void testLoad() throws Exception {
    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(new GsonFactory(), new StringReader(CLIENT_SECRETS));
    Details installed = clientSecrets.getInstalled();
    assertNotNull(installed);
    assertEquals(CLIENT_ID, installed.getClientId());
    assertEquals(CLIENT_SECRET, installed.getClientSecret());
  }
View Full Code Here

Examples of com.google.api.client.json.gson.GsonFactory

    this.clientTokenPath = Paths.get(googleDriveOptions.getClientTokenPath());

    try {
      final String clientTokenAsJson = Files.exists(this.clientTokenPath) ? FileUtils.readFileToString(this.clientTokenPath.toFile()) : null;

      credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()).setJsonFactory(new GsonFactory())
          .setClientSecrets(googleDriveOptions.getClientID(), googleDriveOptions.getClientSecret()).build();

      if (StringUtils.isEmpty(clientTokenAsJson)) {

        final String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URL).build();
View Full Code Here

Examples of com.google.wave.api.impl.GsonFactory

    EventMessageBundle bundle = new EventMessageBundle("Foo", "http://gmodules.com/api/rpc");
    bundle.addEvent(event1);
    bundle.addEvent(event2);
    bundle.addEvent(event3);
    bundle.setWaveletData(waveletData);
    String json = new GsonFactory().create().toJson(bundle);

    MockWriter mockWriter = new MockWriter();
    robot.doPost(
        makeMockRequest(JSONRPC_PATH, new BufferedReader(new StringReader(json))),
        makeMockResponse(mockWriter));
View Full Code Here

Examples of com.google.wave.api.impl.GsonFactory

  @Provides
  @Singleton
  @Inject
  RobotSerializer provideRobotSerializer() {
    NavigableMap<ProtocolVersion, Gson> gsons = Maps.newTreeMap();
    Gson gsonForPostV2 = new GsonFactory().create();
    gsons.put(ProtocolVersion.V2_2, gsonForPostV2);
    // Remove lines below if we want to stop support for <0.22
    gsons.put(ProtocolVersion.V2_1, gsonForPostV2);

    GsonFactory factoryForV2 = new GsonFactory();
    ElementGsonAdaptorV2 elementGsonAdaptorV2 = new ElementGsonAdaptorV2();
    factoryForV2.registerTypeAdapter(Element.class, elementGsonAdaptorV2);
    factoryForV2.registerTypeAdapter(Attachment.class, elementGsonAdaptorV2);
    gsons.put(ProtocolVersion.V2, factoryForV2.create());

    return new RobotSerializer(gsons, ProtocolVersion.DEFAULT);
  }
View Full Code Here

Examples of com.google.wave.api.impl.GsonFactory

    EventMessageBundle bundle = new EventMessageBundle("Foo", "http://gmodules.com/api/rpc");
    bundle.addEvent(event1);
    bundle.addEvent(event2);
    bundle.addEvent(event3);
    bundle.setWaveletData(waveletData);
    String json = new GsonFactory().create().toJson(bundle);

    MockWriter mockWriter = new MockWriter();
    robot.doPost(
        makeMockRequest(JSONRPC_PATH, new BufferedReader(new StringReader(json))),
        makeMockResponse(mockWriter));
View Full Code Here

Examples of com.google.wave.api.impl.GsonFactory

  @Provides
  @Singleton
  @Inject
  RobotSerializer provideRobotSerializer() {
    NavigableMap<ProtocolVersion, Gson> gsons = Maps.newTreeMap();
    Gson gsonForPostV2 = new GsonFactory().create();
    gsons.put(ProtocolVersion.V2_2, gsonForPostV2);
    // Remove lines below if we want to stop support for <0.22
    gsons.put(ProtocolVersion.V2_1, gsonForPostV2);

    GsonFactory factoryForV2 = new GsonFactory();
    ElementGsonAdaptorV2 elementGsonAdaptorV2 = new ElementGsonAdaptorV2();
    factoryForV2.registerTypeAdapter(Element.class, elementGsonAdaptorV2);
    factoryForV2.registerTypeAdapter(Attachment.class, elementGsonAdaptorV2);
    gsons.put(ProtocolVersion.V2, factoryForV2.create());

    return new RobotSerializer(gsons, ProtocolVersion.DEFAULT);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.