title: How can I assert a header on an outgoing Mule Request with an Munit Spy
body: <p>My mule flow is making an outgoing http request using the <code>http:request</code> component. I'm using an <code>http:request-builder</code> to add headers to the request.</p>
  
  <pre><code>    &lt;http:request doc:name="unnamedImportApi"
          config-ref="HTTP_Request_Configuration"
          path="${outgoing.api.base_path}/import" method="POST"&gt;
          &lt;http:request-builder&gt;
              &lt;http:header headerName="Authorization" value="Token token=#[flowVars['api_key']]"/&gt;
          &lt;/http:request-builder&gt;
      &lt;/http:request&gt;
  </code></pre>
  
  <p>When writing tests, I'm using MUnit mocks and spies to assert the outgoing request contents.  I'm not sure how to get the values of headers in the spy though.  Eg. below I'd like to store the <strong>Authorization</strong> header with the <strong>authHeader</strong> in <strong>spyData</strong>, but am not sure how to acquire the header from the MuleMessage.</p>
  
  <pre><code>       Map&lt;String, String&gt; spyData = new HashMap&lt;&gt;();
         spyMessageProcessor("request").ofNamespace("http")
          .withAttributes(attribute("path").withValue(apiPath))
          .before(new SpyProcess() {
  
              public void spy(MuleEvent event) throws MuleException {
                  try {
                      spyData.put("payload", event.getMessage().getPayloadAsString());
                      spyData.put("contentType", ""+event.getMessage().getOutboundProperty("Content-type"));
                      spyData.put("method", ""+event.getMessage().getOutboundProperty("http.method"));
                      spyData.put("authHeader", ??????);
                  } catch (Exception e) {
                      System.err.println("ERROR - Test Spy caused exception");
                      e.printStackTrace();
                      fail("Test Spy threw exception");
                  }
              }
          });
  </code></pre>