Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #435 from SELab-2/development
Browse files Browse the repository at this point in the history
Last last last PR?
  • Loading branch information
lars-vc authored May 22, 2022
2 parents 942de03 + 323faee commit 84182a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.springframework.web.context.request.ServletRequestAttributes
import java.util.UUID

class ProjectServiceTests {
private val scheme = System.getenv("OSOC_SCHEME") ?: "http"
private val testId = UUID.randomUUID()
private val testStudent = Student("Lars", "Van Cauter", "")
private val testCoach = User("Lars2 Van Cauter", "[email protected]", Role.Coach, "password")
Expand Down Expand Up @@ -219,27 +220,27 @@ class ProjectServiceTests {
val service = ProjectService(repository, mockk(), getUserService())

val mockRequest = MockHttpServletRequest()
mockRequest.scheme = "http"
mockRequest.scheme = scheme
mockRequest.serverName = "example.com"
mockRequest.serverPort = -1
mockRequest.contextPath = "/api"
RequestContextHolder.setRequestAttributes(ServletRequestAttributes(mockRequest))
val conflictList = service.getConflicts(testEdition)
assert(
conflictList[0] == ProjectService.Conflict(
"http://example.com/api/$testEdition/students/" + testStudent.id,
"$scheme://example.com/api/$testEdition/students/" + testStudent.id,
mutableListOf(
"http://example.com/api/$testEdition/projects/" + testProjectConflict.id,
"http://example.com/api/$testEdition/projects/" + testProjectConflict2.id
"$scheme://example.com/api/$testEdition/projects/" + testProjectConflict.id,
"$scheme://example.com/api/$testEdition/projects/" + testProjectConflict2.id
)
)
)
assert(
conflictList[1] == ProjectService.Conflict(
"http://example.com/api/$testEdition/students/" + testStudent2.id,
"$scheme://example.com/api/$testEdition/students/" + testStudent2.id,
mutableListOf(
"http://example.com/api/$testEdition/projects/" + testProjectConflict2.id,
"http://example.com/api/$testEdition/projects/" + testProjectConflict3.id
"$scheme://example.com/api/$testEdition/projects/" + testProjectConflict2.id,
"$scheme://example.com/api/$testEdition/projects/" + testProjectConflict3.id
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.springframework.web.context.request.ServletRequestAttributes
@JsonTest
class SerializationTests {

private val scheme = System.getenv("OSOC_SCHEME") ?: "http"
@Autowired
private val projectJacksonTester: JacksonTester<Project>? = null

Expand Down Expand Up @@ -61,11 +62,11 @@ class SerializationTests {
val json: JsonContent<Project> = projectJacksonTester!!.write(testProject)

assertThat(json).extractingJsonPathValue("$.coaches")
.isEqualTo(mutableListOf("http://example.com/api/users/${testUser.id}"))
.isEqualTo(mutableListOf("$scheme://example.com/api/users/${testUser.id}"))
assertThat(json).extractingJsonPathValue("$.positions")
.isEqualTo(mutableListOf("http://example.com/api/positions/${testPosition.id}"))
.isEqualTo(mutableListOf("$scheme://example.com/api/positions/${testPosition.id}"))
assertThat(json).extractingJsonPathValue("$.assignments")
.isEqualTo(mutableListOf("http://example.com/api/assignments/${testAssignment.id}"))
.isEqualTo(mutableListOf("$scheme://example.com/api/assignments/${testAssignment.id}"))
}

@Test
Expand All @@ -89,9 +90,9 @@ class SerializationTests {
val json: JsonContent<Student> = studentJacksonTester!!.write(testStudent)

assertThat(json).extractingJsonPathValue("$.statusSuggestions")
.isEqualTo(mutableListOf("http://example.com/api/statusSuggestions/${testStatusSuggestion.id}"))
.isEqualTo(mutableListOf("$scheme://example.com/api/statusSuggestions/${testStatusSuggestion.id}"))
assertThat(json).extractingJsonPathValue("$.communications")
.isEqualTo(mutableListOf("http://example.com/api/$testEdition/communications/${testCommunication.id}"))
.isEqualTo(mutableListOf("$scheme://example.com/api/$testEdition/communications/${testCommunication.id}"))
}

@Test
Expand All @@ -113,10 +114,10 @@ class SerializationTests {
val json: JsonContent<Assignment> = assignmentJacksonTester!!.write(testAssignment)

assertThat(json).extractingJsonPathValue("$.student")
.isEqualTo("http://example.com/api/$testEdition/students/${testStudent.id}")
.isEqualTo("$scheme://example.com/api/$testEdition/students/${testStudent.id}")
assertThat(json).extractingJsonPathValue("$.position")
.isEqualTo("http://example.com/api/positions/${testPosition.id}")
.isEqualTo("$scheme://example.com/api/positions/${testPosition.id}")
assertThat(json).extractingJsonPathValue("$.suggester")
.isEqualTo("http://example.com/api/users/${testSuggester.id}")
.isEqualTo("$scheme://example.com/api/users/${testSuggester.id}")
}
}

0 comments on commit 84182a9

Please sign in to comment.