Skip to content

Commit

Permalink
Fixing tests failing after changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AvilaAndre committed Mar 29, 2024
1 parent 1863c6f commit 250bb18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class Activity(
@field:NotBlank
open var image: String,

@ElementCollection
@ElementCollection(fetch = FetchType.EAGER)
open val gallery: MutableList<String> = mutableListOf(),

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ abstract class AbstractActivityService<T : Activity>(

var imageFolder = "activities"

when (activity::javaClass) {
Event::class -> imageFolder = EventService.IMAGE_FOLDER
Project::class -> imageFolder = ProjectService.IMAGE_FOLDER
if (activity is Event) {
imageFolder = EventService.IMAGE_FOLDER
} else if (activity is Project) {
imageFolder = ProjectService.IMAGE_FOLDER
}

val fileName = fileUploader.buildFileName(image, activity.title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ internal class EventControllerTest @Autowired constructor(

@Test
fun `should add an image`() {
val expectedImagePath = "${uploadConfigProperties.staticServe}/gallery/${testEvent.title}-$uuid.jpeg"
val expectedImagePath = "${uploadConfigProperties.staticServe}/events/gallery/${testEvent.title}-$uuid.jpeg"

mockMvc.multipartBuilder("/events/${testEvent.id}/gallery/addImage")
.asPutMethod()
Expand Down Expand Up @@ -898,11 +898,13 @@ internal class EventControllerTest @Autowired constructor(

private val uuid: UUID = UUID.randomUUID()
private val mockedSettings = Mockito.mockStatic(UUID::class.java)
private val mockImageUrl = "${uploadConfigProperties.staticServe}/gallery/${testEvent.title}-$uuid.jpeg"
private val mockImageUrl = "${uploadConfigProperties.staticServe}/events/gallery/${testEvent.title}-$uuid.jpeg"

@BeforeAll
fun setupMocks() {
Mockito.`when`(UUID.randomUUID()).thenReturn(uuid)

testEvent.gallery.add(mockImageUrl)
}

@AfterAll
Expand All @@ -914,10 +916,7 @@ internal class EventControllerTest @Autowired constructor(
fun addToRepositories() {
accountRepository.save(testAccount)

val testEventClone = testEvent

testEvent.gallery.add(mockImageUrl)
repository.save(testEventClone)
repository.save(testEvent)
}

@Test
Expand Down

0 comments on commit 250bb18

Please sign in to comment.