Clean code for junit tests …

- Added messages to JUnit assertions
- Added Description when missing
- Changed to assertThat when assertEquals

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Philip Knoblauch
2016-02-12 13:47:53 +01:00
parent d8a0a7f8e4
commit 88c854f2be
7 changed files with 190 additions and 108 deletions

View File

@@ -45,7 +45,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
/**
*
*
* Test Amqp controller authentfication.
*/
@Features("AMQP Authenfication Test")
@Stories("Tests the authenfication")
@@ -86,24 +86,34 @@ public class AmqpControllerAuthentficationTest {
amqpMessageHandlerService.setAuthenticationManager(authenticationManager);
}
@Test(expected = BadCredentialsException.class)
@Test
@Description("Tests authentication manager without principal")
public void testAuthenticationeBadCredantialsWithoutPricipal() {
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
authenticationManager.doAuthenticate(securityToken);
fail();
try {
authenticationManager.doAuthenticate(securityToken);
fail("BadCredentialsException was excepeted since principal was missing");
} catch (final BadCredentialsException exception) {
// test ok - exception was excepted
}
}
@Test(expected = BadCredentialsException.class)
@Description("Tests authentication manager without wrong credential")
@Test
@Description("Tests authentication manager without wrong credential")
public void testAuthenticationBadCredantialsWithWrongCredential() {
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
when(systemManagement.getConfigurationValue(
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any()))
.thenReturn(Boolean.TRUE);
securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLLER_ID);
authenticationManager.doAuthenticate(securityToken);
fail();
try {
authenticationManager.doAuthenticate(securityToken);
fail("BadCredentialsException was excepeted due to wrong credential");
} catch (final BadCredentialsException exception) {
// test ok - exception was excepted
}
}
@Test