-
Notifications
You must be signed in to change notification settings - Fork 1
Created the tests for the navbar interactor #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
src/test/java/use_case/nav_bar/NavbarInteractorTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| package use_case.nav_bar; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
Adish-Singh marked this conversation as resolved.
Adish-Singh marked this conversation as resolved.
Adish-Singh marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Test class for NavbarInteractor. | ||
| * It verifies that the interactor correctly delegates navigation requests | ||
| * to the presenter for all available views. | ||
| */ | ||
| public class NavbarInteractorTests { | ||
| /** | ||
| * Tests that switchToLogin correctly calls the presenter's switchToLogin method. | ||
| */ | ||
| @Test | ||
| void testSwitchToLogin() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToLogin(); | ||
|
|
||
| assertEquals("login", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to login view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToSignUp correctly calls the presenter's switchToSignUp method. | ||
| */ | ||
| @Test | ||
| void testSwitchToSignUp() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToSignUp(); | ||
|
|
||
| assertEquals("signup", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to signup view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToCommunity correctly calls the presenter's switchToCommunity method. | ||
| */ | ||
| @Test | ||
| void testSwitchToCommunity() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToCommunity(); | ||
|
|
||
| assertEquals("community", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to community view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToGenerateRecipe correctly calls the presenter's switchToGenerateRecipe method. | ||
| */ | ||
| @Test | ||
| void testSwitchToGenerateRecipe() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToGenerateRecipe(); | ||
|
|
||
| assertEquals("generateRecipe", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to generate recipe view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToApproveRecipe correctly calls the presenter's switchToApproveRecipe method. | ||
| */ | ||
| @Test | ||
| void testSwitchToApproveRecipe() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToApproveRecipe(); | ||
|
|
||
| assertEquals("approveRecipe", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to approve recipe view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToProfile correctly calls the presenter's switchToProfile method. | ||
| */ | ||
| @Test | ||
| void testSwitchToProfile() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToProfile(); | ||
|
|
||
| assertEquals("profile", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to profile view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToGroceryList correctly calls the presenter's switchToGroceryList method. | ||
| */ | ||
| @Test | ||
| void testSwitchToGroceryList() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToGroceryList(); | ||
|
|
||
| assertEquals("groceryList", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to grocery list view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToMealPlan correctly calls the presenter's switchToMealPlan method. | ||
| */ | ||
| @Test | ||
| void testSwitchToMealPlan() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToMealPlan(); | ||
|
|
||
| assertEquals("mealPlan", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to meal plan view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToSearchByIngredients correctly calls the presenter's switchToSearchByIngredients method. | ||
| */ | ||
| @Test | ||
| void testSwitchToSearchByIngredients() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToSearchByIngredients(); | ||
|
|
||
| assertEquals("searchByIngredients", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to search by ingredients view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that switchToLikedRecipeList correctly calls the presenter's switchToLikedRecipeList method. | ||
| */ | ||
| @Test | ||
| void testSwitchToLikedRecipeList() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToLikedRecipeList(); | ||
|
|
||
| assertEquals("likedRecipeList", presenter.getLastViewSwitched(), | ||
| "Presenter should switch to liked recipe list view."); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that multiple sequential switch calls work correctly. | ||
| * Verifies that the presenter tracks the most recent view switch. | ||
| */ | ||
| @Test | ||
| void testMultipleSwitchCallsInSequence() { | ||
| final NavbarMockPresenter presenter = new NavbarMockPresenter(); | ||
| final NavbarInteractor interactor = new NavbarInteractor(presenter); | ||
|
|
||
| interactor.switchToLogin(); | ||
| assertEquals("login", presenter.getLastViewSwitched(), | ||
| "First switch should be to login view."); | ||
|
|
||
| interactor.switchToProfile(); | ||
| assertEquals("profile", presenter.getLastViewSwitched(), | ||
| "Second switch should be to profile view."); | ||
|
|
||
| interactor.switchToCommunity(); | ||
| assertEquals("community", presenter.getLastViewSwitched(), | ||
| "Third switch should be to community view."); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package use_case.nav_bar; | ||
|
Adish-Singh marked this conversation as resolved.
|
||
|
|
||
| import use_case.nav_bar.NavbarOutputBoundary; | ||
|
Adish-Singh marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Mock implementation of NavbarOutputBoundary for testing purposes. | ||
| * Tracks which view was last switched to, allowing tests to verify | ||
| * that the interactor correctly delegates to the presenter. | ||
| */ | ||
| public class NavbarMockPresenter implements NavbarOutputBoundary { | ||
| private String lastViewSwitched = null; | ||
|
Adish-Singh marked this conversation as resolved.
|
||
|
|
||
| @Override | ||
| public void switchToLogin() { | ||
| this.lastViewSwitched = "login"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToSignUp() { | ||
| this.lastViewSwitched = "signup"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToCommunity() { | ||
| this.lastViewSwitched = "community"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToGenerateRecipe() { | ||
| this.lastViewSwitched = "generateRecipe"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToApproveRecipe() { | ||
| this.lastViewSwitched = "approveRecipe"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToProfile() { | ||
| this.lastViewSwitched = "profile"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToGroceryList() { | ||
| this.lastViewSwitched = "groceryList"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToMealPlan() { | ||
| this.lastViewSwitched = "mealPlan"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToSearchByIngredients() { | ||
| this.lastViewSwitched = "searchByIngredients"; | ||
| } | ||
|
|
||
| @Override | ||
| public void switchToLikedRecipeList() { | ||
| this.lastViewSwitched = "likedRecipeList"; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the last view that was switched to. | ||
| * @return the name of the last view switched to, or null if no switch has occurred | ||
| */ | ||
| public String getLastViewSwitched() { | ||
| return lastViewSwitched; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.