-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test cases for validation improvement (#51)
Adding test cases for the validation improvement. Signed-off-by: Amit-Singh40 <[email protected]>
- Loading branch information
1 parent
4a67317
commit 09726e9
Showing
26 changed files
with
730 additions
and
12 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
22 changes: 22 additions & 0 deletions
22
...a-sensor-collector/src/test/java/io/pravega/sensor/collector/DeviceDriverManagerTest.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,22 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector; | ||
|
||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeviceDriverManagerTest { | ||
|
||
@Test | ||
public void testCreateDeviceDriverManagerWithNullProperties() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new DeviceDriverManager(null)); | ||
Assert.assertTrue("properties".equals(exception.getMessage())); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
pravega-sensor-collector/src/test/java/io/pravega/sensor/collector/DeviceDriverTest.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,59 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector; | ||
|
||
import io.pravega.sensor.collector.accelerometer.AccelerometerDriver; | ||
import io.pravega.sensor.collector.file.csvfile.CsvFileIngestService; | ||
import io.pravega.sensor.collector.file.parquet.ParquetFileIngestService; | ||
import io.pravega.sensor.collector.file.rawfile.RawFileIngestService; | ||
import io.pravega.sensor.collector.leap.LeapDriver; | ||
import io.pravega.sensor.collector.network.NetworkDriver; | ||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeviceDriverTest { | ||
|
||
@Test | ||
public void testCreateAccelerometerDriverWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new AccelerometerDriver(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
@Test | ||
public void testCreateLeapDriverWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new LeapDriver(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
@Test | ||
public void testCreateNetworkDriverWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new NetworkDriver(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
@Test | ||
public void testCreateCsvFileIngestServiceWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new CsvFileIngestService(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
@Test | ||
public void testCreateParquetFileIngestServiceWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new ParquetFileIngestService(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
@Test | ||
public void testCreateRawFileIngestServiceWithNullConfig() { | ||
Exception exception = Assert.assertThrows(NullPointerException.class, () -> new RawFileIngestService(null)); | ||
Assert.assertTrue("config".equals(exception.getMessage())); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
pravega-sensor-collector/src/test/java/io/pravega/sensor/collector/MockedConnection.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,46 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector; | ||
|
||
import io.pravega.sensor.collector.util.TransactionCoordinator; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import static org.mockito.Mockito.when; | ||
|
||
public abstract class MockedConnection { | ||
|
||
@Mock | ||
protected Connection mockConnection; | ||
|
||
@Mock | ||
protected Statement mockStatement; | ||
|
||
@Mock | ||
protected ResultSet mockResultSet; | ||
|
||
@Mock | ||
protected TransactionCoordinator transactionCoordinator; | ||
|
||
|
||
protected void before() throws SQLException { | ||
MockitoAnnotations.initMocks(this); | ||
when(mockConnection.createStatement()).thenReturn(mockStatement); | ||
when(mockStatement.executeQuery("select count(id) from Queue")).thenReturn(mockResultSet); | ||
when(mockResultSet.next()).thenReturn(true); | ||
} | ||
|
||
|
||
} |
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
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
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
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
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
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
Oops, something went wrong.