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

Mime type for contracts #39

Merged
merged 6 commits into from
Dec 27, 2018
Merged

Mime type for contracts #39

merged 6 commits into from
Dec 27, 2018

Conversation

Felipe444
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Dec 24, 2018

Pull Request Test Coverage Report for Build 120

  • 69 of 69 (100.0%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.8%) to 96.0%

Totals Coverage Status
Change from base Build 108: 0.8%
Covered Lines: 504
Relevant Lines: 525

💛 - Coveralls

form.getCapabilities(),
form.getExpectations()
map(form.getCapabilities()),
form.getExpectations().entrySet().stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please extract this to method? it's not easy to understand what's happening

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What was my initial plan was to migrate to the final approach ant then get rid of any non-domain logic in ServiceContracts. For now we have there for example mapping from incoming data which binds us to non-domain logic.

If you really want it, I can do the final refactor now, but it would require to refactor duplicated code as well.
What do you think?

provider,
version,
mapToEntity(form.getCapabilities()),
form.getExpectations().entrySet().stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please extract this to method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What was my initial plan was to migrate to the final approach ant then get rid of any non-domain logic in ServiceContracts. For now we have there for example mapping from incoming data which binds us to non-domain logic.

If you really want it, I can do the final refactor now, but it would require to refactor duplicated code as well.
What do you think?

@@ -54,7 +85,7 @@ public ServiceContractsDto create(@PathVariable(name = "provider") String provid
}

@GetMapping(value = "/contracts/{serviceName}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get versions of a service with registered contracts", nickname = "get versions of a service")
@ApiOperation(value = "Get versions of a service with registered contracts", nickname = "create versions of a service")
Copy link
Contributor

Choose a reason for hiding this comment

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

revert this get -> create

)
));
}

@GetMapping(value = "/contracts", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get names of services with registered contracts", nickname = "get names of services")
@ApiOperation(value = "Get names of services with registered contracts", nickname = "create names of services")
Copy link
Contributor

Choose a reason for hiding this comment

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

revert get -> create

@GetMapping(value = "/contracts/{provider}/{version:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Register contracts for a version of a service", nickname = "register contracts")
@ApiOperation(value = "Get contracts for a version of a service", nickname = "register contracts")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it really registerting contracts? (nickname)

dto.setName(serviceContracts.getName());
dto.setVersion(serviceContracts.getVersion());
@GetMapping(value = "/new/contracts/{provider}/{version:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get contracts for a version of a service", nickname = "register contracts")
Copy link
Contributor

Choose a reason for hiding this comment

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

again, is it registering contracts?

@ApiResponse(code = 200, message = "Success", response = ServiceContractsDto.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Failure")})
public NewServiceContractsDto newGet(@PathVariable(name = "provider") String provider, @PathVariable(name = "version") String version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not the best name for any method

@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = ServiceContractsDto.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Failure")})
public ServiceContractsDto create(@PathVariable(name = "provider") String provider, @PathVariable(name = "version") String version) {
public ServiceContractsDto get(@PathVariable(name = "provider") String provider, @PathVariable(name = "version") String version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

getContractsForServiceInVersion?


private Map<String, Map<String, NewServiceContractsDto.ContractDto>> mapExpectationsToDto(Map<ServiceContracts.ProviderProtocol, ServiceContracts.Contract> expectations) {
HashMap<String, Map<String, NewServiceContractsDto.ContractDto>> result = newHashMap();
for (Map.Entry<ServiceContracts.ProviderProtocol, ServiceContracts.Contract> e : expectations.entrySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this loop is pretty complicated, is there any way to make it look easier?

Copy link
Contributor

Choose a reason for hiding this comment

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

at least extract method with a name that will explain this logic

@Felipe444 Felipe444 merged commit 296ba7b into master Dec 27, 2018
@Felipe444 Felipe444 deleted the mime-type-for-contracts branch December 27, 2018 08:48
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.

None yet

3 participants