|
| 1 | +package com.securenative.models; |
| 2 | + |
| 3 | +import com.securenative.config.SecureNativeConfigurationBuilder; |
| 4 | +import com.securenative.config.SecureNativeOptions; |
| 5 | +import com.securenative.enums.EventTypes; |
| 6 | +import com.securenative.exceptions.SecureNativeInvalidOptionsException; |
| 7 | +import org.junit.jupiter.api.DisplayName; |
| 8 | +import org.junit.jupiter.api.Test; |
| 9 | + |
| 10 | + |
| 11 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 12 | + |
| 13 | +public class SDKEventTest { |
| 14 | + @Test |
| 15 | + @DisplayName("Should throw when creating sdk event invalid user-id") |
| 16 | + public void createSDKEventInvalidUserIdThrowTest() { |
| 17 | + SecureNativeOptions options = SecureNativeConfigurationBuilder.defaultConfigBuilder().build(); |
| 18 | + EventOptions event = new EventOptions(EventTypes.LOG_IN.getType()); |
| 19 | + event.setUserId(""); |
| 20 | + |
| 21 | + assertThrows(SecureNativeInvalidOptionsException.class, () -> { |
| 22 | + SDKEvent sdkEvent = new SDKEvent(event, options); |
| 23 | + }); |
| 24 | + } |
| 25 | + |
| 26 | + @Test |
| 27 | + @DisplayName("Should throw when creating sdk event without user-id") |
| 28 | + public void createSDKEventWithoutUserIdThrowTest() { |
| 29 | + SecureNativeOptions options = SecureNativeConfigurationBuilder.defaultConfigBuilder().build(); |
| 30 | + EventOptions event = new EventOptions(EventTypes.LOG_IN.getType()); |
| 31 | + |
| 32 | + assertThrows(SecureNativeInvalidOptionsException.class, () -> { |
| 33 | + SDKEvent sdkEvent = new SDKEvent(event, options); |
| 34 | + }); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + @DisplayName("Should throw when creating sdk event without event type") |
| 39 | + public void createSDKEventWithoutEventTypeThrowTest() { |
| 40 | + SecureNativeOptions options = SecureNativeConfigurationBuilder.defaultConfigBuilder().build(); |
| 41 | + EventOptions event = new EventOptions(""); |
| 42 | + |
| 43 | + assertThrows(SecureNativeInvalidOptionsException.class, () -> { |
| 44 | + SDKEvent sdkEvent = new SDKEvent(event, options); |
| 45 | + }); |
| 46 | + } |
| 47 | +} |
0 commit comments