add controllers
This commit is contained in:
parent
50b50ebe0d
commit
69fef2a6c7
@ -1,43 +1,49 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
//import javax.validation.Valid;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/types")
|
||||
@RequestMapping("/appointment")
|
||||
public class AppointmentController {
|
||||
private final AppointmentService appointmentService;
|
||||
private final RequestForCooperationService requestForCooperationService;
|
||||
|
||||
|
||||
public AppointmentController(AppointmentService appointmentService, RequestForCooperationService requestForCooperationService) {
|
||||
public AppointmentController(AppointmentService appointmentService) {
|
||||
this.appointmentService = appointmentService;
|
||||
this.requestForCooperationService = requestForCooperationService;
|
||||
}
|
||||
@PostMapping
|
||||
public AppointmentDTO addAppointment(@RequestBody AppointmentDTO appointmentDTO) {
|
||||
return new AppointmentDTO(appointmentService.addAppointment(appointmentDTO));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Appointment getPost(@PathVariable Long id) {
|
||||
return appointmentService.findPost(id);
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public List<Appointment> getAllPosts() {
|
||||
return appointmentService.findAllPosts();
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public Appointment createPost(@RequestParam("Name") String name) {
|
||||
return appointmentService.addPost(name);
|
||||
@PutMapping("/{id}")
|
||||
public AppointmentDTO updateAppointment(@PathVariable Long id,@RequestBody AppointmentDTO appointmentDTO) {
|
||||
return new AppointmentDTO(appointmentService.updateAppointment(id,appointmentDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Appointment deletePost(@PathVariable Long id) {
|
||||
return appointmentService.deletePost(id);
|
||||
public AppointmentDTO removeAppointment(@PathVariable Long id) {
|
||||
return new AppointmentDTO(appointmentService.deleteAppointment(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllAppointments() {
|
||||
appointmentService.deleteAllAppointments();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public AppointmentDTO findAppointment(@PathVariable Long id) {
|
||||
return new AppointmentDTO(appointmentService.findAppointment(id));
|
||||
}
|
||||
|
||||
public List<AppointmentDTO> findAllAppointments() {
|
||||
return appointmentService.findAllAppointments()
|
||||
.stream()
|
||||
.map(AppointmentDTO::new)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
@ -14,47 +14,43 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/companies")
|
||||
@RequestMapping("/company")
|
||||
public class CompanyController {
|
||||
private final EmployeeService employeeService;
|
||||
private final RequestForCooperationService requestForCooperationService;
|
||||
private final AppointmentService appointmentService;
|
||||
private final CompanyService companyService;
|
||||
|
||||
public CompanyController(CompanyService _companyService) {
|
||||
this.companyService = _companyService;
|
||||
}
|
||||
@PostMapping
|
||||
public CompanyDTO addAppointment(@RequestBody CompanyDTO companyDTO) {
|
||||
return new CompanyDTO(companyService.addCompany(companyDTO));
|
||||
}
|
||||
|
||||
public CompanyController(CompanyService companyService, EmployeeService employeeService, RequestForCooperationService requestForCooperationService, AppointmentService appointmentService) {
|
||||
this.employeeService = employeeService;
|
||||
this.requestForCooperationService = requestForCooperationService;
|
||||
this.appointmentService = appointmentService;
|
||||
this.companyService = companyService;
|
||||
@PutMapping("/{id}")
|
||||
public CompanyDTO updateAppointment(@PathVariable Long id,@RequestBody CompanyDTO companyDTO) {
|
||||
return new CompanyDTO(companyService.updateCompany(id,companyDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public CompanyDTO removeCompany(@PathVariable Long id) {
|
||||
return new CompanyDTO(companyService.deleteCompany(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllCompanies() {
|
||||
companyService.deleteAllCompanies();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Company getCompany(@PathVariable Long id) {
|
||||
return companyService.findCompany(id);
|
||||
public CompanyDTO findCompany(@PathVariable Long id) {
|
||||
return new CompanyDTO(companyService.findCompany(id));
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public List<Company> getCompanies() {
|
||||
return companyService.findAllCompanies();
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public Company createCompany(@RequestParam("Name") String name,
|
||||
@RequestParam("legalAdressCompany") String legalAdressCompany,
|
||||
@RequestParam("adressCompany") String adressCompany,
|
||||
@RequestParam("contactEmail") String contactEmail) {
|
||||
|
||||
return companyService.addCompany(name, legalAdressCompany, adressCompany, contactEmail);
|
||||
}
|
||||
@DeleteMapping("/{id}")
|
||||
public Company deleteCompany(@PathVariable Long id) {
|
||||
return companyService.deleteCompany(id);
|
||||
}
|
||||
@GetMapping("/list={id}")
|
||||
public List<RequestForCooperation> getRequestsOfCompany(@PathVariable Long id)
|
||||
{
|
||||
return companyService.findCompany(id).getList();
|
||||
public List<CompanyDTO> findAllCompanies() {
|
||||
return companyService.findAllCompanies()
|
||||
.stream()
|
||||
.map(CompanyDTO::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,41 +35,29 @@ public class EmployeeController {
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public Employee createWorker(@RequestParam("Name") String Name,
|
||||
@RequestParam("postId") Long postId) {
|
||||
final Appointment appointment = appointmentService.findPost(postId);
|
||||
return employeeService.addWorker(Name, appointment);
|
||||
public EmployeeDTO createWorker(@RequestBody EmployeeDTO emplyeeDTO) {
|
||||
return new EmployeeDTO(employeeService.addWorker(emplyeeDTO));
|
||||
}
|
||||
|
||||
@PatchMapping("/{id}")
|
||||
public Employee updateWorker(@PathVariable Long id,
|
||||
@RequestParam("Name") String Name,
|
||||
@RequestParam("PostId") Long postId) {
|
||||
final Appointment appointment = appointmentService.findPost(postId);
|
||||
return employeeService.updateReportWorker(id, Name, appointment);
|
||||
public EmployeeDTO updateWorker(@PathVariable Long id,@RequestBody EmployeeDTO employeeDTO) {
|
||||
return new EmployeeDTO(employeeService.updateReportWorker(id, employeeDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Employee deleteWorker(@PathVariable Long id) {
|
||||
return employeeService.deleteWorker(id);
|
||||
public EmployeeDTO deleteWorker(@PathVariable Long id) {
|
||||
return new EmployeeDTO(employeeService.deleteWorker(id));
|
||||
}
|
||||
|
||||
@GetMapping("/id={id}")
|
||||
public List<RequestForCooperation> getListOfReports(@RequestParam("id") Long id) {
|
||||
var list = requestForCooperationService.findAllRequests();
|
||||
List<RequestForCooperation> listOfReports = new ArrayList<>();
|
||||
for (RequestForCooperation l :list) {
|
||||
if(l.getWorker().getId() == id)
|
||||
{
|
||||
listOfReports.add(l);
|
||||
}
|
||||
}
|
||||
return listOfReports;
|
||||
public List<RequestForCooperation> getListOfReports(@PathVariable Long id) {
|
||||
var employee = employeeService.findWorker(id);
|
||||
return employeeService.findAllRequestsOfEmployee(employee);
|
||||
}
|
||||
|
||||
@GetMapping("/postId={postId}")
|
||||
public List<Employee> getListOfWorkers(@RequestParam("postId") Long id) {
|
||||
final Appointment appointment = appointmentService.findPost(id);
|
||||
final Appointment appointment = appointmentService.findAppointment(id);
|
||||
return employeeService.findWorkerByPost(appointment);
|
||||
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class RequestForCooperationController {
|
||||
typeSotr = TypeOfRequestEnum.TRACKING;
|
||||
break;
|
||||
}
|
||||
EmployeeService employeeService = new EmployeeService(employeeRepository, appointmentRepository);
|
||||
EmployeeService employeeService = new EmployeeService(employeeRepository, appointmentRepository, requestForCooperationRepository);
|
||||
String result = "";
|
||||
for (var i : List) {
|
||||
var Worker = employeeService.findWorker(i.getWorker().getId());
|
||||
|
@ -9,6 +9,6 @@ import org.springframework.data.repository.query.Param;
|
||||
import java.util.List;
|
||||
|
||||
public interface ICompanyRepository extends JpaRepository<Company, Long> {
|
||||
@Query("SELECT DISTINCT p.requests FROM Company p where :request MEMBER OF p.requests")
|
||||
List<RequestForCooperation> getTypesRequest(@Param("request") RequestForCooperation request);
|
||||
@Query("SELECT DISTINCT p.requests FROM Company p where :company = p.id")
|
||||
List<RequestForCooperation> getRequestsOfCompany(@Param("company") Long id);
|
||||
}
|
||||
|
@ -12,4 +12,7 @@ import java.util.List;
|
||||
public interface IEmployeeRepository extends JpaRepository<Employee, Long> {
|
||||
@Query("SELECT DISTINCT p.fio FROM Employee p where :appointment = p.appointment")
|
||||
List<Employee> getEmployeeByAppointment(@Param("appointment") Appointment appointment);
|
||||
|
||||
@Query("SELECT DISTINCT p FROM RequestForCooperation p where :employee = p.sotr")
|
||||
List<RequestForCooperation> getRequestsOfEmployee(@Param("employee") Employee employee);
|
||||
}
|
||||
|
@ -1,68 +1,78 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.CompanyDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import com.example.demo.speaker.repository.ICompanyRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class CompanyService {
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
private final ICompanyRepository companyRepository;
|
||||
|
||||
public CompanyService(ICompanyRepository companyRepository) {
|
||||
this.companyRepository = companyRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Company addCompany(String nameCompany, String legalAdressCompany, String adressCompany,
|
||||
String contactEmail) {
|
||||
if (!StringUtils.hasText(nameCompany) && !StringUtils.hasText(nameCompany) &&
|
||||
!StringUtils.hasText(nameCompany) && !StringUtils.hasText(nameCompany)) {
|
||||
throw new IllegalArgumentException("One of the field is null or empty");
|
||||
}
|
||||
final Company company = new Company(nameCompany, legalAdressCompany, adressCompany, contactEmail);
|
||||
em.persist(company);
|
||||
public Company addCompany(CompanyDTO companyDTO) {
|
||||
final Company company = new Company(companyDTO.getNameCompany(),
|
||||
companyDTO.getLegalAdressCompany(),
|
||||
companyDTO.getAdressCompany(),
|
||||
companyDTO.getContactEmail());
|
||||
companyRepository.save(company);
|
||||
return company;
|
||||
}
|
||||
@Transactional
|
||||
public Company addRequest(CompanyDTO companyDTO, List<RequestForCooperation> requests){
|
||||
final Company currentCompany = findCompany(companyDTO.getId());
|
||||
currentCompany.setList((RequestForCooperation) requests);
|
||||
return currentCompany;
|
||||
}
|
||||
@Transactional
|
||||
public Company updateCompany(Long id, CompanyDTO companyDTO) {
|
||||
final Company currentCompany = findCompany(id);
|
||||
currentCompany.setNameCompany(companyDTO.getNameCompany());
|
||||
currentCompany.setAdressCompany(currentCompany.getAdressCompany());
|
||||
currentCompany.setLegalAdressCompany(currentCompany.getLegalAdressCompany());
|
||||
currentCompany.setContactEmail(currentCompany.getContactEmail());
|
||||
companyRepository.save(currentCompany);
|
||||
return currentCompany;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Company findCompany(Long id) {
|
||||
final Company company = em.find(Company.class, id);
|
||||
if (company == null) {
|
||||
throw new EntityNotFoundException(String.format("Company with id [%s] is not found", id));
|
||||
}
|
||||
return company;
|
||||
final Optional<Company> company = companyRepository.findById(id);
|
||||
return company.orElseThrow(()->new CompanyNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Company> findAllCompanies() {
|
||||
return em.createQuery("select c from Company c", Company.class)
|
||||
.getResultList();
|
||||
return companyRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Company deleteCompany(Long id) {
|
||||
final Company currentCompany = findCompany(id);
|
||||
em.remove(currentCompany);
|
||||
companyRepository.delete(currentCompany);
|
||||
return currentCompany;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllCompanies() {
|
||||
em.createQuery("delete from Company").executeUpdate();
|
||||
companyRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<RequestForCooperation> getTypesRequests(Long id, TypeOfRequestEnum type)
|
||||
public List<RequestForCooperation> getTypesRequests(Long id)
|
||||
{
|
||||
final Company comp = findCompany(id);
|
||||
var list = comp.getList();
|
||||
List<RequestForCooperation> res = list.stream().
|
||||
filter(r -> r.getType() == type).toList();
|
||||
return res;
|
||||
return companyRepository.getRequestsOfCompany(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.AppointmentDTO;
|
||||
import com.example.demo.speaker.controller.EmployeeDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.repository.IAppointmentRepository;
|
||||
import com.example.demo.speaker.repository.IEmployeeRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import com.example.demo.speaker.repository.IRequestForCooperationRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -63,6 +61,13 @@ private final IAppointmentRepository appointmentRepository;
|
||||
return list;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<RequestForCooperation> findAllRequestsOfEmployee(Employee employee)
|
||||
{
|
||||
List<RequestForCooperation> list = employeeRepository.getRequestsOfEmployee(employee);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Employee deleteWorker(Long id) {
|
||||
final Employee currentEmployee = findWorker(id);
|
||||
|
@ -23,176 +23,6 @@ import java.util.stream.Stream;
|
||||
|
||||
@SpringBootTest
|
||||
public class JPATests {
|
||||
private static final Logger log = LoggerFactory.getLogger(JPATests.class);
|
||||
private static final SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
|
||||
|
||||
@Autowired
|
||||
RequestForCooperationService requestService;
|
||||
@Autowired
|
||||
AppointmentService appointmentService;
|
||||
@Autowired
|
||||
EmployeeService employeeService;
|
||||
@Autowired
|
||||
CompanyService companyService;
|
||||
@Test
|
||||
@Transactional
|
||||
void testCompaniesReadAll() {
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final Company comp1 = companyService.addCompany("Mars", "Ульяновск, Чердаклинский район",
|
||||
"Чердаклинский район", "mars@mail.ru");
|
||||
final Company comp2 = companyService.addCompany("AIST", "Ульяновск, Кузоватовская 20",
|
||||
"Кузоватовская 20", "iast@mail.ru");
|
||||
|
||||
final List<Company> companies = companyService.findAllCompanies();
|
||||
log.info(companies.toString());
|
||||
Assertions.assertEquals(companies.size(), 3);
|
||||
}
|
||||
@Test
|
||||
void testReadCompany()
|
||||
{
|
||||
companyService.deleteAllCompanies();
|
||||
Company addCompany = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
Company comp = companyService.findCompany(addCompany.getId());
|
||||
log.info(addCompany.toString());
|
||||
Assertions.assertEquals(comp, addCompany);
|
||||
}
|
||||
@Test
|
||||
void checkConnectionCompanyAndRequest() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
RequestForCooperation report = requestService.addRequest(comp,
|
||||
formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
report = requestService.addRequest(comp,
|
||||
formatter.parse("18-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
var listRequest = comp.getList();
|
||||
Assertions.assertEquals(2, listRequest.size());
|
||||
|
||||
}
|
||||
@Test
|
||||
void checkConnectionRequestAndCompany() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
RequestForCooperation report = requestService.addRequest(comp,
|
||||
formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
report = requestService.addRequest(comp,
|
||||
formatter.parse("18-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
List<Company> listCompany = requestService.findAllRequests().
|
||||
stream().map(p -> p.getName()).toList();
|
||||
Assertions.assertEquals(1, listCompany.size());
|
||||
|
||||
}
|
||||
@Test
|
||||
void testReportCreate() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final RequestForCooperation report = requestService.addRequest(comp,
|
||||
formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
log.info(report.toString());
|
||||
Assertions.assertNotNull(report.getId());
|
||||
}
|
||||
@Test
|
||||
void testAddWorker() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final RequestForCooperation report = requestService.addRequest(comp,
|
||||
formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
final Appointment appointment = appointmentService.addPost("Manager");
|
||||
final Employee employee = employeeService.addWorker("NameWorker", appointment);
|
||||
report.setWorker(employee);
|
||||
log.info(report.toString());
|
||||
Assertions.assertNotNull(report.getWorker());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
void testReportRead() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
final Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
final RequestForCooperation report = requestService.addRequest(comp, formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
log.info(report.toString());
|
||||
final RequestForCooperation findApplication = requestService.findRequest(report.getId());
|
||||
log.info(findApplication.toString());
|
||||
Assertions.assertEquals(report, findApplication);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReportsReadNotFound() {
|
||||
requestService.deleteAllRequests();
|
||||
Assertions.assertThrows(EntityNotFoundException.class, () -> requestService.findRequest(-1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWorkerAllByPost() throws ParseException {
|
||||
employeeService.deleteAllWorkers();
|
||||
appointmentService.deleteAllvs();
|
||||
companyService.deleteAllCompanies();
|
||||
final Appointment appointment = appointmentService.addPost("Manager");
|
||||
final Employee employee = employeeService.addWorker("NAme1", appointment);
|
||||
final Employee employee1 = employeeService.addWorker("Name2", appointment);
|
||||
final List<Employee> employees = employeeService.findWorkerByPost(appointment);
|
||||
log.info(employees.toString());
|
||||
Assertions.assertEquals(2, employees.size());
|
||||
}
|
||||
@Test
|
||||
@Transactional
|
||||
void testReportsReadAll() throws ParseException {
|
||||
requestService.deleteAllRequests();
|
||||
companyService.deleteAllCompanies();
|
||||
final TypeOfRequestEnum type = TypeOfRequestEnum.TRACKING;
|
||||
final TypeOfRequestEnum typeNew = TypeOfRequestEnum.DEVELOP;
|
||||
|
||||
|
||||
Company comp = companyService.addCompany("Mars", "Ульяновск, Солнечная 19",
|
||||
"Солнечная 19", "mars@mail.ru");
|
||||
Company comp1 = companyService.addCompany("Mars", "Ульяновск, Чердаклинский район",
|
||||
"Чердаклинский район", "mars@mail.ru");
|
||||
Company comp2 = companyService.addCompany("AIST", "Ульяновск, Кузоватовская 20",
|
||||
"Кузоватовская 20", "iast@mail.ru");
|
||||
|
||||
RequestForCooperation report = requestService.addRequest(comp, formatter.parse("05-Jun-2018"),
|
||||
type, "Хотим сотрудничать");
|
||||
report = requestService.addRequest(comp1, formatter.parse("05-Jun-2019"),
|
||||
typeNew, "Хотим сотрудничать");
|
||||
report = requestService.addRequest(comp2, formatter.parse("05-Jun-2019"),
|
||||
typeNew, "Хотим сотрудничать");
|
||||
final List<RequestForCooperation> reports = requestService.findAllRequests();
|
||||
|
||||
log.info(reports.toString());
|
||||
Assertions.assertEquals(reports.size(), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReportsReadAllEmpty() {
|
||||
requestService.deleteAllRequests();
|
||||
final List<RequestForCooperation> reports = requestService.findAllRequests();
|
||||
log.info(reports.toString());
|
||||
Assertions.assertEquals(0, reports.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user