Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-443 Added uploadANC front end #38

Merged
merged 6 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.imperial.mrc.hint.models
import com.fasterxml.jackson.databind.ObjectMapper

data class SuccessResponse(val data: Any?){
val errors = mapOf<Any, Any>()
val errors = arrayOf<Any>()
val status = "success"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import java.io.File
import java.net.URI
import java.net.URL
import javax.json.stream.JsonParsingException
import java.io.InputStreamReader
import java.io.BufferedReader
import java.net.HttpURLConnection


class JSONValidator {
Expand Down Expand Up @@ -72,7 +75,9 @@ class JSONValidator {
"$name.schema.json"
}
val url = URL("https://raw.githubusercontent.com/mrc-ide/hintr/$hintrVersion/inst/schema/$path")
return url.openStream().use {

val conn = url.openConnection() as HttpURLConnection
return BufferedReader(InputStreamReader(conn.getInputStream())).use {
Copy link
Contributor Author

@EmmaLRussell EmmaLRussell Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy hell, this was annoying. This randomly started throwing errors when running locally, when attempting to use the blameless ValidateInputResponse schema (it was claiming the schema was invalid). Eventually worked out it appeared to always fail at the same character index, so presumably it wasn't managing to read the whole file over a certain length). Changing from url.openStream to url.openConnection seemed to fix this...

val reader = readerFactory.createSchemaReader(it)
try {
reader.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaselineTests : SecureIntegrationTests() {
if (isAuthorized == IsAuthorized.TRUE){
// we can't use the JSONValidator here because this response schema isn't in the spec yet
assertThat(responseEntity.body!!)
.isEqualTo("{\"errors\":{},\"status\":\"success\",\"data\":{\"pjnz\":null}}")
.isEqualTo("{\"errors\":[],\"status\":\"success\",\"data\":{\"pjnz\":null}}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class HintApplicationTests(@Autowired val restTemplate: TestRestTemplate) : Inte
val entity = restTemplate.getForEntity<String>("/baseline/")

assertThat(entity.statusCode).isEqualTo(HttpStatus.OK)
assertThat(entity.body!!).isEqualTo("{\"errors\":{},\"status\":\"success\",\"data\":{\"pjnz\":null}}")
assertThat(entity.body!!).isEqualTo("{\"errors\":[],\"status\":\"success\",\"data\":{\"pjnz\":null}}")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PasswordTests(@Autowired val restTemplate: TestRestTemplate) : CleanDataba
}
}

private val expectedSuccessResponse = "{\"errors\":{},\"status\":\"success\",\"data\":true}"
private val expectedSuccessResponse = "{\"errors\":[],\"status\":\"success\",\"data\":true}"

private fun expectedErrorResponse(errorMessage: String): String {
return "{\"data\":{},\"status\":\"failure\",\"errors\":[{\"error\":\"OTHER_ERROR\",\"detail\":\"$errorMessage\"}]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PasswordControllerTests {

val mockEmailManager = mock<EmailManager>()

val expectedSuccessResponse = "{\"errors\":{},\"status\":\"success\",\"data\":true}"
val expectedSuccessResponse = "{\"errors\":[],\"status\":\"success\",\"data\":true}"

@Test
fun `forgotPassword returns expected template name`() {
Expand Down
Loading