Skip to content

Comments

Feature/issue 90/spring controller unit tests#131

Merged
GerardChabaBristol merged 6 commits intodevfrom
feature/issue-90/SpringControllerUnitTests
Jan 22, 2025
Merged

Feature/issue 90/spring controller unit tests#131
GerardChabaBristol merged 6 commits intodevfrom
feature/issue-90/SpringControllerUnitTests

Conversation

@yi23484
Copy link
Contributor

@yi23484 yi23484 commented Jan 17, 2025

Issue(s):

#90

Type of change: (choose required ones)

  • New feature

Description:

Refactored SpringController class to work with dependency injection, making it easier to test.
Created unit tests for creating new user, revoking consent and creating new chats.

Additional context:

Unit tests are currently commented out until they can be tested on server.

Testing instructions:

Tests can be run seperately on Intellij IDE.

Changed Spring Controller class to better work with dependency injection, so that it can be tested more efficiently
…llerTest.java

Added unit tests for creating new users, revoking consent and creating chats
@yi23484 yi23484 added Backend Issue relates to backend code. Testing Issue relates to test-driven development. labels Jan 17, 2025
@yi23484 yi23484 linked an issue Jan 17, 2025 that may be closed by this pull request
@vladislav-k1
Copy link
Contributor

Backend fails to start, it reports the following error:
Parameter 0 of constructor in com.UoB.AILearningTool.SpringController required a bean of type 'com.UoB.AILearningTool.DatabaseController' that could not be found.

It may help to define a bean of type 'com.UoB.AILearningTool.DatabaseController' in our configuration.

@vladislav-k1
Copy link
Contributor

I think that lines 20-24 in SpringController.java cause the error.

…BaseController and OpenAIAPIController classes, backend should now start
@yi23484
Copy link
Contributor Author

yi23484 commented Jan 20, 2025

Issue should be fixed, forgot to update the annotation tag for DatabaseController and OpenAIAPIController

…he code in SpringController.Java as 3 users are generated each time createChat is called, which causes testCreateChat to fail.
…chat once. This should make the test cleaner as well as simplify the testCreateChat method. Also changed some methods in SpringController.java to prevent potential NullPointerExceptions.
@yi23484
Copy link
Contributor Author

yi23484 commented Jan 21, 2025

Tests should be fully functial now

Copy link
Contributor

@vladislav-k1 vladislav-k1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code works and makes sense.

Copy link
Collaborator

@GerardChabaBristol GerardChabaBristol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, no more errors.

@GerardChabaBristol GerardChabaBristol merged commit 5b678e8 into dev Jan 22, 2025
1 check passed
@GerardChabaBristol GerardChabaBristol deleted the feature/issue-90/SpringControllerUnitTests branch January 22, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Issue relates to backend code. Testing Issue relates to test-driven development.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make unit tests for SpringController class

3 participants