test methods

This commit is contained in:
yannick.blanken@csc-online.eu 2022-06-01 15:24:28 +02:00
parent 9220951be6
commit 77f11bdc25
5 changed files with 46 additions and 2 deletions

View File

@ -25,6 +25,8 @@ public class CustomerService {
@Autowired
private DeviceService deviceService;
@Autowired
private CustomerVehicleRepository customerVehicleRepository;
@Autowired
@ -33,6 +35,7 @@ public class CustomerService {
public List<UserEntity> findAll() {
return userRepository.findAll();
}
@ -82,4 +85,8 @@ public class CustomerService {
return customerVehicleRepository.save(item);
}
public Optional<UserEntity> findByEmail(String email) {
return userRepository.findOneByEmail(email);
}
}

View File

@ -18,6 +18,7 @@ public class DeviceService {
@Autowired
private DeviceRepository deviceRepository;
@Autowired
private DeviceArticleRepository deviceArticleRepository;

View File

@ -1,7 +1,12 @@
package eu.csc.ODPAppVehOwnServer.web.clients;
import eu.csc.ODPAppVehOwnServer.client.clients.VehOwnAppClient;
import eu.csc.ODPAppVehOwnServer.persistence.services.CustomerService;
import eu.csc.ODPAppVehOwnServer.persistence.services.DeviceService;
import eu.csc.ODPAppVehOwnServer.persistence.services.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.security.crypto.password.PasswordEncoder;
public abstract class AbstractClientTester {
@ -11,6 +16,20 @@ public abstract class AbstractClientTester {
protected String url;
protected VehOwnAppClient client;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
protected DeviceService deviceService;
@Autowired
protected VehicleService vehicleService;
@Autowired
protected CustomerService customerService;
protected String token;
protected String user;
protected String password;
@ -20,4 +39,18 @@ public abstract class AbstractClientTester {
this.password = "yannyann1";
}
protected void setUpDevices(){
}
protected void removeDevices(){
}
protected void initUser() {
if(!customerService.findByEmail(user).isPresent())
customerService.addCustomer(user, passwordEncoder.encode(password));
}
}

View File

@ -14,6 +14,9 @@ public class CustomerClientTester extends AbstractClientTester{
@BeforeEach
void init() throws IOException {
this.initUser();
this.url = "http://localhost:" + port;
this.token = ClientFactory.authenticate(url, this.user, this.password).body().getToken();
client = ClientFactory.createVehOwnAppClient(this.url, this.token);

View File

@ -1,8 +1,8 @@
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/appvehownserver
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/appvehownserver_test
spring.datasource.username=root
spring.datasource.password=0cscadmin1
spring.datasource.driver-class-name=com.mysql.jdbc.Driver