forked from authzed/authzed-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleRetryableClientTest.java
More file actions
64 lines (55 loc) · 2.15 KB
/
SimpleRetryableClientTest.java
File metadata and controls
64 lines (55 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.authzed.api.v1.ConflictStrategy;
import com.authzed.api.v1.ObjectReference;
import com.authzed.api.v1.Relationship;
import com.authzed.api.v1.RetryableClient;
import com.authzed.api.v1.SubjectReference;
import com.authzed.grpcutil.BearerToken;
import static org.junit.Assert.assertEquals;
/**
* Simple test for RetryableClient that doesn't use mocking.
* This allows us to test the basic compilation and functionality.
*/
public class SimpleRetryableClientTest {
@Test
public void testRetryableClientInitialization() {
// Create a real RetryableClient
RetryableClient client = RetryableClient.newClient(
"localhost:50051",
new BearerToken("test-token"),
true);
// If we can create the client without errors, the test passes
client.close();
}
@Test
public void testCreateRelationship() {
// Create a relationship
Relationship relationship = createTestRelationship();
// Just verify the relationship object was created correctly
assertEquals("document", relationship.getResource().getObjectType());
assertEquals("doc1", relationship.getResource().getObjectId());
assertEquals("viewer", relationship.getRelation());
assertEquals("user", relationship.getSubject().getObject().getObjectType());
assertEquals("user1", relationship.getSubject().getObject().getObjectId());
}
/**
* Helper method to create a test relationship.
*/
private Relationship createTestRelationship() {
return Relationship.newBuilder()
.setResource(ObjectReference.newBuilder()
.setObjectType("document")
.setObjectId("doc1")
.build())
.setRelation("viewer")
.setSubject(SubjectReference.newBuilder()
.setObject(ObjectReference.newBuilder()
.setObjectType("user")
.setObjectId("user1")
.build())
.build())
.build();
}
}