-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed logic to save and retrieve cars from a redis based cache by usi…
…ng the vin of the car as the id of each car entity rather than the id field of the car entity as received from the external black box api, renamed all classes, methods and variables with the content vehicle in them to contain the keyword car instead to be in line with the requirement, renamed vehicle service to car service along with changing the keyword vehicle to car within all classes, methods and variables within previously called vehicle-service, fixed logic in car service to query cars by their vin when the vin is the id of each car entity in the redis store
- Loading branch information
1 parent
b2fa0d3
commit d374ef0
Showing
50 changed files
with
355 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM adoptopenjdk:11-jre-hotspot-focal | ||
MAINTAINER Anirban Das <anirbandas18@live.com> | ||
RUN mkdip ~p /opt/sharenow-coding-challenge | ||
COPY target/vehicle-car.jar /opt/sharenow-coding-challenge/car-app.jar | ||
CMD ["java","-jar","/opt/sharenow-coding-challenge/car-app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ow/vehicle/VehicleServiceApplication.java → ...e/sharenow/car/CarServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.vehicle; | ||
package com.teenthofabud.codingchallenge.sharenow.car; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
|
||
@SpringBootApplication | ||
@EnableEurekaClient | ||
public class VehicleServiceApplication { | ||
public class CarServiceApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(VehicleServiceApplication.class, args); | ||
SpringApplication.run(CarServiceApplication.class, args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...in/java/com/teenthofabud/codingchallenge/sharenow/car/controller/CarSearchController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.car.controller; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.car.model.error.CarServiceException; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarDetailsVO; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarVO; | ||
import com.teenthofabud.codingchallenge.sharenow.car.service.CarService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("search") | ||
public class CarSearchController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(CarSearchController.class); | ||
|
||
@Autowired | ||
private CarService service; | ||
|
||
@GetMapping("vin/{vin}") | ||
public ResponseEntity<?> getVehicleByVin(@PathVariable String vin) throws CarServiceException { | ||
LOGGER.info("Requesting vehicle with vin: {}", vin); | ||
CarDetailsVO vo = this.service.retrieveVehicleDetailsByVin(vin); | ||
ResponseEntity<CarDetailsVO> response = ResponseEntity.ok(vo); | ||
LOGGER.info("Responding with vehicle of vin: {}", vin); | ||
return response; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<?> getAllVehicles() throws CarServiceException { | ||
LOGGER.info("Requesting all vehicles"); | ||
List<CarVO> voList = this.service.retrieveAllVehicles(); | ||
ResponseEntity<List<CarVO>> response = ResponseEntity.ok(voList); | ||
LOGGER.info("Responding with all available vehicles"); | ||
return response; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...om/teenthofabud/codingchallenge/sharenow/car/converter/CarEntity2DetailedVOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.car.converter; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.car.model.entity.CarEntity; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarDetailsVO; | ||
import org.springframework.core.convert.converter.Converter; | ||
|
||
@FunctionalInterface | ||
public interface CarEntity2DetailedVOConverter extends Converter<CarEntity, CarDetailsVO> { | ||
|
||
public CarDetailsVO convert(CarEntity entity); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...n/java/com/teenthofabud/codingchallenge/sharenow/car/converter/CarEntity2VOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.car.converter; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.car.model.entity.CarEntity; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarVO; | ||
import org.springframework.core.convert.converter.Converter; | ||
|
||
@FunctionalInterface | ||
public interface CarEntity2VOConverter extends Converter<CarEntity, CarVO> { | ||
|
||
public CarVO convert(CarEntity entity); | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
...converter/PositionEntity2VOConverter.java → ...converter/PositionEntity2VOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../vehicle/model/entity/PositionEntity.java → ...enow/car/model/entity/PositionEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...vehicle/model/error/VehicleErrorCode.java → ...harenow/car/model/error/CarErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
.../model/error/VehicleServiceException.java → .../car/model/error/CarServiceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ow/vehicle/model/vo/VehicleDetailsVO.java → ...e/sharenow/car/model/vo/CarDetailsVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../sharenow/vehicle/model/vo/VehicleVO.java → ...hallenge/sharenow/car/model/vo/CarVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ge/sharenow/vehicle/model/vo/ErrorVO.java → ...llenge/sharenow/car/model/vo/ErrorVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sharenow/vehicle/model/vo/PositionVO.java → ...nge/sharenow/car/model/vo/PositionVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...src/main/java/com/teenthofabud/codingchallenge/sharenow/car/repository/CarRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.car.repository; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.car.model.entity.CarEntity; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface CarRepository extends CrudRepository<CarEntity, String> { | ||
|
||
public List<CarEntity> findByVin(String vin); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...rvice/src/main/java/com/teenthofabud/codingchallenge/sharenow/car/service/CarService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.car.service; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.car.model.error.CarServiceException; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarDetailsVO; | ||
import com.teenthofabud.codingchallenge.sharenow.car.model.vo.CarVO; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public interface CarService { | ||
|
||
public List<CarVO> retrieveAllVehicles(); | ||
|
||
public CarDetailsVO retrieveVehicleDetailsByVin(String vin) throws CarServiceException; | ||
|
||
} |
Oops, something went wrong.