Package com.google.wave.api

Examples of com.google.wave.api.OperationRequest


    // Confirm alex is not on wave prior to operation.
    Set<ParticipantId> participants = conversation.getParticipantIds();
    assertFalse("Alex should not be a participant on wavelet prior to operation to add him.",
        participants.contains(ALEX));

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, rootBlipId,
            Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress()));

    try {
      service.execute(operation, context, ROBOT);
View Full Code Here


    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId,
            Parameter.of(ParamsProperty.PARTICIPANT_ID, MALFORMED_ADDRESS));

    try {
      service.execute(operation, context, ROBOT);
View Full Code Here

    // thread.
    conversation.getRootThread().appendBlip();

    // Append to continue the thread of the root blip
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);
    OperationRequest operation = operationRequest(OperationType.BLIP_CONTINUE_THREAD,
        rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData));

    service.execute(operation, context, ALEX);

    JsonRpcResponse response = context.getResponse(OPERATION_ID);
View Full Code Here

    waveletProvider = mock(WaveletProvider.class);
    operationRegistry = mock(OperationServiceRegistry.class);
    ConversationUtil conversationUtil = mock(ConversationUtil.class);
    converter = mock(EventDataConverter.class);

    operation = new OperationRequest("wavelet.fetch", "op1", s(WAVE_ID), s(WAVELET_ID));
    context = new OperationContextImpl(waveletProvider, converter, conversationUtil);
  }
View Full Code Here

    protocolVersion = OperationUtil.getProtocolVersion(Collections.singletonList(operation));
    assertEquals("Non notify op as first op should return default", ProtocolVersion.DEFAULT,
        protocolVersion);

    OperationRequest notifyOp = new OperationRequest(OperationType.ROBOT_NOTIFY.method(), "op1");
    protocolVersion = OperationUtil.getProtocolVersion(Collections.singletonList(notifyOp));
    assertEquals("Notify op as first op without version parameter should return default",
        ProtocolVersion.DEFAULT, protocolVersion);

    Parameter versionParameter =
        Parameter.of(ParamsProperty.PROTOCOL_VERSION, ProtocolVersion.V2_1.getVersionString());
    notifyOp = new OperationRequest(OperationType.ROBOT_NOTIFY.method(), "op1", versionParameter);
    protocolVersion = OperationUtil.getProtocolVersion(Collections.singletonList(notifyOp));
    assertEquals(
        "Notify op as first op should return its version", ProtocolVersion.V2_1, protocolVersion);
  }
View Full Code Here

        "Notify op as first op should return its version", ProtocolVersion.V2_1, protocolVersion);
  }

  public void testExecuteOperationCallsExecute() throws Exception {
    String operationId = "op1";
    OperationRequest operation = new OperationRequest("wavelet.create", operationId);

    OperationService service = mock(OperationService.class);
    when(operationRegistry.getServiceFor(any(OperationType.class))).thenReturn(service);

    OperationUtil.executeOperation(operation, operationRegistry, context, ALEX);
View Full Code Here

    verify(service).execute(operation, context, ALEX);
  }

  public void testExecuteOperationsSetsErrorOnInvalidRequestException() throws Exception {
    String operationId = "op1";
    OperationRequest operation = new OperationRequest("wavelet.create", operationId);

    OperationService service =
        mock(OperationService.class, new ThrowsException(new InvalidRequestException("")));
    when(operationRegistry.getServiceFor(any(OperationType.class))).thenReturn(service);
View Full Code Here

  }
 
  public void testComputeParticipantWithInvalidProxyFor() throws Exception {
    String invalidProxyFor = "~@#+^+";
    String participantAddress = "foo@bar.com";
    OperationRequest operation = mock(OperationRequest.class);
    when(operation.getParameter(ParamsProperty.PROXYING_FOR)).thenReturn(invalidProxyFor);
    try {
      OperationUtil.computeParticipant(operation, ParticipantId.of(participantAddress));
      fail("InvalidRequestException should be thrown.");
    } catch (InvalidRequestException e) {
      // Pass.
View Full Code Here

  }
 
  public void testComputeParticipantWithValidProxyFor() throws Exception {
    String validProxyFor = "foo";
    String participantAddress = "foo@bar.com";
    OperationRequest operation = mock(OperationRequest.class);
    when(operation.getParameter(ParamsProperty.PROXYING_FOR)).thenReturn(validProxyFor);
    try {
      OperationUtil.computeParticipant(operation, ParticipantId.of(participantAddress));
    } catch (InvalidRequestException e) {
      fail("Exception is thrown for a valid address.");
    }
View Full Code Here

            return ((JsonPrimitive) (invocation.getArguments()[0])).getAsString();
          }
        });

    OperationRequestGsonAdaptor adaptor = new OperationRequestGsonAdaptor();
    OperationRequest result = adaptor.deserialize(jsonElement, null, mockContext);
    assertEquals("op1", result.getId());
    assertEquals("wavelet.setTitle", result.getMethod());
    assertEquals("1", result.getWaveId());
    assertEquals("2", result.getWaveletId());
    assertNull(result.getBlipId());
    assertEquals(3, result.getParams().size());
    assertEquals("Title", result.getParameter(ParamsProperty.WAVELET_TITLE));
  }
View Full Code Here

TOP

Related Classes of com.google.wave.api.OperationRequest

Copyright © 2018 www.massapicom. 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.