private PrognosisResponse createRejectedPrognosisResponse(
      String conversationID, String recipientDomain, Long prognosisSequence, String errorMessage) {
    PrognosisResponse prognosisResponse = new PrognosisResponse();

    MessageMetadata messageMetadata =
        new MessageMetadataBuilder()
            .precedence(ROUTINE)
            .messageID()
            .timeStamp()
            .conversationID(conversationID)
            .senderDomain(config.getProperty(ConfigParam.HOST_DOMAIN))
            .senderRole(USEFRole.BRP)
            .recipientDomain(recipientDomain)
            .recipientRole(USEFRole.AGR)
            .build();

    prognosisResponse.setPrognosisSequence(prognosisSequence);

    // Errors
    LOGGER.info("A-Plan rejected");
    prognosisResponse.setResult(DispositionAcceptedRejected.REJECTED);
    prognosisResponse.setMessage(errorMessage);

    prognosisResponse.setMessageMetadata(messageMetadata);

    return prognosisResponse;
  }
  @Before
  public void init() {
    controller = new FlexOfferController();
    Whitebox.setInternalState(controller, messageService);
    Whitebox.setInternalState(controller, jmsService);
    Whitebox.setInternalState(controller, corePlanboardBusinessService);
    Whitebox.setInternalState(controller, corePlanboardValidatorService);
    Whitebox.setInternalState(controller, config);

    PowerMockito.when(config.getProperty(Matchers.eq(ConfigParam.HOST_DOMAIN)))
        .thenReturn("usef-example.com");
  }
 private FlexOfferRevocationResponse buildResponse(FlexOfferRevocation flexOfferRevocation) {
   FlexOfferRevocationResponse response = new FlexOfferRevocationResponse();
   response.setSequence(flexOfferRevocation.getSequence());
   MessageMetadata metadata =
       new MessageMetadataBuilder()
           .messageID()
           .timeStamp()
           .conversationID(flexOfferRevocation.getMessageMetadata().getConversationID())
           .senderDomain(config.getProperty(ConfigParam.HOST_DOMAIN))
           .senderRole(USEFRole.DSO)
           .recipientDomain(flexOfferRevocation.getMessageMetadata().getSenderDomain())
           .recipientRole(flexOfferRevocation.getMessageMetadata().getSenderRole())
           .precedence(ROUTINE)
           .build();
   response.setMessageMetadata(metadata);
   return response;
 }
  private PrognosisResponse createPrognosisResponse(
      String congestionPoint, String conversationID, String recipientDomain, String errorMessage) {
    PrognosisResponse prognosisResponse = new PrognosisResponse();

    // Setting root attributes
    prognosisResponse.setMessage(congestionPoint);

    MessageMetadata messageMetadata =
        new MessageMetadataBuilder()
            .precedence(ROUTINE)
            .messageID()
            .timeStamp()
            .conversationID(conversationID)
            .senderDomain(config.getProperty(ConfigParam.HOST_DOMAIN))
            .senderRole(USEFRole.DSO)
            .recipientDomain(recipientDomain)
            .recipientRole(USEFRole.AGR)
            .build();

    LOGGER.info("Prognosis for {} stored", congestionPoint);

    if (errorMessage == null) {
      // No error
      prognosisResponse.setResult(DispositionAcceptedRejected.ACCEPTED);
      LOGGER.info("No error found, accepted PrognosisResponse will be sent");
    } else {
      // Errors
      LOGGER.info("Prognosis for {} rejected", congestionPoint);
      prognosisResponse.setResult(DispositionAcceptedRejected.REJECTED);
      prognosisResponse.setMessage(errorMessage);
    }

    prognosisResponse.setMessageMetadata(messageMetadata);

    return prognosisResponse;
  }