-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ed8397
commit 568d260
Showing
3 changed files
with
131 additions
and
26 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
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
44 changes: 44 additions & 0 deletions
44
src/test/java/gov/nist/csd/pm/pap/serialization/JSONSerializationTest.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,44 @@ | ||
package gov.nist.csd.pm.pap.serialization; | ||
|
||
import gov.nist.csd.pm.impl.memory.pap.MemoryPAP; | ||
import gov.nist.csd.pm.pap.exception.PMException; | ||
import gov.nist.csd.pm.pap.graph.relationship.AccessRightSet; | ||
import gov.nist.csd.pm.pap.query.UserContext; | ||
import gov.nist.csd.pm.pap.serialization.json.JSONDeserializer; | ||
import gov.nist.csd.pm.pap.serialization.json.JSONGraph; | ||
import gov.nist.csd.pm.pap.serialization.json.JSONPolicy; | ||
import gov.nist.csd.pm.pap.serialization.json.JSONSerializer; | ||
import gov.nist.csd.pm.util.SamplePolicy; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
public class JSONSerializationTest { | ||
|
||
@Test | ||
void testJSONSerializationDoesNotThrowNPE() throws PMException, IOException { | ||
List<JSONPolicy> policies = List.of( | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(null, new JSONGraph(), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), null, List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(), null, List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(), List.of(), null, List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(), List.of(), List.of(), null, List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(), List.of(), List.of(), List.of(), null), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(List.of(), List.of(), List.of(), List.of(), List.of()), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(null, List.of(), List.of(), List.of(), List.of()), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(List.of(), null, List.of(), List.of(), List.of()), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(List.of(), List.of(), null, List.of(), List.of()), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(List.of(), List.of(), List.of(), null, List.of()), List.of(), List.of(), List.of(), List.of()), | ||
new JSONPolicy(new AccessRightSet(), new JSONGraph(List.of(), List.of(), List.of(), List.of(), null), List.of(), List.of(), List.of(), List.of()) | ||
); | ||
|
||
for (JSONPolicy policy : policies) { | ||
assertDoesNotThrow(() -> new MemoryPAP().deserialize(new UserContext(), policy.toString(), new JSONDeserializer())); | ||
} | ||
} | ||
|
||
} |