This file contains hidden or 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
| // https://jsonplaceholder.typicode.com/users | |
| pm.test('Request Name', () => { | |
| pm.expect(pm.info.requestName).equals('Test Postman Scripts'); | |
| }); | |
| pm.test('Request Method is GET', () => { | |
| pm.expect(pm.request.method).equals('GET'); | |
| }); |
This file contains hidden or 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
| package com.example.demo; | |
| import io.swagger.v3.oas.annotations.OpenAPIDefinition; | |
| import io.swagger.v3.oas.annotations.info.Info; | |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| @SpringBootApplication | |
| @OpenAPIDefinition( | |
| info = @Info( |
This file contains hidden or 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
| package com.example.demo.repositories; | |
| import com.example.demo.entities.Item; | |
| import org.springframework.data.mongodb.repository.MongoRepository; | |
| public interface ItemRepository extends MongoRepository<Item, Long> { | |
| } | |
This file contains hidden or 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
| package com.example.demo.services; | |
| import com.example.demo.entities.Item; | |
| import java.util.List; | |
| public interface ItemService { | |
| List<Item> getItems(); |
This file contains hidden or 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
| package com.example.demo.services; | |
| import com.example.demo.entities.Item; | |
| import com.example.demo.repositories.ItemRepository; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.stereotype.Service; | |
| import java.util.List; | |
| import java.util.Optional; |
This file contains hidden or 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
| package com.example.demo.entities; | |
| import org.springframework.data.annotation.Id; | |
| import org.springframework.data.mongodb.core.mapping.Document; | |
| @Document(collection = "items") | |
| public class Item { | |
| @Id | |
| private String id; | |
| private String name; | |
| private String description; |
This file contains hidden or 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
| package com.example.demo.controllers; | |
| import com.example.demo.entities.Item; | |
| import com.example.demo.services.ItemService; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.*; | |
| import java.util.List; |
This file contains hidden or 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
| package com.api.reporting.models; | |
| public class ErrorMessage { | |
| private String message; | |
| private String url; | |
| private String port; | |
| private String method; | |
| public ErrorMessage(String message, String url, String port, String method) { |
This file contains hidden or 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
| import org.springframework.http.HttpStatus; | |
| import org.springframework.web.bind.annotation.ResponseStatus; | |
| @ResponseStatus(HttpStatus.NOT_FOUND) | |
| public class ProductNotFoundException extends RuntimeException { | |
| private static final long serialVersionUID = 1L; | |
| public ProductNotFoundException(String message) { | |
| super(message); |
This file contains hidden or 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
| import com.api.reporting.models.ErrorMessage; | |
| import org.springframework.http.HttpHeaders; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.ControllerAdvice; | |
| import org.springframework.web.bind.annotation.ExceptionHandler; | |
| import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | |
| import javax.servlet.http.HttpServletRequest; | |
| @ControllerAdvice |
NewerOlder