Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit b789e96

Browse files
committed
Add new method to AccountAnalytics.java
1 parent 712e610 commit b789e96

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

account-analytics/src/main/java/com.bobocode/AccountAnalytics.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ public List<Account> sortByFirstAndLastNames() {
8686
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
8787
}
8888

89+
/**
90+
* Checks if there is at least one account with provided email domain.
91+
*
92+
* @param emailDomain
93+
* @return true if there is an account that has an email with provided domain
94+
*/
95+
public boolean containsAccountWithEmailDomain(String emailDomain) {
96+
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
97+
}
98+
8999
/**
90100
* Returns a {@link Map} where key is {@link Account#lastName} and values is a {@link Set} that contains first names
91101
* of all accounts with a specific last name.
@@ -136,6 +146,5 @@ public Map<Character, Long> getCharacterFrequencyIgnoreCaseInFirstAndLastNames()
136146
throw new UnsupportedOperationException("It's your job to implement this method"); // todo
137147
}
138148

139-
140149
}
141150

account-analytics/src/test/java/com/bobocode/AccountAnalyticsTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.util.*;
1515

1616
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.assertFalse;
18+
import static org.junit.Assert.assertTrue;
1719

1820
/**
1921
* The helper method of this test class do not use Stream API intentionally. You should try to find a stream-based
@@ -118,6 +120,13 @@ public void testSortByFirstAndLastNames() {
118120

119121
}
120122

123+
@Test
124+
public void testContainsAccountWithEmailDomain() {
125+
assertTrue(analytics.containsAccountWithEmailDomain("gmail.com"));
126+
assertTrue(analytics.containsAccountWithEmailDomain("yahoo.com"));
127+
assertFalse(analytics.containsAccountWithEmailDomain("ukr.net"));
128+
}
129+
121130
@Test
122131
public void testGroupFirstNamesByLastNames() {
123132
Map<String, Set<String>> lastToFirstNamesMap = analytics.groupFirstNamesByLastNames();

0 commit comments

Comments
 (0)