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

feat(credentials) #54: validate required endpoints #58

Merged

Conversation

andacata
Copy link
Contributor

@andacata andacata commented Jan 9, 2024

Solves #54

@andacata
Copy link
Contributor Author

andacata commented Jan 9, 2024

Sorry, I've included a previous commit in the PR by mistake 🤦‍♂️

@lilgallon lilgallon force-pushed the feature/54_validate_required_endpoints branch from 0b179cf to a570a09 Compare January 9, 2024 18:03
@lilgallon
Copy link
Member

No worries, I rebased your PR, it's fine now ;)

*/
class CredentialsClientService(
private val clientVersionsEndpointUrl: String,
private val clientPartnerRepository: PartnerRepository,
private val clientVersionsRepository: VersionsRepository,
private val clientCredentialsRoleRepository: CredentialsRoleRepository,
private val serverVersionsEndpointUrl: String,
private val transportClientBuilder: TransportClientBuilder
private val transportClientBuilder: TransportClientBuilder,
private val requiredOtherPartEndpointsProvider: suspend () -> Map<InterfaceRole, List<ModuleID>>
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a particular reason why need this as a function? instead of just a map? ... I'd assume this will be static anyways, as your particular implementation will require certain endpoints, or not

nit: name could simply be requiredEndpoints as it should be pretty clear we are testing the other side, not ourself

Copy link
Contributor

Choose a reason for hiding this comment

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

on that note .. using a map, where you actually expect very specific fields seems odd .. schema it

data class RequiredEndpoints(
  val receivers: List<ModuleId>,
  val senders: List<ModuleId>,
)

import com.izivia.ocpi.toolkit.modules.versions.domain.ModuleID

class CredentialsCommon {
companion object {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I have a feeling this was code written in Java, and automatically transformed to Kotlin ... there's barely ever a need for companion objects ... just move the method out of class ... function will be part of package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty new to Kotlin, so I'll make more mistakes like this 😓

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm by no means an expert ... it looked very much like the code I wrote 3 months ago ;)

That's why I think PR comments are a great way to transmit this info, as it gives real world examples. I hope this didn't discouraged you ... overall great contribution. Also .. I wouldn't call it a mistake (ergo the nit:), just room for improvement ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm always open to learn.

Comment on lines 23 to 27
.let {
it ?: throw OcpiServerNoMatchingEndpointsException(
"${ModuleID.credentials} other part endpoint missing"
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need the let ... just react to the null

Suggested change
.let {
it ?: throw OcpiServerNoMatchingEndpointsException(
"${ModuleID.credentials} other part endpoint missing"
)
}
?: throw OcpiServerNoMatchingEndpointsException(
"${ModuleID.credentials} other part endpoint missing"
)
```

@andacata
Copy link
Contributor Author

Comments fixed in b29ef05

@lilgallon lilgallon changed the title Feature/54 validate required endpoints feat(credentials) #54: validate required endpoints Jan 11, 2024
Copy link
Member

@lilgallon lilgallon left a comment

Choose a reason for hiding this comment

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

Well done ! Thank you for your contribution @andacata, and thank you for your review @atschabu

@lilgallon lilgallon force-pushed the feature/54_validate_required_endpoints branch from b29ef05 to 319816e Compare January 11, 2024 11:30
Copy link

sonarcloud bot commented Jan 11, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@lilgallon lilgallon merged commit ed450b6 into IZIVIA:main Jan 11, 2024
2 checks passed
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