1 package org.apache.onami.persist;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.junit.Before;
23 import org.junit.Test;
24
25 import javax.inject.Provider;
26 import javax.persistence.EntityManagerFactory;
27
28 import static org.hamcrest.CoreMatchers.sameInstance;
29 import static org.junit.Assert.assertThat;
30 import static org.mockito.Mockito.doReturn;
31 import static org.mockito.Mockito.mock;
32
33
34
35
36 public class EntityManagerFactorySourceViaProviderTest
37 {
38
39 private EntityManagerFactorySourceViaProvider sut;
40
41 private Provider<EntityManagerFactory> emfProvider;
42
43 @Before
44 @SuppressWarnings( "unchecked" )
45 public void setUp()
46 throws Exception
47 {
48 emfProvider = mock(Provider.class);
49 sut = new EntityManagerFactorySourceViaProvider( emfProvider );
50 }
51
52 @Test
53 public void shouldReturnValueFromProvider() {
54
55 EntityManagerFactory emfDummy = mock(EntityManagerFactory.class);
56 doReturn( emfDummy ).when( emfProvider ).get();
57
58 final EntityManagerFactory result = sut.getEntityManagerFactory();
59
60 assertThat(result, sameInstance(emfDummy));
61 }
62
63 }