View Javadoc
1   /*
2    * Copyright 2018 the original author or authors.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package org.openehealth.ipf.platform.camel.ihe.fhir.iti68;
18  
19  import org.apache.camel.CamelExecutionException;
20  import org.apache.camel.http.common.HttpOperationFailedException;
21  import org.junit.BeforeClass;
22  import org.junit.Test;
23  import org.openehealth.ipf.commons.audit.codes.EventOutcomeIndicator;
24  import org.openehealth.ipf.commons.audit.model.AuditMessage;
25  import org.openehealth.ipf.commons.audit.queue.AbstractMockedAuditMessageQueue;
26  
27  import static org.junit.Assert.assertEquals;
28  import static org.junit.Assert.assertTrue;
29  import static org.junit.Assert.fail;
30  
31  /**
32   *
33   */
34  public class TestIti68Error extends AbstractTestIti68 {
35  
36      private static final String CONTEXT_DESCRIPTOR = "iti-68-error.xml";
37  
38      @BeforeClass
39      public static void setUpClass() {
40          startServer(CONTEXT_DESCRIPTOR);
41      }
42  
43      @Test
44      public void testRetrieveDocument() {
45          try {
46              getProducerTemplate().requestBody("direct:input", null, byte[].class);
47              fail();
48          } catch (CamelExecutionException e) {
49              assertTrue(e.getCause() instanceof HttpOperationFailedException);
50  
51              // Check ATNA Audit
52              AbstractMockedAuditMessageQueue sender = getAuditSender();
53              assertEquals(1, sender.getMessages().size());
54              AuditMessage event = sender.getMessages().get(0);
55              assertEquals(
56                      EventOutcomeIndicator.MajorFailure,
57                      event.getEventIdentification().getEventOutcomeIndicator());
58          }
59      }
60  
61  
62  }