Compare commits

..

No commits in common. "27f03d7a0ae3c31c4ef03f2809fcddbc85508902" and "b01d313c9a6f017c52dec122c88e5cac217b92f2" have entirely different histories.

7 changed files with 2 additions and 287 deletions

View file

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>csep</groupId>
<artifactId>root</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>integration-tests</artifactId>
<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- TestFX Core -->
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.16-alpha</version>
</dependency>
<!-- TestFX JUnit5 Integration -->
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit5</artifactId>
<version>4.0.16-alpha</version>
</dependency>
<!-- Include JavaFX Dependencies -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>25.0.1</version> <!-- Update this to your required JavaFX version -->
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>25.0.1</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.1</version>
</dependency>
<dependency>
<groupId>csep</groupId>
<artifactId>commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>csep</groupId>
<artifactId>client</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>csep</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>3.5.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
<version>3.5.7</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,39 +0,0 @@
package csep;
import client.scenes.FoodpalApplicationCtrl;
import client.scenes.MainCtrl;
import client.scenes.SearchBarCtrl;
import client.scenes.recipe.IngredientListCtrl;
import client.scenes.recipe.RecipeStepListCtrl;
import client.utils.*;
import com.google.inject.AbstractModule;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
import commons.Ingredient;
import commons.Recipe;
import java.nio.file.Path;
public class TestModule implements Module {
@Override
public void configure(Binder binder) {
binder.bind(MainCtrl.class).in(Scopes.SINGLETON);
binder.bind(FoodpalApplicationCtrl.class).in(Scopes.SINGLETON);
binder.bind(IngredientListCtrl.class).in(Scopes.SINGLETON);
binder.bind(RecipeStepListCtrl.class).in(Scopes.SINGLETON);
binder.bind(SearchBarCtrl.class).in(Scopes.SINGLETON);
binder.bind(LocaleManager.class).in(Scopes.SINGLETON);
binder.bind(ServerUtils.class).in(Scopes.SINGLETON);
binder.bind(WebSocketUtils.class).in(Scopes.SINGLETON);
binder.bind(ConfigService.class).toInstance(new ConfigService(Path.of("config.json")));
binder.bind(new TypeLiteral<WebSocketDataService<Long, Recipe>>() {}).toInstance(
new WebSocketDataService<>()
);
binder.bind(new TypeLiteral<WebSocketDataService<Long, Ingredient>>() {}).toInstance(
new WebSocketDataService<>()
);
}
}

View file

@ -1,74 +0,0 @@
package csep.backlog;
import client.MyFXML;
import client.MyModule;
import client.UI;
import com.google.inject.Injector;
import commons.Recipe;
import javafx.scene.control.ListView;
import javafx.scene.input.KeyCode;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static com.google.inject.Guice.createInjector;
import static org.junit.jupiter.api.Assertions.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
import org.testfx.api.FxToolkit;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;
import server.Main;
import server.WebSocketConfig;
import server.database.IngredientRepository;
import server.database.RecipeIngredientRepository;
import server.database.RecipeRepository;
@SpringBootTest(classes = Main.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ActiveProfiles("test")
@Import(WebSocketConfig
.class)
public abstract class BaseTest extends ApplicationTest {
@Autowired
private IngredientRepository ingredientRepository;
@Autowired
private RecipeRepository recipeRepository;
@Autowired
private RecipeIngredientRepository recipeIngredientRepository;
private static final Injector INJECTOR = createInjector(new MyModule());
private static final MyFXML FXML = new MyFXML(INJECTOR);
@Autowired
protected ApplicationContext applicationContext;
protected <T> T bean(Class<T> type) {
return applicationContext.getBean(type);
}
protected <T> T bean(String name, Class<T> type) {
return applicationContext.getBean(name, type);
}
@BeforeEach
public void setup() throws Exception {
ingredientRepository.deleteAll();
recipeRepository.deleteAll();
recipeIngredientRepository.deleteAll();
ingredientRepository.flush();
recipeRepository.flush();
recipeIngredientRepository.flush();
FxToolkit.registerPrimaryStage();
FxToolkit.setupApplication(UI::new);
WaitForAsyncUtils.waitForFxEvents();
}
@AfterEach
public void tearDown() throws Exception {
FxToolkit.cleanupStages();
WaitForAsyncUtils.waitForFxEvents();
}
}

View file

@ -1,67 +0,0 @@
package csep.backlog.basic;
import commons.Recipe;
import csep.backlog.BaseTest;
import javafx.scene.control.ListView;
import javafx.scene.input.KeyCode;
import org.junit.jupiter.api.Test;
import org.testfx.util.WaitForAsyncUtils;
import server.database.RecipeRepository;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
// TODO(1): Testing for error paths
public class CRUDTest extends BaseTest {
@Test
public void newRecipeOnClickDoesAddOne() {
ListView<Recipe> list = lookup("#recipeList").query();
// when:
clickOn("#addRecipeButton");
// then:
WaitForAsyncUtils.waitForFxEvents();
assertEquals(1L, bean(RecipeRepository.class).count());
assertEquals(1, list.getItems().size());
}
@Test
public void deleteRecipeOnClickDoesDeleteOne() {
ListView<Recipe> list = lookup("#recipeList").query();
// when:
clickOn("#addRecipeButton");
WaitForAsyncUtils.waitForFxEvents();
assertEquals(1, list.getItems().size());
WaitForAsyncUtils.waitForFxEvents();
clickOn("#removeRecipeButton");
// then:
WaitForAsyncUtils.waitForFxEvents();
assertEquals(0, list.getItems().size());
}
@Test
public void changeRecipeNameDoesChangeName() {
WaitForAsyncUtils.waitForFxEvents();
ListView<Recipe> list = lookup("#recipeList").query();
clickOn("#addRecipeButton");
WaitForAsyncUtils.waitForFxEvents();
write("TEST_RECIPE");
type(KeyCode.ENTER);
WaitForAsyncUtils.waitForFxEvents();
assertEquals("TEST_RECIPE", list.getItems().get(0).getName());
}
@Test
public void cloneRecipeOnClickDoesCloneOne() {
ListView<Recipe> list = lookup("#recipeList").query();
clickOn("#addRecipeButton");
write("TEST_RECIPE");
type(KeyCode.ENTER);
WaitForAsyncUtils.waitForFxEvents();
clickOn("#cloneRecipeButton");
WaitForAsyncUtils.waitForFxEvents();
assertEquals(2, list.getItems().size());
Recipe orig = list.getItems().get(0);
Recipe cloned = list.getItems().get(1);
assertNotEquals(orig.getName(), cloned.getName());
assertEquals(orig.getPreparationSteps(), cloned.getPreparationSteps());
}
}

View file

@ -1,4 +0,0 @@
package csep.backlog.basic;
public class RecipeDetailsTest {
}

View file

@ -1,18 +0,0 @@
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# use one of these alternatives...
# ... purely in-memory, wiped on restart, but great for testing
spring.datasource.url=jdbc:h2:mem:testdb
# ... persisted on disk (in project directory)
#spring.datasource.url=jdbc:h2:file:./h2-database
# enable DB view on http://localhost:8080/h2-console
spring.h2.console.enabled=true
# strategy for table (re-)generation
spring.jpa.hibernate.ddl-auto=create-drop
# show auto-generated SQL commands
#spring.jpa.hibernate.show_sql=true

View file

@ -13,6 +13,6 @@
<module>commons</module>
<module>client</module>
<module>server</module>
<module>integration-tests</module>
</modules>
</modules>
</project>