-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test to prevent NPE when user agent string is null
- Loading branch information
1 parent
a005ba3
commit 8dc7bb0
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/java/org/signal/storageservice/util/ua/UserAgentUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.signal.storageservice.util.ua; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class UserAgentUtilTest { | ||
@Test | ||
void testGetPlatformFromUserAgentString() throws UnrecognizedUserAgentException { | ||
String userAgentString = "Signal-Android/12.35.42 Android/31"; | ||
ClientPlatform platform = UserAgentUtil.getPlatformFromUserAgentString(userAgentString); | ||
assertThat(platform).isSameAs(ClientPlatform.ANDROID); | ||
} | ||
|
||
@Test | ||
void testGetPlatformFromUserAgentString_null() { | ||
String userAgentString = null; | ||
assertThatThrownBy(() -> UserAgentUtil.getPlatformFromUserAgentString(userAgentString)).isInstanceOf(UnrecognizedUserAgentException.class); | ||
} | ||
} |