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

techtask/Separation-of-credentials-from-endpoints #35

Merged

Conversation

yahorm
Copy link
Collaborator

@yahorm yahorm commented Sep 5, 2019

No description provided.

Copy link
Contributor

@szymon-owczarzak szymon-owczarzak left a comment

Choose a reason for hiding this comment

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

Let's introduce JUnit tests with this improvement.

companion object {
val LOGGER: Logger = LoggerFactory.getLogger(ConfigManager::class.java)
const val ID = "id";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice i like that

return endpoint
}

private fun findJsonObjectById(id: String?, array: JsonArray): Optional<JsonObject> {
Copy link
Contributor

Choose a reason for hiding this comment

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

@michalskrzypek
Copy link
Contributor

Let's introduce JUnit tests with this improvement.

Done. Code refactored and unit tests added.


override fun start() {
endpoints = config().getJsonArray("endpoints")
endpoints = config().getJsonArray(ENDPOINTS)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is know confusing - in my opinion there is no need to store endpoints, credentials and most importantly endpoint here. Look below to see how I see it:

endpointId == it.getString("id")
}.findFirst()
.orElse(JsonObject()))
config.put(CogboardConstants.PROP_ENDPOINT, endpoint.readById(endpointId))}
Copy link
Contributor

@szymon-owczarzak szymon-owczarzak Sep 9, 2019

Choose a reason for hiding this comment

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

I would like to see it like this:
config.put(CogboardConstants.PROP_ENDPOINT, Endpoint.from(config(), endpointId).asJson())


companion object {
val LOGGER: Logger = LoggerFactory.getLogger(ConfigManager::class.java)
const val CREDENTIALS = "credentials"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be moved to Endpoint class

@@ -24,8 +24,8 @@ class GetEndpoints : RoutingHandlerFactory {
copy.stream().forEach {
if (it is JsonObject) {
it.remove("url")
it.remove("user")
it.remove("password")
it.remove("publicUrl")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice !

import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Test

internal class EndpointTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like that You introduced JUnit to the project !

@@ -0,0 +1,14 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

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

merge credentials-test.json and endpoints-test.json so it is presented as in actual code.

@michalskrzypek michalskrzypek merged commit 025c986 into master Sep 9, 2019

@Test
fun shouldRemoveCredentialsProp() {
val validEndpoint = Endpoint(endpoints, credentials,"validEndpoint").asJson()
Copy link
Collaborator Author

@yahorm yahorm Sep 9, 2019

Choose a reason for hiding this comment

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

next time please use @beforeeach for initialize e.g. endpoint once.

private lateinit var validEndpoint: JsonObject
private lateinit var invalidEndpoint: JsonObject

@BeforeEach
fun init() {
    validEndpoint = Endpoint(endpoints, credentials, "validEndpoint").asJson()
    invalidEndpoint = Endpoint(endpoints, credentials, "invalidEndpoint").asJson()
}

Cich0sza pushed a commit that referenced this pull request Sep 23, 2019
…als-from-endpoints

techtask/Separation-of-credentials-from-endpoints
@michalskrzypek michalskrzypek deleted the techtask/Separation-of-credentials-from-endpoints branch September 27, 2019 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants