@@ -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 }
@@ -670,7 +671,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
670671 val feideId = " FEIDE"
671672 val folderId = UUID .randomUUID()
672673 val parentId = UUID .randomUUID()
673- val updateFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
674+ val updateFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
674675
675676 val existingFolder = domain.Folder (
676677 id = folderId,
@@ -733,7 +734,8 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
733734 val feideId = " FEIDE"
734735 val folderId = UUID .randomUUID()
735736 val parentId = UUID .randomUUID()
736- val updateFolder = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
737+ val updateFolder =
738+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
737739
738740 val existingFolder = domain.Folder (
739741 id = folderId,
@@ -991,7 +993,8 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
991993 val myNDLAUser = emptyMyNDLAUser.copy(userRole = UserRole .STUDENT )
992994 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
993995
994- val updatedFolder = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
996+ val updatedFolder =
997+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
995998 val Failure (result) =
996999 service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder): @ unchecked
9971000 result.getMessage should be(" You do not have necessary permissions to share folders." )
@@ -1004,7 +1007,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
10041007 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
10051008 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (true ))
10061009
1007- val updatedFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1010+ val updatedFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
10081011 val Failure (result) =
10091012 service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder): @ unchecked
10101013 result.getMessage should be(" You do not have write access while write restriction is active." )
@@ -1015,7 +1018,7 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
10151018 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
10161019 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (false ))
10171020
1018- val updatedFolder = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1021+ val updatedFolder = api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
10191022 val result = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), updatedFolder)
10201023 result.isSuccess should be(true )
10211024 }
@@ -1027,8 +1030,10 @@ class FolderWriteServiceTest extends UnitTestSuite with TestEnvironment {
10271030 when(userService.getOrCreateMyNDLAUserIfNotExist(any, any)(using any)).thenReturn(Success (myNDLAUser))
10281031 when(configService.isMyNDLAWriteRestricted).thenReturn(Success (true ))
10291032
1030- val folderWithUpdatedName = api.UpdatedFolderDTO (name = Some (" asd" ), status = None , description = None )
1031- val folderWithUpdatedStatus = api.UpdatedFolderDTO (name = None , status = Some (" shared" ), description = None )
1033+ val folderWithUpdatedName =
1034+ api.UpdatedFolderDTO (parentId = Missing , name = Some (" asd" ), status = None , description = None )
1035+ val folderWithUpdatedStatus =
1036+ api.UpdatedFolderDTO (parentId = Missing , name = None , status = Some (" shared" ), description = None )
10321037 val result1 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedName)
10331038 val result2 = service.isOperationAllowedOrAccessDenied(" feideid" , Some (" accesstoken" ), folderWithUpdatedStatus)
10341039 result1.isSuccess should be(true )
0 commit comments