From f804205c73fbdf0934bedae4ee7e8615ab5baaaf Mon Sep 17 00:00:00 2001 From: NOIR Nicolas ext Date: Wed, 9 Oct 2019 16:40:51 +0200 Subject: [PATCH] Addition of unit tests and correction of parameters names in requests (#827) Signed-off-by: NOIR Nicolas ext --- .../com/powsybl/afs/storage/AbstractAppStorageTest.java | 6 ++++++ .../java/com/powsybl/afs/ws/server/AppStorageServer.java | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java index 9d4feddb108..147b44f0262 100644 --- a/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java +++ b/afs/afs-storage-api/src/test/java/com/powsybl/afs/storage/AbstractAppStorageTest.java @@ -140,6 +140,10 @@ public void test() throws IOException, InterruptedException { assertEquals("", storage.getNodeInfo(testFolderInfo.getId()).getDescription()); assertTrue(storage.getNodeInfo(testFolderInfo.getId()).getCreationTime() > 0); assertTrue(storage.getNodeInfo(testFolderInfo.getId()).getModificationTime() > 0); + assertEquals(testFolderInfo.getAccessRights(), storage.getNodeInfo(testFolderInfo.getId()).getAccessRights()); + assertEquals(Collections.singletonMap("user1", 6), storage.getNodeInfo(testFolderInfo.getId()).getAccessRights().getUsersRights()); + assertTrue(storage.getNodeInfo(testFolderInfo.getId()).getAccessRights().getGroupsRights().isEmpty()); + assertNull(storage.getNodeInfo(testFolderInfo.getId()).getAccessRights().getOthersRights()); // check test folder is empty assertTrue(storage.getChildNodes(testFolderInfo.getId()).isEmpty()); @@ -294,6 +298,8 @@ public void test() throws IOException, InterruptedException { assertEquals(ImmutableMap.of("d1", 1d), testData2Info.getGenericMetadata().getDoubles()); assertEquals(ImmutableMap.of("i1", 2), testData2Info.getGenericMetadata().getInts()); assertEquals(ImmutableMap.of("b1", false), testData2Info.getGenericMetadata().getBooleans()); + assertEquals(ImmutableMap.of("user1", 2, "user2", 4), testData2Info.getAccessRights().getUsersRights()); + assertEquals(ImmutableMap.of("group1", 6), testData2Info.getAccessRights().getGroupsRights()); // 10) check data node 2 binary data write try (OutputStream os = storage.writeBinaryData(testData2Info.getId(), "blob")) { diff --git a/afs/afs-ws/afs-ws-server/src/main/java/com/powsybl/afs/ws/server/AppStorageServer.java b/afs/afs-ws/afs-ws-server/src/main/java/com/powsybl/afs/ws/server/AppStorageServer.java index c825910a83d..37053c71452 100644 --- a/afs/afs-ws/afs-ws-server/src/main/java/com/powsybl/afs/ws/server/AppStorageServer.java +++ b/afs/afs-ws/afs-ws-server/src/main/java/com/powsybl/afs/ws/server/AppStorageServer.java @@ -104,7 +104,7 @@ public Response getInconsistentChildrenNodes(@ApiParam(value = "File system name public Response createNode(@ApiParam(value = "File system name") @PathParam("fileSystemName") String fileSystemName, @ApiParam(value = "Node ID") @PathParam("nodeId") String nodeId, @ApiParam(value = "Child Name") @PathParam("childName") String childName, - @ApiParam(value = "Node Meta Data") NodeInfo nodeInfo) { + @ApiParam(value = "Node Data") NodeInfo nodeInfo) { AppStorage storage = appDataBean.getStorage(fileSystemName); NodeInfo newNodeInfo = storage.createNode(nodeId, childName, nodeInfo.getPseudoClass(), nodeInfo.getDescription(), nodeInfo.getVersion(), nodeInfo.getGenericMetadata(), nodeInfo.getAccessRights()); return Response.ok().entity(newNodeInfo).build(); @@ -188,7 +188,7 @@ public Response deleteNode(@ApiParam(value = "File system name") @PathParam("fil @ApiOperation (value = "") @ApiResponses (value = {@ApiResponse(code = 200, message = ""), @ApiResponse(code = 500, message = "Error")}) public Response setDescription(@ApiParam(value = "File system name") @PathParam("fileSystemName") String fileSystemName, - @ApiParam(value = "File system name") @PathParam("nodeId") String nodeId, + @ApiParam(value = "Node ID") @PathParam("nodeId") String nodeId, @ApiParam(value = "Description") String description) { AppStorage storage = appDataBean.getStorage(fileSystemName); storage.setDescription(nodeId, description); @@ -201,7 +201,7 @@ public Response setDescription(@ApiParam(value = "File system name") @PathParam( @ApiOperation (value = "") @ApiResponses (value = {@ApiResponse(code = 200, message = ""), @ApiResponse(code = 500, message = "Error")}) public Response setConsistent(@ApiParam(value = "File system name") @PathParam("fileSystemName") String fileSystemName, - @ApiParam(value = "File system name") @PathParam("nodeId") String nodeId) { + @ApiParam(value = "Node ID") @PathParam("nodeId") String nodeId) { AppStorage storage = appDataBean.getStorage(fileSystemName); storage.setConsistent(nodeId); return Response.ok().build(); @@ -213,7 +213,7 @@ public Response setConsistent(@ApiParam(value = "File system name") @PathParam(" @ApiOperation (value = "") @ApiResponses (value = {@ApiResponse(code = 200, message = ""), @ApiResponse(code = 500, message = "Error")}) public Response renameNode(@ApiParam(value = "File system name") @PathParam("fileSystemName") String fileSystemName, - @ApiParam(value = "File system name") @PathParam("nodeId") String nodeId, + @ApiParam(value = "Node ID") @PathParam("nodeId") String nodeId, @ApiParam(value = "Name") String name) { AppStorage storage = appDataBean.getStorage(fileSystemName); storage.renameNode(nodeId, name);