private void testExceptionGetIds(String aggregator, String provider, String msg)
     throws Exception {
   try {
     this.userManager.getAllowedIds(aggregator, provider, "transactions");
     Assert.fail();
   } catch (RSSException e) {
     Assert.assertEquals(UNICAExceptionType.NON_ALLOWED_OPERATION, e.getExceptionType());
     Assert.assertEquals("Operation is not allowed: " + msg, e.getMessage());
   }
 }
  @Test
  public void getCurrentUserNoneExisting() throws RSSException {
    when(userDaoMock.getCurrentUser()).thenReturn(null);

    try {
      userManager.getCurrentUser();
    } catch (RSSException e) {
      assertEquals(UNICAExceptionType.NON_ALLOWED_OPERATION, e.getExceptionType());
      assertEquals("Your user is not authorized to access the RSS", e.getMessage());
    }
  }
Exemplo n.º 3
0
  /** Test method for {@link es.upm.fiware.rss.exception.RSSException#getExceptionType()}. */
  @Test
  public void testGetExceptionType() {
    Object[] args = {"Mensaje de error"};
    // Call method
    RSSException exception = new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);

    Assert.assertEquals(
        "ExceptionType not equal (" + exception.getExceptionType() + ")",
        UNICAExceptionType.NON_EXISTENT_RESOURCE_ID,
        exception.getExceptionType());
  }
 @Test
 public void throwExceptionGetAllowedIdsSingleProviderNoRoles() throws Exception {
   this.mockUserRoles();
   try {
     this.userManager.getAllowedIdsSingleProvider(
         this.aggregatorId, this.providerId, "transactions");
     Assert.fail();
   } catch (RSSException e) {
     Assert.assertEquals(UNICAExceptionType.NON_ALLOWED_OPERATION, e.getExceptionType());
     Assert.assertEquals(
         "Operation is not allowed: You are not allowed to manage transactions", e.getMessage());
   }
 }
Exemplo n.º 5
0
  /**
   * Test method for {@link
   * es.upm.fiware.rss.exception.RSSException#GRETAException(java.lang.String)}.
   */
  @Test
  public void testGRETAExceptionString() {
    String msg = "Mensaje de error";
    // Call method
    RSSException exception = new RSSException(msg);

    Assert.assertTrue(
        "Message not equal (" + exception.getMessage() + ")",
        exception.getMessage().compareTo(msg) == 0);
    Assert.assertEquals(
        "ExceptionType not equal (" + exception.getExceptionType() + ")",
        RSSExceptionType.GENERIC_EXCEPTION,
        exception.getExceptionType());
  }
Exemplo n.º 6
0
  /**
   * Test method for {@link
   * es.upm.fiware.rss.exception.RSSException#GRETAException(es.upm.fiware.rss.exception.InterfaceExceptionType,
   * java.lang.Object[])} .
   */
  @Test
  public void testGRETAExceptionInterfaceExceptionTypeObjectArray() {
    Object[] args = {"Mensaje de error"};
    // Call method
    RSSException exception = new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);

    Assert.assertTrue(
        "Message not equal (" + exception.getMessage() + ")",
        exception
                .getMessage()
                .compareTo(
                    String.format(
                        UNICAExceptionType.NON_EXISTENT_RESOURCE_ID.getFormatText(), args))
            == 0);
    Assert.assertEquals(
        "ExceptionType not equal (" + exception.getExceptionType() + ")",
        UNICAExceptionType.NON_EXISTENT_RESOURCE_ID,
        exception.getExceptionType());
  }