private void throwIfUserIs(User user) {
   if (SecurityUtil.getLoggedInUser().getUsername().equals(user.getUsername())) {
     throw new IllegalStateException("Thrown when user was " + user);
   }
 }
 @Test
 public void consumerLoggedIn() {
   logInAs(LoginRole.CONSUMER);
   assertThat(SecurityUtil.getLoggedInUser().getUsername(), is(getConsumer().getUsername()));
 }
 private void throwIfUserRole(String identifier) {
   User.Role identifierRole = stringToRole(UserIdentifier.parse(identifier).getIdentifier());
   if (SecurityUtil.getLoggedInUser().getRole() == identifierRole) {
     throw new IllegalStateException("Thrown when role was " + identifier);
   }
 }
 @Test
 public void producerLoggedIn() {
   assertThat(SecurityUtil.getLoggedInUser().getUsername(), is(getProducer().getUsername()));
 }