Skip to content

Commit

Permalink
initial pseudo unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-kan committed Aug 5, 2023
1 parent 5ea35b8 commit 432e675
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,82 @@
package d_frameworks_and_drivers.database_management.DBControllers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.ProjectModel;
import b_application_business_rules.entity_models.TaskModel;
import java.util.ArrayList;
import java.util.List;

class EntityIDsToListControllerTest {

private EntityIDsToListController controller;

@BeforeEach
void setUp() {
public void setUp() {
controller = new EntityIDsToListController();
}

@AfterEach
void tearDown() {
public void tearDown() {
// Clean up any resources, if needed
controller = null;
}

@Test
public void testEntityIDsToListWithProjectModel() {
// Create a sample project model with column models
List<ColumnModel> columnModelList = new ArrayList<>();
// columnModelList.add(new ColumnModel("Column1", "1"));
// columnModelList.add(new ColumnModel("Column2", "2"));
// columnModelList.add(new ColumnModel("Column3", "3"));
// ProjectModel projectModel = new ProjectModel("Project1", columnModelList);

// Expected concatenated column IDs
String expected = "1, 2, 3";

// Call the method to get the result
String result = controller.EntityIDsToList(projectModel);

// Assert the result
assertEquals(expected, result);
}

@Test
public void testEntityIDsToListWithColumnModel() {
// Create a sample column model with task models
List<TaskModel> taskModelList = new ArrayList<>();
// taskModelList.add(new TaskModel("Task1", "100"));
// taskModelList.add(new TaskModel("Task2", "101"));
// taskModelList.add(new TaskModel("Task3", "102"));
// ColumnModel columnModel = new ColumnModel("Column1", taskModelList);

// Expected concatenated task IDs
String expected = "100, 101, 102";

// Call the method to get the result
String result = controller.EntityIDsToList(columnModel);

// Assert the result
assertEquals(expected, result);
}

@Test
void entityIDsToList() {
public void testEntityIDsToListWithEmptyList() {
// Create an empty column model
// ColumnModel emptyColumnModel = new ColumnModel("Empty Column", new ArrayList<>());

// Expected empty string for an empty list
String expected = "";

// Call the method to get the result
String result = controller.EntityIDsToList(emptyColumnModel);

// Assert the result
assertEquals(expected, result);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,71 @@
package d_frameworks_and_drivers.database_management.DBControllers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.ProjectModel;
import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.factories.ColumnModelFactory;
import b_application_business_rules.factories.ProjectModelFactory;
import b_application_business_rules.factories.TaskModelFactory;
import d_frameworks_and_drivers.database_management.ProjectUUIDArray;
import c_interface_adapters.DBAdapterInterface;

import java.time.LocalDateTime;
import java.util.*;

class EntityIDsToModelControllerTest {

private EntityIDstoModelController controller;

@BeforeEach
void setUp() {
public void setUp() {
controller = new EntityIDstoModelController();
}

@AfterEach
void tearDown() {
public void tearDown() {
controller = null;
}

@Test
public void testIDstoProjectModelList() {
// Prepare a sample list of project UUIDs (You may need to mock ProjectUUIDArray if needed)
ArrayList<ArrayList<String>> projectListString = new ArrayList<>();
ArrayList<String> projectInfo1 = new ArrayList<>(Arrays.asList(
"a123e456-cd78-9abc-1d23-48264301b44a",
"Project 1",
"This is project 1 description",
"b123e456-cd78-9abc-1d23-48264301b44b,c123e456-cd78-9abc-1d23-48264301b44c"
));
projectListString.add(projectInfo1);



// Call the method to get the result
List<ProjectModel> result = controller.IDstoProjectModelList();

// Expected ProjectModel
UUID projectID = UUID.fromString("a123e456-cd78-9abc-1d23-48264301b44a");
String projectName = "Project 1";
String projectDescription = "This is project 1 description";
UUID column1ID = UUID.fromString("b123e456-cd78-9abc-1d23-48264301b44b");
UUID column2ID = UUID.fromString("c123e456-cd78-9abc-1d23-48264301b44c");

// Create expected ColumnModel objects
ColumnModel columnModel1 = ColumnModelFactory.create("Column 1", Collections.emptyList(), column1ID);
ColumnModel columnModel2 = ColumnModelFactory.create("Column 2", Collections.emptyList(), column2ID);

// Create expected ProjectModel object
List<ColumnModel> columnModelList = new ArrayList<>(Arrays.asList(columnModel1, columnModel2));
ProjectModel expectedProjectModel = ProjectModelFactory.create(projectName, projectID, projectDescription, columnModelList);

// Assert the result
assertEquals(1, result.size());
assertEquals(expectedProjectModel, result.get(0));
}

@Test
Expand Down

0 comments on commit 432e675

Please sign in to comment.