Skip to content

Commit 51eb9ac

Browse files
matteocarnelosgiovannivelludoCogno-Marco
committed
SMSPeerTest Fixes (#40)
* added files to .gitignore * removed modules.xml, as it was added to .gitignore * added to .gitignore all patterns present in default .gitignore generated by Android Studio * Implemented Google Library Still everything to test * Rewritten tests, fixed one class, added emulator exception * Codacy improvements * Applied suggested changes: + Added author tag (and standardized specs) * Modified parseMessage() structure * Extracted exception messages into static final fields * Extracted RegEx string into static final field * Used String.format() - Removed fail() assertions * Update README.md * Changes: + Added exception types - Removed throws clause on unchecked exceptions * Enhanced tests * Updated gradle * Test Fixes: Major fixes: * Overridden prefix auto-detection Small fixes: * Syntax and typo fixes Co-authored-by: giovannivelludo <56405609+giovannivelludo@users.noreply.github.com> Co-authored-by: Cogno-Marco <marco.cognolato.98@gmail.com>
1 parent 08f4b54 commit 51eb9ac

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

smslibrary/src/test/java/com/eis/smslibrary/SMSPeerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public class SMSPeerTest {
3939

4040
private static final String HIGHER_VALID_ADDR = "3401234568";
4141

42-
private static PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
4342
private static String[] randomValidAddresses = new String[VALID_TEST_ITERATIONS];
4443
private static String randomInvalidAddress;
4544

4645
@BeforeClass
4746
public static void setup() {
47+
PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
4848
Set<String> availableCountries = phoneNumberUtil.getSupportedRegions();
4949
String[] countryCodes = availableCountries.toArray(new String[0]);
5050
int randomIndex = new Random().nextInt(countryCodes.length);
@@ -59,6 +59,7 @@ public static void setup() {
5959
phoneNumberUtil.getExampleNumber(countryCodes[randomIndex]),
6060
PhoneNumberUtil.PhoneNumberFormat.E164);
6161
}
62+
SMSPeer.setDefaultRegion("IT");
6263
}
6364

6465
@Test
@@ -87,30 +88,30 @@ public void emptyPeer_isNotCreated() {
8788

8889
@Test
8990
public void shortPeer_isNotCreated() {
90-
try { new SMSPeer(SHORT_ADDR);}
91+
try { new SMSPeer(SHORT_ADDR); }
9192
catch(InvalidTelephoneNumberException e) {
9293
assertEquals(InvalidTelephoneNumberException.Type.INVALID_NUMBER, e.getType());
9394
}
9495
}
9596

9697
@Test
9798
public void longPeer_isNotCreated() {
98-
try { new SMSPeer(LONG_ADDR);}
99+
try { new SMSPeer(LONG_ADDR); }
99100
catch(InvalidTelephoneNumberException e) {
100101
assertEquals(InvalidTelephoneNumberException.Type.INVALID_NUMBER, e.getType());
101102
}
102103
}
103104

104105
@Test
105106
public void invalidPeer_isNotCreated() {
106-
try { new SMSPeer(randomInvalidAddress);}
107+
try { new SMSPeer(randomInvalidAddress); }
107108
catch(InvalidTelephoneNumberException e) {
108109
assertEquals(InvalidTelephoneNumberException.Type.INVALID_NUMBER, e.getType());
109110
}
110111
}
111112

112113
@Test
113-
public void validAddressed_areCompared() {
114+
public void validAddresses_areCompared() {
114115
SMSPeer lowerPeer = new SMSPeer(VALID_ADDR);
115116
SMSPeer higherPeer = new SMSPeer(HIGHER_VALID_ADDR);
116117
assertTrue(higherPeer.compareTo(lowerPeer) > 0);

0 commit comments

Comments
 (0)