Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.4 kB
1
Indexable
Never
class CamelModelServiceImplTest {
    @BeforeEach
    public void setup() {
        MockitoAnnotations.openMocks(this);
    }
    @Mock
    CdoService cdoService;
    @Mock
    CDOSessionX cdoSessionX;
    @Mock
    CDOTransaction transaction;
    @Mock
    CdoServerApi cdoServerApi;
    
    @Test
    void testGetCamelModelNames() {
        ArrayList<String> stringList = new ArrayList<String>();
        when(cdoService.getAllXmi()).thenReturn(stringList);
        List<String> actualCamelModelNames = (new CamelModelServiceImpl(cdoServerApi, cdoService))
                .getCamelModelNames();
        assertSame(stringList, actualCamelModelNames);
        assertTrue(actualCamelModelNames.isEmpty());
        verify(cdoService).getAllXmi();
    }

    @Test
    void testGetCamelModel() {
        String resourceName= "";
        when(cdoServerApi.openSession()).thenReturn(cdoSessionX);
        when(cdoServerApi.openTransaction(cdoSessionX)).thenReturn(transaction);

        CamelModel actualCamelModel = (new CamelModelServiceImpl(cdoServerApi, cdoService))
                .getCamelModel(resourceName);
        assertSame(null, actualCamelModel);
        verify(cdoServerApi).openSession();
        verify(cdoServerApi).openTransaction(cdoSessionX);
        verify(cdoServerApi).getCamelModel(resourceName,transaction);

    }

}