-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw UninitilizedClientException when trying to call a directory ope…
…ration with an uninitialised client. Bump artefact version to 0.21.0 Add new constructor to DirectoryClient.
- Loading branch information
1 parent
19d2365
commit 97ca7b8
Showing
9 changed files
with
198 additions
and
109 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
187 changes: 135 additions & 52 deletions
187
src/main/java/com/aserto/directory/v3/DirectoryClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/aserto/directory/v3/UninitilizedClientException.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,7 @@ | ||
package com.aserto.directory.v3; | ||
|
||
public class UninitilizedClientException extends Exception { | ||
public UninitilizedClientException(String message) { | ||
super(message); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import com.aserto.directory.common.v3.ObjectIdentifier; | ||
import com.aserto.directory.common.v3.Relation; | ||
import com.aserto.directory.reader.v3.*; | ||
import com.aserto.directory.v3.UninitilizedClientException; | ||
import com.aserto.directory.writer.v3.DeleteRelationResponse; | ||
import com.aserto.directory.writer.v3.SetObjectResponse; | ||
import com.aserto.directory.writer.v3.SetRelationResponse; | ||
|
@@ -84,14 +85,14 @@ static void setDirectoryClient() throws SSLException { | |
} | ||
|
||
@BeforeEach | ||
void beforeEach() throws InterruptedException { | ||
void beforeEach() throws InterruptedException, UninitilizedClientException { | ||
directoryClient.setManifest(originalManifest); | ||
List<ImportElement> list = importCitadelDataList(); | ||
directoryClient.importData(list.stream()); | ||
} | ||
|
||
@AfterEach | ||
void afterEach() { | ||
void afterEach() throws UninitilizedClientException { | ||
directoryClient.deleteManifest(); | ||
} | ||
|
||
|
@@ -104,8 +105,7 @@ static void closeChannel() { | |
@Test | ||
void testDirectoryClientWithReaderCanRead() { | ||
// Arrange | ||
DirectoryClient directoryClient = new DirectoryClient(); | ||
directoryClient.withReaderChannel(channel); | ||
DirectoryClient directoryClient = new DirectoryClient(channel, null, null, null, null); | ||
|
||
// Act & Assert | ||
assertDoesNotThrow(() -> { | ||
|
@@ -116,18 +116,17 @@ void testDirectoryClientWithReaderCanRead() { | |
@Test | ||
void testDirectoryClientWithReaderCannotWrite() { | ||
// Arrange | ||
DirectoryClient directoryClient = new DirectoryClient(); | ||
directoryClient.withReaderChannel(channel); | ||
DirectoryClient directoryClient = new DirectoryClient(channel, null, null, null, null); | ||
|
||
|
||
// Act & Assert | ||
assertThrows(NullPointerException.class, () -> { | ||
assertThrows(UninitilizedClientException.class, () -> { | ||
directoryClient.setObject("test_type", "test_id"); | ||
}); | ||
} | ||
|
||
@Test | ||
void testGetUserWithNoRelations() { | ||
void testGetUserWithNoRelations() throws UninitilizedClientException { | ||
// Arrange | ||
Object managerObject = Directory.buildObject("user", "[email protected]"); | ||
|
||
|
@@ -143,7 +142,7 @@ void testGetUserWithNoRelations() { | |
} | ||
|
||
@Test | ||
void testGetUserWithRelations() { | ||
void testGetUserWithRelations() throws UninitilizedClientException { | ||
// Arrange | ||
Object managerObject = Directory.buildObject("user", "[email protected]"); | ||
Relation managerRelation = Directory.buildRelation("user", "[email protected]", "manager", "user", "[email protected]"); | ||
|
@@ -163,7 +162,7 @@ void testGetUserWithRelations() { | |
} | ||
|
||
@Test | ||
void testGetUsers() { | ||
void testGetUsers() throws UninitilizedClientException { | ||
// Arrange & Act | ||
GetObjectsResponse getObjectsResponse = directoryClient.getObjects("user"); | ||
|
||
|
@@ -172,7 +171,7 @@ void testGetUsers() { | |
} | ||
|
||
@Test | ||
void testGetUsersWithLimit() { | ||
void testGetUsersWithLimit() throws UninitilizedClientException { | ||
// Arrange & Act | ||
GetObjectsResponse getObjectsResponse = directoryClient.getObjects("user", 1, ""); | ||
|
||
|
@@ -184,7 +183,7 @@ void testGetUsersWithLimit() { | |
} | ||
|
||
@Test | ||
void testGetUserManyRequest() { | ||
void testGetUserManyRequest() throws UninitilizedClientException { | ||
// Arrange | ||
List<ObjectIdentifier> objects = List.of( | ||
Directory.buildObjectIdentifier("user", "[email protected]"), | ||
|
@@ -200,7 +199,7 @@ void testGetUserManyRequest() { | |
} | ||
|
||
@Test | ||
void testGetRelation() { | ||
void testGetRelation() throws UninitilizedClientException { | ||
// Arrange | ||
Relation expectedRelation = Directory.buildRelation("user", "[email protected]", "manager", "user", "[email protected]"); | ||
|
||
|
@@ -221,7 +220,7 @@ void testGetRelation() { | |
} | ||
|
||
@Test | ||
void testGetRelations() { | ||
void testGetRelations() throws UninitilizedClientException { | ||
// Arrange | ||
Relation expectedManagerRelation = Directory.buildRelation("user", "[email protected]", "manager", "user", "[email protected]"); | ||
Relation expectedFriendRelation = Directory.buildRelation("user", "[email protected]", "friend", "user", "[email protected]"); | ||
|
@@ -246,7 +245,7 @@ void testGetRelations() { | |
} | ||
|
||
@Test | ||
void testCheckRelationManager() { | ||
void testCheckRelationManager() throws UninitilizedClientException { | ||
// Arrange & Act | ||
CheckRelationResponse checkRelationResponse = directoryClient.checkRelation( | ||
"user", | ||
|
@@ -260,7 +259,7 @@ void testCheckRelationManager() { | |
} | ||
|
||
@Test | ||
void testCheckRelationFriend() { | ||
void testCheckRelationFriend() throws UninitilizedClientException { | ||
// Arrange & Act | ||
CheckRelationResponse checkRelationResponse = directoryClient.checkRelation( | ||
"user", | ||
|
@@ -274,7 +273,7 @@ void testCheckRelationFriend() { | |
} | ||
|
||
@Test | ||
void testCheckManager() { | ||
void testCheckManager() throws UninitilizedClientException { | ||
// Arrange & Act | ||
CheckResponse checkResponse = directoryClient.check( | ||
"user", | ||
|
@@ -317,7 +316,7 @@ void testGetGraph() { | |
} | ||
|
||
@Test | ||
void setObjectTest() { | ||
void setObjectTest() throws UninitilizedClientException { | ||
// Arrange | ||
Object object = Directory.buildObject("test_type", "test_id"); | ||
|
||
|
@@ -332,7 +331,7 @@ void setObjectTest() { | |
} | ||
|
||
@Test | ||
void deleteObjectTest() { | ||
void deleteObjectTest() throws UninitilizedClientException { | ||
// Arrange | ||
directoryClient.setObject("test_type", "test_id"); | ||
assertEquals(1, directoryClient.getObjects("test_type").getResultsList().size()); | ||
|
@@ -345,7 +344,7 @@ void deleteObjectTest() { | |
} | ||
|
||
@Test | ||
void setRelationTest() { | ||
void setRelationTest() throws UninitilizedClientException { | ||
// Arrange | ||
Relation relation = Directory.buildRelation("user", "[email protected]", "friend", "user", "[email protected]"); | ||
|
||
|
@@ -365,7 +364,7 @@ void setRelationTest() { | |
} | ||
|
||
@Test | ||
void deleteRelationTest() { | ||
void deleteRelationTest() throws UninitilizedClientException { | ||
// Arrange & Act | ||
DeleteRelationResponse deleteRelationResponse = directoryClient.deleteRelation( | ||
"user", | ||
|
@@ -388,7 +387,7 @@ void deleteRelationTest() { | |
} | ||
|
||
@Test | ||
void testGetManifest() { | ||
void testGetManifest() throws UninitilizedClientException { | ||
// Arrange & Act | ||
GetManifestResponse getManifestResponse = directoryClient.getManifest(); | ||
|
||
|
@@ -397,7 +396,7 @@ void testGetManifest() { | |
} | ||
|
||
@Test | ||
void testSetManifest() throws InterruptedException { | ||
void testSetManifest() throws InterruptedException, UninitilizedClientException { | ||
// Arrange & Act | ||
directoryClient.setManifest(modifiedManifest); | ||
GetManifestResponse getManifestResponse = directoryClient.getManifest(); | ||
|
@@ -407,7 +406,7 @@ void testSetManifest() throws InterruptedException { | |
} | ||
|
||
@Test | ||
void testDeleteManifest() { | ||
void testDeleteManifest() throws UninitilizedClientException { | ||
// Arrange & Act | ||
directoryClient.deleteManifest(); | ||
GetManifestResponse getManifestResponse = directoryClient.getManifest(); | ||
|
@@ -417,7 +416,7 @@ void testDeleteManifest() { | |
} | ||
|
||
@Test | ||
void importDataTest() throws InterruptedException { | ||
void importDataTest() throws InterruptedException, UninitilizedClientException { | ||
// Arrange | ||
List<ImportElement> list = importCitadelDataList(); | ||
List<Object> users = list.stream() | ||
|
@@ -437,7 +436,7 @@ void importDataTest() throws InterruptedException { | |
} | ||
|
||
@Test | ||
void exportDataTest() { | ||
void exportDataTest() throws UninitilizedClientException { | ||
// Arrange & Act | ||
Iterator<ExportResponse> exportedData = directoryClient.exportData(Option.OPTION_DATA); | ||
|
||
|