@Before public void setUp() { eventListener = new AuthorizationEventListener(); service = mock(IdentificationAuthorizationService.class); when(service.isValid(INVALID_IDENTIFYING_TOKEN)).thenReturn(false); when(service.isValid(IDENTIFYING_TOKEN)).thenReturn(true); eventListener.setIdentificationAuthorizationService(service); gateway = mock(AuthorizationCommandGateway.class); eventListener.setCommandGateway(gateway); eventListener.setAddOnIdentity("1"); identityContext = new IdentityContext(new TypeBasedAddOnIdentity(ADD_ON_TYPE, "1"), new NullUserIdentity()); }