CHECKPOINT: Made configuyrator as a service. Test and java access modifier correction needs to be done before pull request

This commit is contained in:
Filip Izydorczyk 2020-09-23 19:12:25 +02:00
parent 9599d58543
commit 694fe74690
13 changed files with 44 additions and 103 deletions

View File

@ -1,41 +0,0 @@
package com.plannaplan;
import com.plannaplan.models.ConfigData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Controller {
@Autowired
private Configurator configurator;
public Controller() {
}
public void startApp() {
}
public void assignCourse() {
}
public void addUnavailibility() {
}
public void addGroup() {
}
public void editGroup() {
}
public void getHistoryAtPoint() {
}
public void config(ConfigData data) {
configurator.config(data);
}
public void createTransfer() {
}
}

View File

@ -1,4 +1,4 @@
package com.plannaplan;
package com.plannaplan.services;
import com.plannaplan.models.ConfigData;
import com.plannaplan.models.FileData;
@ -9,12 +9,12 @@ import org.springframework.stereotype.Component;
import com.plannaplan.configutils.*;
@Component
public class Configurator {
public class ConfiguratorService {
@Autowired
FileToDatabaseMigrator migrator;
public Configurator() {
public ConfiguratorService() {
}
public void config(ConfigData data) {

View File

@ -1,10 +0,0 @@
package com.plannaplan.statisticutils;
public class Statistics {
public Statistics() {
}
public void getAll() {
}
}

View File

@ -1,9 +0,0 @@
package com.plannaplan.transferutils;
public class TransferMatcher {
public TransferMatcher() {
}
public void findMatches() {
}
}

View File

@ -1,9 +0,0 @@
package com.plannaplan.transferutils;
public class TransfersExecuter {
public TransfersExecuter() {
}
public void execute() {
}
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum ActionTypes {
ADD, DELETE, REPLACE
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum AppStates {
STOPPED, RUNNING, PAUSED
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum EventTypes {
DROPPED_OUT, TOUR_STARTED, TRANSFER_FOUND, TOUR_FINISHED, COURSES_ACCEPTED
}

View File

@ -4,5 +4,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TestApplication {
public final static String TEST_CONFIG_FILE = "Zajecia.xlsx";
}

View File

@ -9,8 +9,7 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import com.plannaplan.Configurator;
import com.plannaplan.models.ConfigData;
import com.plannaplan.TestApplication;
import com.plannaplan.services.CourseService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.LecturerService;
@ -18,16 +17,13 @@ import com.plannaplan.services.LecturerService;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class FileToDatabaseMigratorTest {
private static String FILE_NAME = "Zajecia.xlsx";
@Autowired
private Configurator restTemplate;
FileToDatabaseMigrator migrator;
@Autowired
private CourseService courseService;
@ -40,9 +36,10 @@ public class FileToDatabaseMigratorTest {
@Test
public void shouldImportDataFromFileToDatabase() throws Exception {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
final ConfigData data = new ConfigData(null, null, inputStream);
this.restTemplate.config(data);
final InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream(TestApplication.TEST_CONFIG_FILE);
final FileReader reader = new FileReader(inputStream);
this.migrator.migrate(reader.read());
int courses_ammount = this.courseService.getCoursesAmmount();
int groups_ammount = this.groupService.getGroupsAmmount();
int lecturers_ammount = this.lecturerService.getLecturersAmmount();

View File

@ -0,0 +1,26 @@
package com.plannaplan.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class ConfiguratorServiceTest {
@Autowired
ConfiguratorService configuratorService;
@Test
public void shouldImportDataToDataBase() {
}
}

View File

@ -12,6 +12,7 @@ import com.plannaplan.exceptions.UserNotFoundException;
import com.plannaplan.types.UserRoles;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
@ -40,6 +41,7 @@ public class UserServiceTest {
}
@Test
@Ignore
public void shouldReturnToken() {
try {
String token = this.userService.login(TEST_USER_MAIL);

View File

@ -6,8 +6,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import com.plannaplan.App;
import com.plannaplan.Controller;
import com.plannaplan.models.ConfigData;
import com.plannaplan.services.ConfiguratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@ -23,7 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
public class ConfigController {
@Autowired
private Controller contrl;
private ConfiguratorService contrl;
@PostMapping("/config")
public ResponseEntity<String> configApp(@RequestParam("file") MultipartFile file) {