Разные тесты с Joomla
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
public class CompanyServiceImplTest {
CompanyRepository companyRepository = mock(CompanyRepository.class);
@Test
public void getAll() {
CompanyEntity company1 = new CompanyEntity(1);
CompanyEntity company2 = new CompanyEntity(2);
when(companyRepository.findAll()).thenReturn(List.of(company1, company2));
CompanyService companyService = new CompanyServiceImpl(companyRepository);
assertEquals(2, companyService.getAll().size());
}
}
Содержимое статьи 1
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
public class CompanyServiceImplTest {
CompanyRepository companyRepository = mock(CompanyRepository.class);
}
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
public class CompanyServiceImplTest {
CompanyRepository companyRepository = mock(CompanyRepository.class);
@Test
public void getAll() {
CompanyEntity company1 = new CompanyEntity(1);
CompanyEntity company2 = new CompanyEntity(2);
when(companyRepository.findAll()).thenReturn(List.of(company1, company2));
CompanyService companyService = new CompanyServiceImpl(companyRepository);
assertEquals(2, companyService.getAll().size());
}
}