From 8309e562681e944970f2f7277d06f33258031cc7 Mon Sep 17 00:00:00 2001 From: developerDiv Date: Sun, 19 Jul 2020 15:44:48 +0100 Subject: [PATCH] Rename tests --- .../mockito/argumentcaptor/Credentials.java | 1 - .../argumentcaptor/EmailServiceUnitTest.java | 21 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/argumentcaptor/Credentials.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/argumentcaptor/Credentials.java index 5aec15505e..d5d60bb6fc 100644 --- a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/argumentcaptor/Credentials.java +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/argumentcaptor/Credentials.java @@ -6,7 +6,6 @@ public class Credentials { private final String key; public Credentials(String name, String password, String key) { - this.name = name; this.password = password; this.key = key; diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/argumentcaptor/EmailServiceUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/argumentcaptor/EmailServiceUnitTest.java index cdae118e92..2208bc7c7b 100644 --- a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/argumentcaptor/EmailServiceUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/argumentcaptor/EmailServiceUnitTest.java @@ -32,7 +32,7 @@ public class EmailServiceUnitTest { public void whenDoesNotSupportHtml_expectTextOnlyEmailFormat() { String to = "info@baeldung.com"; String subject = "Using ArgumentCaptor"; - String body = "Article on using ArgumentCaptor"; + String body = "Hey, let'use ArgumentCaptor"; emailService.send(to, subject, body, false); @@ -42,10 +42,10 @@ public class EmailServiceUnitTest { } @Test - public void send_whenDoesSupportHtml_expectHTMLEmailFormat() { - String to = "baeldung@baeldung.com"; - String subject = "Great New Course!"; - String body = "Try out our new course."; + public void whenDoesSupportHtml_expectHTMLEmailFormat() { + String to = "info@baeldung.com"; + String subject = "Using ArgumentCaptor"; + String body = "Hey, let'use ArgumentCaptor"; emailService.send(to, subject, body, true); @@ -55,7 +55,7 @@ public class EmailServiceUnitTest { } @Test - public void getServiceStatus_whenServiceRunning_expectUpResponse() { + public void whenServiceRunning_expectUpResponse() { when(platform.getServiceStatus()).thenReturn("OK"); ServiceStatus serviceStatus = emailService.checkServiceStatus(); @@ -64,7 +64,7 @@ public class EmailServiceUnitTest { } @Test - public void getServiceStatus_whenServiceNotRunning_expectDownResponse() { + public void whenServiceNotRunning_expectDownResponse() { when(platform.getServiceStatus()).thenReturn("Error"); ServiceStatus serviceStatus = emailService.checkServiceStatus(); @@ -73,7 +73,7 @@ public class EmailServiceUnitTest { } @Test - public void usingArgumemtMatcher_whenAuthenticatedWithValidCredentials_expectTrue() { + public void usingArgumentMatcher_whenAuthenticatedWithValidCredentials_expectTrue() { Credentials credentials = new Credentials("baeldung", "correct_password", "correct_key"); when(platform.authenticate(eq(credentials))).thenReturn(AuthenticationStatus.AUTHENTICATED); @@ -90,11 +90,10 @@ public class EmailServiceUnitTest { } @Test - public void authenticate_whenNotAuthenticated_expectFalse() { + public void whenNotAuthenticated_expectFalse() { Credentials credentials = new Credentials("baeldung", "incorrect_password", "incorrect_key"); - when(platform.authenticate(credentialsCaptor.capture())).thenReturn(AuthenticationStatus.NOT_AUTHENTICATED); + when(platform.authenticate(eq(credentials))).thenReturn(AuthenticationStatus.NOT_AUTHENTICATED); assertFalse(emailService.authenticatedSuccessfully(credentials)); - assertEquals(credentials, credentialsCaptor.getValue()); } } \ No newline at end of file