Skip to content
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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ updates:
open-pull-requests-limit: 10
commit-message:
prefix: ci
include: scope
include: scope
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [1.1 Unit Test](#11-unit-test)
- [1.2 Cucumber End to End Test](#12-cucumber-end-to-end-test)
- [1.3 Mutation Testing](#13-mutation-testing)
- [1.4 Local Testing](#14-local-testing)
- [2. Development Accelerators](#2-development-accelerators)
- [2.1 Mapstruct](#21-mapstruct)
- [2.2 Lombok](#22-lombok)
Expand Down Expand Up @@ -49,25 +50,17 @@

### Introduction

This project is intended to bring arguably best practices and integrations available for Spring Boot based Microservice
in a single repository.
This repository combines the best practices and essential integrations for building robust Spring Boot-based microservices, all in one place. It serves as a template, allowing developers to easily create their own microservices by adding or removing dependencies based on their needs.

Developers can use this repository as a template to build there own Microservice by adding or removing dependencies as
per requirement.
In the sections below, I'll walk you through the various integrations included in the project and guide you on how to use them effectively.

In the below section I will try to explain each integration we have made and how to use.

At the moment the Microservice exposes a GET API and expects the company reference as path parameter then makes a call
to the Companies House API hence returning Company Details.

**Note: Texts highlighted in light blue colour are clickable hyperlinks for additional references.**
Currently, the microservice exposes a simple GET API that accepts a company reference as a path parameter. It then queries the Companies House API to retrieve and return detailed company information.

### Prerequisites

- You must have >= Java 21 Installed. You can use [SDKMAN](https://sdkman.io/install) for maintaining different JDK's in your system.
- If you wish to run the application against the actual Companies House
API and then you will need to [create a free account](https://developer.companieshouse.gov.uk/developer/signin).
Once created replace the `authUserName` in the [application.yaml](src/main/resources/application.yaml) under main dir.
- You should [register for a free Companies House account](https://developer.company-information.service.gov.uk/get-started) and then generate a REST API key. This is required for invoking the GET API exposed by this service else the API invocation will fail at runtime with auth error.
- Replace the `authUserName` in the [application.yaml](src/main/resources/application.yaml) under main dir with the newly created API Key.

### Installation and Getting Started

Expand Down Expand Up @@ -172,6 +165,22 @@ once the test execution completes report should be accessible at:

![](doc-resources/images/pitest-report.png)

#### 1.4 Local Testing

The application can be started in the IDE through [CompaniesHouseApplication.java](src/main/java/com/uk/companieshouse/CompaniesHouseApplication.java) or by executing below command in the terminal

```bash
./gradlew bootRun
```

Once the application starts the application can be accessed through below URL:

```
curl --location 'http://localhost:8080/companieshouse/search/abhishek'
```

If valid Rest API Key is added in `authUserName` then we should receive all the companies details that has `abhishek` in their registered **title**

### 2. Development Accelerators

#### [2.1 Mapstruct](https://mapstruct.org/)
Expand Down
9 changes: 0 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
testImplementation('org.springframework.boot:spring-boot-starter-test')
// Upgrade transient vulnerabilities to fix vulnerabilities
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// https://docs.gradle.org/current/userguide/resolution_rules.html
if (details.requested.group == 'ch.qos.logback' && details.requested.name == 'logback-classic') {
details.useVersion '1.5.13'
}
}
}
// Cucumber Dependencies for BDD
testImplementation "io.cucumber:cucumber-java:${ioCucumberVersion}"
testImplementation "io.cucumber:cucumber-junit:${ioCucumberVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public CompaniesHouseGovUKResponse getCompaniesHouseDetails(String crn) {
restTemplate.getInterceptors().add(
new BasicAuthenticationInterceptor(authUsername, ""));

log.debug("CompaniesHouseConnector:getCompaniesHouseDetails: Make External call to {} with CRN {}",
log.debug("CompaniesHouseConnector:getCompaniesHouseDetails: Make External call to: {} with CRN: {}",
govCompaniesHouseEndpoint, crn);
ResponseEntity<CompaniesHouseGovUKResponse> responseEntity = restTemplate
.getForEntity(govCompaniesHouseEndpoint, CompaniesHouseGovUKResponse.class, crn);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ logging:
companieshouse: DEBUG

govCompaniesHouse:
endpoint: https://api.companieshouse.gov.uk/search/companies?q={companyRef}
endpoint: https://api.company-information.service.gov.uk/search/companies?q={crn}
authUserName: dummy-auth-user
Loading