View Javadoc
1   package net.avcompris.examples.users3.core.tests;
2   
3   import static net.avcompris.commons3.core.tests.CoreTestUtils.defaultClock;
4   import static net.avcompris.commons3.core.tests.CoreTestUtils.grantAll;
5   import static org.junit.jupiter.api.Assertions.assertEquals;
6   import static org.junit.jupiter.api.Assertions.assertNotNull;
7   
8   import org.junit.jupiter.api.BeforeEach;
9   import org.junit.jupiter.api.Test;
10  
11  import net.avcompris.commons3.core.CorrelationService;
12  import net.avcompris.commons3.core.tests.AbstractServiceTest;
13  import net.avcompris.commons3.dao.CorrelationDao;
14  import net.avcompris.examples.shared3.core.impl.CorrelationServiceImpl;
15  
16  public abstract class AbstractCorrelationServiceTest extends AbstractServiceTest<CorrelationDao> {
17  
18  	protected CorrelationService correlationService;
19  
20  	@BeforeEach
21  	public final void setUpBeans() throws Exception {
22  
23  		final CorrelationDao correlationDao = getBeans(defaultClock());
24  
25  		correlationService = new CorrelationServiceImpl(grantAll(), defaultClock(), correlationDao);
26  	}
27  
28  	@Test
29  	public final void test_correlationIdParam() throws Exception {
30  
31  		final String correlationId = correlationService.getCorrelationId("xx", "yyy");
32  
33  		assertNotNull(correlationId);
34  
35  		assertEquals(correlationId, correlationService.getCorrelationId(correlationId, null));
36  
37  		assertEquals(correlationId, correlationService.getCorrelationId(correlationId, "yyy"));
38  	}
39  
40  	@Test
41  	public final void test_correlationIdHeader() throws Exception {
42  
43  		final String correlationId = correlationService.getCorrelationId("xx", "yyy");
44  
45  		assertNotNull(correlationId);
46  
47  		assertEquals(correlationId, correlationService.getCorrelationId(null, correlationId));
48  
49  		final String correlationId2 = correlationService.getCorrelationId("xx", correlationId);
50  
51  		assertEquals(correlationId, correlationId2);
52  	}
53  
54  	@Test
55  	public final void test_correlationId_null_null() throws Exception {
56  
57  		final String correlationId = correlationService.getCorrelationId(null, null);
58  
59  		assertNotNull(correlationId);
60  	}
61  }