Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Teeesa7 committed Mar 20, 2024
2 parents f84e97d + 998535c commit e1f6398
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ dependencies {

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion

testImplementation 'org.mockito:mockito-core:5.11.0'

testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
}

Expand Down
47 changes: 47 additions & 0 deletions src/test/java/seedu/address/logic/MailAppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package seedu.address.logic;

import org.junit.jupiter.api.Test;

import org.mockito.MockedStatic;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static seedu.address.testutil.TypicalPersons.GEORGE;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;

import java.awt.Desktop;


public class MailAppTest {

@Test
public void handleEmailClicked_validEmail_opensMailApp() {
MailApp mailApp = new MailApp(GEORGE);
mailApp.handleEmailClicked();
}

@Test
public void handleEmailClicked_noDesktopMailApp_throwsException() {
// Create a mock object for the Desktop class
try (MockedStatic desktopMock = mockStatic(Desktop.class)) {
desktopMock.when(Desktop::isDesktopSupported).thenReturn(false);

MailApp mailApp = new MailApp(GEORGE);
assertThrows(RuntimeException.class, () -> mailApp.handleEmailClicked());
}
}

@Test
public void handleEmailClicked_noMailActionSupported_throwsException() {
try (MockedStatic<Desktop> desktopMock = mockStatic(Desktop.class)) {
Desktop desktop = mock(Desktop.class);
when(Desktop.getDesktop()).thenReturn(desktop);
when(desktop.isSupported(Desktop.Action.MAIL)).thenReturn(false);

MailApp mailApp = new MailApp(GEORGE);

assertThrows(RuntimeException.class, () -> mailApp.handleEmailClicked());
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/testutil/ContactBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ContactBuilder() {
email = new Email(DEFAULT_EMAIL);
address = new Address(DEFAULT_ADDRESS);
gitHubUsername = new GitHubUsername(DEFAULT_GITHUB_USERNAME);
techStack = new HashSet<>();
tags = new HashSet<>();
}

Expand Down Expand Up @@ -116,5 +117,4 @@ public Contact build() {
return new Contact(name, phone, email, address, gitHubUsername, techStack, tags);
}


}

0 comments on commit e1f6398

Please sign in to comment.