|
1 | | -package edu.tamu.app.mock.projects; |
| 1 | +package edu.tamu.app.mock.products; |
2 | 2 |
|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.util.ArrayList; |
|
19 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | 20 |
|
21 | 21 | import edu.tamu.app.model.request.FeatureRequest; |
22 | | -import edu.tamu.app.model.response.Project; |
| 22 | +import edu.tamu.app.model.response.Product; |
23 | 23 |
|
24 | 24 | @Service |
25 | 25 | @Profile("test") |
26 | | -public class MockProjects { |
| 26 | +public class MockProducts { |
27 | 27 |
|
28 | | - private static List<Project> projects = new ArrayList<Project>(); |
| 28 | + private static List<Product> products = new ArrayList<Product>(); |
29 | 29 |
|
30 | | - @Value("classpath:mock/projects.json") |
| 30 | + @Value("classpath:mock/products.json") |
31 | 31 | private Resource resource; |
32 | 32 |
|
33 | 33 | @Autowired |
34 | 34 | private ObjectMapper objectMapper; |
35 | 35 |
|
36 | 36 | @PostConstruct |
37 | | - private void loadProjects() throws JsonParseException, JsonMappingException, IOException { |
38 | | - projects = objectMapper.readValue(resource.getFile(), new TypeReference<List<Project>>() {}); |
| 37 | + private void loadProducts() throws JsonParseException, JsonMappingException, IOException { |
| 38 | + products = objectMapper.readValue(resource.getFile(), new TypeReference<List<Product>>() {}); |
39 | 39 | } |
40 | 40 |
|
41 | | - public List<Project> getAllProjects() { |
42 | | - return projects; |
| 41 | + public List<Product> getAllProducts() { |
| 42 | + return products; |
43 | 43 | } |
44 | 44 |
|
45 | | - public Project getProjectById(Long id) { |
46 | | - Project project = null; |
47 | | - for (Project currentProject : projects) { |
48 | | - Optional<Long> currentId = Optional.ofNullable(Long.valueOf(currentProject.getId())); |
| 45 | + public Product getProductById(Long id) { |
| 46 | + Product product = null; |
| 47 | + for (Product currentProduct : products) { |
| 48 | + Optional<Long> currentId = Optional.ofNullable(Long.valueOf(currentProduct.getId())); |
49 | 49 | if (currentId.isPresent()) { |
50 | 50 | if (currentId.get().equals(id)) { |
51 | | - project = currentProject; |
| 51 | + product = currentProduct; |
52 | 52 | break; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | | - return project; |
| 56 | + return product; |
57 | 57 | } |
58 | 58 |
|
59 | 59 | public String submitRequest(FeatureRequest request) { |
|
0 commit comments