/** * 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()); }
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 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()); }
@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()); } }
@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()); } }