Skip to content
Snippets Groups Projects
Commit 7079052d authored by John Watkins's avatar John Watkins
Browse files

test fixes 2

parent e41739c0
No related branches found
No related tags found
1 merge request!114LoggingService service class, new method to add a log to the "Logs" table when...
......@@ -4,6 +4,7 @@ import com.example.clientproject.data.tags.Tags;
import com.example.clientproject.data.users.Users;
import com.example.clientproject.service.LoggingService;
import com.example.clientproject.service.dtos.UsersDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
......@@ -22,6 +23,8 @@ import java.util.Map;
public class MiscQueriesImpl implements MiscQueries{
private final JdbcTemplate jdbcTemplate;
private final RowMapper<UserFavouriteTags> userFavouriteTagsRowMapper;
@Autowired
LoggingService loggingService;
/**
......
......@@ -15,6 +15,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;
......@@ -58,7 +59,7 @@ public class SelectCategoriesTests {
"", "",
LocalDateTime.now().format(formatter), twoFactorMethods);
// Save the user
miscQueries.saveUser(newUser, null);
miscQueries.saveUser(newUser, new MockHttpSession());
// Get the user as a DTO object
Optional<Users> usersOptional = usersRepo.findByUserEmail(newUser.getUserEmail());
......@@ -69,11 +70,11 @@ public class SelectCategoriesTests {
// Create a new "Tags" object with that name
Tags newTag = new Tags(tagName);
// Save a new tag with that name
miscQueries.saveTag(newTag, null);
miscQueries.saveTag(newTag, new MockHttpSession());
// Get the newly saved tag
Optional<Tags> tagsOptional = tagsRepo.findByTagName(tagName);
// Add a row to the "User_Favourite_Tags" table
miscQueries.saveUserFavouriteTags(usersOptional.get(), tagsOptional.get(), null);
miscQueries.saveUserFavouriteTags(usersOptional.get(), tagsOptional.get(), new MockHttpSession());
}
// Get the size of the table at the beginning
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment