Ejemplo n.º 1
0
  /**
   * Tests the publish method with invalid input parameters
   *
   * @throws HubException
   */
  @Test
  public void testPublishInvalidInputs() throws HubException {
    errors.add("Error string");
    when(hubValidator.validatePing(mode, url)).thenReturn(errors);
    try {
      controller.publish(mode, url);
    } catch (RestException e) {
      HubErrors he = e.getHubException().getError();
      assertEquals(1001, he.getCode());
      assertEquals(HttpStatus.BAD_REQUEST, he.getHttpStatus());
      assertEquals("One or more input parameter(s) may be wrong", he.getMessage());
    }

    verify(hubValidator).validatePing(mode, url);
  }
Ejemplo n.º 2
0
  /**
   * Tests the subscribe method with invalid input parameters
   *
   * @throws HubException
   */
  @Test
  public void testSubscribeInvalidInputs() throws HubException {
    errors.add("Error string");
    when(hubValidator.validateSubscription(callbackUrl, mode, topic, leaseSeconds, secret))
        .thenReturn(errors);
    try {
      controller.subscribe(callbackUrl, mode, topic, leaseSeconds, secret);
    } catch (RestException e) {
      HubErrors he = e.getHubException().getError();
      assertEquals(1001, he.getCode());
      assertEquals(HttpStatus.BAD_REQUEST, he.getHttpStatus());
      assertEquals("One or more input parameter(s) may be wrong", he.getMessage());
    }

    verify(hubValidator).validateSubscription(callbackUrl, mode, topic, leaseSeconds, secret);
  }