@@ -10,6 +10,7 @@ package no.ndla.myndlaapi.service
1010
1111import no .ndla .common .errors .{AccessDeniedException , ValidationException }
1212import no .ndla .common .model .NDLADate
13+ import no .ndla .common .model .api .Missing
1314import no .ndla .common .model .domain .ResourceType
1415import no .ndla .common .model .domain .myndla .{FolderStatus , UserRole }
1516import no .ndla .myndlaapi .TestData .{emptyDomainFolder , emptyDomainResource , emptyMyNDLAUser }
@@ -679,7 +680,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
679680 val feideId = " FEIDE"
680681 val folderId = UUID .randomUUID()
681682 val parentId = UUID .randomUUID()
682- val updateFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
683+ val updateFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
683684
684685 val existingFolder = domain.Folder (
685686 id = folderId,
@@ -742,7 +743,8 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
742743 val feideId = " FEIDE"
743744 val folderId = UUID .randomUUID()
744745 val parentId = UUID .randomUUID()
745- val updateFolder = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
746+ val updateFolder =
747+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
746748
747749 val existingFolder = domain.Folder (
748750 id = folderId,
@@ -981,7 +983,8 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
981983 val myNDLAUser = emptyMyNDLAUser.copy(userRole = UserRole .STUDENT )
982984 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
983985
984- val updatedFolder = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
986+ val updatedFolder =
987+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
985988 val Failure (result) =
986989 service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder): @ unchecked
987990 result.getMessage should be(" You do not have necessary permissions to share folders." )
@@ -994,7 +997,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
994997 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
995998 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (true ))
996999
997- val updatedFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1000+ val updatedFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
9981001 val Failure (result) =
9991002 service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder): @ unchecked
10001003 result.getMessage should be(" You do not have write access while write restriction is active." )
@@ -1005,7 +1008,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
10051008 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
10061009 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (false ))
10071010
1008- val updatedFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1011+ val updatedFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
10091012 val result = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder)
10101013 result.isSuccess should be(true )
10111014 }
@@ -1015,10 +1018,12 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
10151018 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
10161019 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (true ))
10171020
1018- val folderWithUpdatedName = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1019- val folderWithUpdatedStatus = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
1020- val result1 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedName)
1021- val result2 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedStatus)
1021+ val folderWithUpdatedName =
1022+ api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
1023+ val folderWithUpdatedStatus =
1024+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
1025+ val result1 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedName)
1026+ val result2 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedStatus)
10221027 result1.isSuccess should be(true )
10231028 result2.isSuccess should be(true )
10241029 }
0 commit comments