/**
  * Returns producer user to use. {@link this#resolve()} must be called before.
  *
  * @return Producer user instance
  */
 public USER resolverProducer() {
   if (producerRoleContainer.getMode() == RoleContainer.RoleMode.EXISTING_USER) {
     return userFactory.getUserByUsername(producerRoleContainer.getIdentifier());
   } else if (producerRoleContainer.getMode() == RoleContainer.RoleMode.ANONYMOUS) {
     return null;
   } else {
     return producer;
   }
 }
 /**
  * Initializes the resolver. Calling {@link this#resolve()} will actually resolve the users and
  * creates them if necessary.
  *
  * @param userFactory User factory used to create new users
  * @param roleConverter Role converter class
  * @param producer Producer identifier
  * @param consumer Consumer identifier
  */
 public UserResolver(
     UserFactory<USER, ROLE> userFactory,
     RoleConverter<ROLE> roleConverter,
     UserIdentifier producer,
     UserIdentifier consumer) {
   this.userFactory = userFactory;
   this.producerRoleContainer = RoleContainer.forProducer(producer, roleConverter);
   this.consumerRoleContainer =
       RoleContainer.forConsumer(consumer, producerRoleContainer, roleConverter);
 }
 private void initializeProducer() {
   if (producerRoleContainer.getMode() == RoleContainer.RoleMode.SET_USER_ROLE) {
     producer =
         userFactory.createUser(
             userFactory.getRandomUsername(),
             "Test",
             "Producer",
             producerRoleContainer.getRole(),
             LoginRole.PRODUCER);
   } else if (producerRoleContainer.getMode() == RoleContainer.RoleMode.EXISTING_USER) {
     // Do nothing, resolved in getter
   } else if (producerRoleContainer.getMode() == RoleContainer.RoleMode.ANONYMOUS) {
     // Do nothing, consumer is not used
   } else {
     throw new IllegalArgumentException(
         "Invalid producer consumer mode: " + producerRoleContainer.getMode());
   }
 }