Skip to content

Commit

Permalink
Compare Command Test
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffinsonDarmawan committed Apr 14, 2024
1 parent d204876 commit 208a704
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/team/jeffinsondarmawan.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ Code Contribution: [Jeffinson Darmawan RepoSense Report](https://nus-cs2113-ay23
3. Improving Parser class by applying FuzzyLogic.detectItem()
(Pull Request [#71](https://github.com/AY2324S2-CS2113-T11-3/tp/pull/71))
4. Wrote JUnit tests for `AddFlowerCommandTest`, `HelpTest`, `InfoCommandTest`, `ListOccasionCommandTest`,
`RemoveFlowerCommandTest`, `FuzzyLogicTest`, `ParserTest`, and wrote additional JUnit tests for `AddBouquetTest`,
`DeleteBouquetTest` which increases classes coverage from 54% to 61% and lines coverage from 29% to 50%.
`RemoveFlowerCommandTest`, `FuzzyLogicTest`, `ParserTest`, `CompareCommandTest`
and wrote additional JUnit tests for `AddBouquetTest`,
`DeleteBouquetTest` which increases classes coverage from 54% to 63% and lines coverage from 29% to 51%.

**Documentation**
1. Developer Guide
Expand Down
42 changes: 42 additions & 0 deletions src/test/java/florizz/command/CompareCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package florizz.command;

import florizz.core.FlorizzException;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

class CompareCommandTest {

@Test
void testCompareExecute() { // Comparing two different flowers
CompareCommand testCompareCommand = new CompareCommand("Rose", "Lily");
ArrayList<Bouquet> testList = new ArrayList<>();
Ui ui = new Ui();
try {
assertTrue(testCompareCommand.execute(testList, ui));
} catch (FlorizzException error) {
ui.printError(error);
}
}

@Test
void testCompareException1() { // Comparing the same flower
ArrayList<Bouquet> testList = new ArrayList<>();
Ui ui = new Ui();
CompareCommand testCompareCommand2 = new CompareCommand("Rose", "Rose");
assertThrows(FlorizzException.class, () -> testCompareCommand2.execute(testList, ui));
}

@Test
void testCompareException2() { // Comparing a flower that does not exist
ArrayList<Bouquet> testList = new ArrayList<>();
Ui ui = new Ui();
CompareCommand testCompareCommand3 = new CompareCommand("Rose", "Tulip");
assertThrows(FlorizzException.class, () -> testCompareCommand3.execute(testList, ui));
}
}

0 comments on commit 208a704

Please sign in to comment.