Package org.waveprotocol.box.server.robots.operations

Examples of org.waveprotocol.box.server.robots.operations.OperationService


    when(robotSerializer.deserializeOperations(anyString())).thenReturn(operations);
    String responseValue = "response value";
    when(robotSerializer.serialize(any(), any(Type.class), any(ProtocolVersion.class))).thenReturn(
        responseValue);

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

    servlet.doPost(req, resp);

    verify(operationRegistry).getServiceFor(any(OperationType.class));
View Full Code Here


  public void testRegister() throws Exception {
    OperationType operationType = OperationType.BLIP_CONTINUE_THREAD;
    DoNothingService doNothingService = DoNothingService.create();
    operationAccessor.register(operationType, doNothingService);
    OperationService service = operationAccessor.getServiceFor(operationType);
    assertEquals(doNothingService, service);
  }
View Full Code Here

    hashedVersionZero = HASH_FACTORY.createVersionZero(WAVELET_NAME);
  }

  public void testapplyOperationsExecutesAndSubmitsDelta() throws Exception {
    // Use a special operation service that generates a simple delta;
    OperationService service = new OperationService() {
      @Override
      public void execute(
          OperationRequest operation, OperationContext context, ParticipantId participant)
          throws InvalidRequestException {
        context.openWavelet(WAVE_ID, WAVELET_ID, ROBOT_PARTICIPANT).addParticipant(ALEX);
View Full Code Here

    when(robotSerializer.serialize(any(), any(Type.class), any(ProtocolVersion.class))).thenReturn(
        responseValue);
    Map<String, String[]> params = getOAuthParams();
    when(req.getParameterMap()).thenReturn(params);

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

    servlet.doPost(req, resp);

    verify(validator).validateMessage(any(OAuthMessage.class), any(OAuthAccessor.class));
View Full Code Here

  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);

    verify(service).execute(operation, context, ALEX);
View Full Code Here

  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);

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

   * @param author the author of the operation.
   */
  public static void executeOperation(OperationRequest operation,
      OperationServiceRegistry operationRegistry, OperationContext context, ParticipantId author) {
    try {
      OperationService service =
          operationRegistry.getServiceFor(OperationUtil.getOperationType(operation));
      ParticipantId proxyParticipant = OperationUtil.computeParticipant(operation, author);
      service.execute(operation, context, proxyParticipant);
    } catch (InvalidRequestException e) {
      LOG.warning("Operation " + operation + " failed to execute", e);
      context.constructErrorResponse(operation, e.getMessage());
    }
  }
View Full Code Here

  public AbstractOperationServiceRegistry() {
  }

  @Override
  public final OperationService getServiceFor(OperationType opType) throws InvalidRequestException {
    OperationService service = operationMap.get(opType);
    if (service == null) {
      throw new InvalidRequestException("No OperationService found for " + opType);
    }
    return service;
  }
View Full Code Here

   * @param operation the type of the operation to register for
   * @param service the {@link OperationService} to be registered
   */
  protected final void register(OperationType operation, OperationService service) {
    // Do a put first so we can make it use a concurrent map if needed.
    OperationService oldValue = operationMap.put(operation, service);
    if (oldValue != null) {
      LOG.warning("The OperationService for " + operation.name() + " was overwritten");
    }
  }
View Full Code Here

  public AbstractOperationServiceRegistry() {
  }

  @Override
  public final OperationService getServiceFor(OperationType opType) throws InvalidRequestException {
    OperationService service = operationMap.get(opType);
    if (service == null) {
      throw new InvalidRequestException("No OperationService found for " + opType);
    }
    return service;
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.robots.operations.OperationService

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.