Skip to content

Commit 2b934a8

Browse files
committed
Maven Spotless execution
1 parent cd4db6d commit 2b934a8

File tree

10 files changed

+20
-48
lines changed

10 files changed

+20
-48
lines changed

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/ApplicationProperties.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,4 @@
88
* @author Kavindu Perera
99
*/
1010
@ConfigurationProperties(prefix = "catalog")
11-
public record ApplicationProperties(
12-
@DefaultValue("10")
13-
@Min(1)
14-
int pageSize
15-
) {
16-
}
11+
public record ApplicationProperties(@DefaultValue("10") @Min(1) int pageSize) {}

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/domain/PagedResult.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ public record PagedResult<T>(
1313
boolean isFirst,
1414
boolean isLast,
1515
boolean hasNext,
16-
boolean hasPrevious
17-
) {
18-
}
16+
boolean hasPrevious) {}

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/domain/Product.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,4 @@
55
/**
66
* @author Kavindu Perera
77
*/
8-
public record Product(
9-
String code,
10-
String name,
11-
String description,
12-
String imageUrl,
13-
BigDecimal price
14-
) {
15-
}
8+
public record Product(String code, String name, String description, String imageUrl, BigDecimal price) {}

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/domain/ProductEntity.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import jakarta.validation.constraints.DecimalMin;
1111
import jakarta.validation.constraints.NotEmpty;
1212
import jakarta.validation.constraints.NotNull;
13-
1413
import java.math.BigDecimal;
1514

1615
/**
@@ -35,8 +34,7 @@ class ProductEntity {
3534

3635
private String imageUrl;
3736

38-
@NotNull(message = "Product price is required")
39-
@DecimalMin("0.1")
37+
@NotNull(message = "Product price is required") @DecimalMin("0.1")
4038
@Column(nullable = false)
4139
private BigDecimal price;
4240

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/domain/ProductRepository.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
/**
66
* @author Kavindu Perera
77
*/
8-
interface ProductRepository extends JpaRepository<ProductEntity, Long> {
9-
}
8+
interface ProductRepository extends JpaRepository<ProductEntity, Long> {}

catalog-service/src/main/java/com/codebykavindu/bookstore/catalog/domain/ProductService.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.codebykavindu.bookstore.catalog.domain;
22

3-
43
import com.codebykavindu.bookstore.catalog.ApplicationProperties;
54
import org.springframework.data.domain.Page;
65
import org.springframework.data.domain.PageRequest;
@@ -28,8 +27,7 @@ public PagedResult<Product> getProducts(int pageNo) {
2827
pageNo = pageNo <= 1 ? 0 : pageNo - 1;
2928

3029
Pageable pageable = PageRequest.of(pageNo, properties.pageSize(), sort);
31-
Page<Product> productsPage = productRepository.findAll(pageable)
32-
.map(ProductMapper::toProduct);
30+
Page<Product> productsPage = productRepository.findAll(pageable).map(ProductMapper::toProduct);
3331

3432
return new PagedResult<>(
3533
productsPage.getContent(),
@@ -39,7 +37,6 @@ public PagedResult<Product> getProducts(int pageNo) {
3937
productsPage.isFirst(),
4038
productsPage.isLast(),
4139
productsPage.hasNext(),
42-
productsPage.hasPrevious()
43-
);
40+
productsPage.hasPrevious());
4441
}
4542
}

catalog-service/src/test/java/com/codebykavindu/bookstore/catalog/AbstractIntegrationTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.codebykavindu.bookstore.catalog;
22

3+
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
4+
35
import io.restassured.RestAssured;
46
import org.junit.jupiter.api.BeforeEach;
57
import org.springframework.boot.test.context.SpringBootTest;
68
import org.springframework.boot.test.web.server.LocalServerPort;
79
import org.springframework.context.annotation.Import;
810

9-
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
10-
1111
/**
1212
* @author Kavindu Perera
1313
*/
@@ -21,5 +21,4 @@ public abstract class AbstractIntegrationTest {
2121
void setUp() {
2222
RestAssured.port = port;
2323
}
24-
2524
}

catalog-service/src/test/java/com/codebykavindu/bookstore/catalog/CatalogServiceApplicationTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
65
class CatalogServiceApplicationTests extends AbstractIntegrationTest {
76

87
@Test
9-
void contextLoads() {
10-
}
8+
void contextLoads() {}
119
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.codebykavindu.bookstore.catalog.domain;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.util.List;
36
import org.junit.jupiter.api.Test;
47
import org.springframework.beans.factory.annotation.Autowired;
58
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
69
import org.springframework.test.context.jdbc.Sql;
710

8-
import java.util.List;
9-
10-
import static org.assertj.core.api.Assertions.assertThat;
11-
1211
/**
1312
* @author Kavindu Perera
1413
*/
1514
@DataJpaTest(
16-
properties = {
17-
"spring.test.database.replace=none",
18-
"spring.datasource.url=jdbc:tc:postgresql:16-alpine:///db"
19-
}
20-
)
15+
properties = {"spring.test.database.replace=none", "spring.datasource.url=jdbc:tc:postgresql:16-alpine:///db"})
2116
@Sql("/test-data.sql")
2217
class ProductRepositoryTest {
2318

@@ -27,6 +22,6 @@ class ProductRepositoryTest {
2722
@Test
2823
void shouldGetAllProducts() {
2924
List<ProductEntity> products = productRepository.findAll();
30-
assertThat(products).hasSize(15);
25+
assertThat(products).hasSize(15);
3126
}
32-
}
27+
}

catalog-service/src/test/java/com/codebykavindu/bookstore/catalog/web/ProductControllerTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.codebykavindu.bookstore.catalog.web;
22

3+
import static io.restassured.RestAssured.given;
4+
import static org.hamcrest.Matchers.hasSize;
5+
import static org.hamcrest.Matchers.is;
6+
37
import com.codebykavindu.bookstore.catalog.AbstractIntegrationTest;
48
import io.restassured.http.ContentType;
59
import org.junit.jupiter.api.Test;
610
import org.springframework.test.context.jdbc.Sql;
711

8-
import static io.restassured.RestAssured.given;
9-
import static org.hamcrest.Matchers.hasSize;
10-
import static org.hamcrest.Matchers.is;
11-
1212
/**
1313
* @author Kavindu Perera
1414
*/

0 commit comments

Comments
 (0)