diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 040cac8..f0fe8cc 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -13,6 +13,10 @@ jobs: distribution: 'temurin' java-version: '11' cache: 'maven' + - name: Run Spotless Apply + run: mvn spotless:apply + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build with Maven run: mvn --file pom.xml clean install env: diff --git a/eclipse-java-formatter.xml b/eclipse-java-formatter.xml new file mode 100644 index 0000000..4ae144a --- /dev/null +++ b/eclipse-java-formatter.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3dadd4d..4e29ed8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,10 @@ UTF-8 - 2.0.2.0 + 2.0.5 2.12.7 + 2.43.0 + 1.17.0 @@ -67,7 +69,7 @@ org.postgresql postgresql - 42.5.0 + 42.6.1 @@ -175,7 +177,7 @@ org.liquibase liquibase-core - 3.8.0 + 4.8.0 org.springframework.boot @@ -226,6 +228,32 @@ true + + com.diffplug.spotless + spotless-maven-plugin + ${spotlessMavenPlugin.version} + + + + ${project.basedir}/eclipse-java-formatter.xml + + + + + + spotless-check + + check + + + + spotless-apply + + apply + + + + diff --git a/src/main/java/fi/hsl/transitlog/hfp/HfpDataParser.java b/src/main/java/fi/hsl/transitlog/hfp/HfpDataParser.java index dbe81a5..9b01c1a 100644 --- a/src/main/java/fi/hsl/transitlog/hfp/HfpDataParser.java +++ b/src/main/java/fi/hsl/transitlog/hfp/HfpDataParser.java @@ -5,8 +5,7 @@ import org.springframework.stereotype.Component; @Component -public -class HfpDataParser { +public class HfpDataParser { public Hfp.Data parseFrom(byte[] data) throws InvalidProtocolBufferException { return Hfp.Data.parseFrom(data); } diff --git a/src/main/java/fi/hsl/transitlog/hfp/TransitDataSchemaWrapper.java b/src/main/java/fi/hsl/transitlog/hfp/TransitDataSchemaWrapper.java index 6382e61..e3eb565 100644 --- a/src/main/java/fi/hsl/transitlog/hfp/TransitDataSchemaWrapper.java +++ b/src/main/java/fi/hsl/transitlog/hfp/TransitDataSchemaWrapper.java @@ -5,10 +5,8 @@ import org.apache.pulsar.client.api.Message; import org.springframework.stereotype.Component; - @Component -public -class TransitDataSchemaWrapper { +public class TransitDataSchemaWrapper { public boolean hasProtobufSchema(Message message) { return TransitdataSchema.hasProtobufSchema(message, TransitdataProperties.ProtobufSchema.HfpData); } diff --git a/src/main/java/fi/hsl/transitlog/hfp/configuration/DatabaseConfiguration.java b/src/main/java/fi/hsl/transitlog/hfp/configuration/DatabaseConfiguration.java index 48bfbb1..ffdbeb4 100644 --- a/src/main/java/fi/hsl/transitlog/hfp/configuration/DatabaseConfiguration.java +++ b/src/main/java/fi/hsl/transitlog/hfp/configuration/DatabaseConfiguration.java @@ -17,11 +17,7 @@ @Configuration @PropertySource({"classpath:application.properties"}) -@EnableJpaRepositories( - basePackages = "fi.hsl.transitlog.hfp.domain.repositories", - entityManagerFactoryRef = "devWriteEntityManager", - transactionManagerRef = "devWriteTransactionManager" -) +@EnableJpaRepositories(basePackages = "fi.hsl.transitlog.hfp.domain.repositories", entityManagerFactoryRef = "devWriteEntityManager", transactionManagerRef = "devWriteTransactionManager") @Profile(value = {"default", "dev"}) @EnableTransactionManagement @EnableAsync @@ -32,28 +28,22 @@ public class DatabaseConfiguration { @Bean @Primary public PlatformTransactionManager devWriteTransactionManager() { - JpaTransactionManager transactionManager - = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory( - devWriteEntityManager().getObject()); + JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(devWriteEntityManager().getObject()); return transactionManager; } @Bean @Primary public LocalContainerEntityManagerFactoryBean devWriteEntityManager() { - LocalContainerEntityManagerFactoryBean em - = new LocalContainerEntityManagerFactoryBean(); + LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(devWriteDataSource()); - em.setPackagesToScan( - "fi.hsl.transitlog.hfp.domain"); + em.setPackagesToScan("fi.hsl.transitlog.hfp.domain"); - HibernateJpaVendorAdapter vendorAdapter - = new HibernateJpaVendorAdapter(); + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); HashMap properties = new HashMap<>(); - properties.put("hibernate.dialect", - env.getProperty("hibernate.dialect")); + properties.put("hibernate.dialect", env.getProperty("hibernate.dialect")); properties.put("hibernate.order_inserts", true); properties.put("hibernate.jdbc.batch_size", 5000); properties.put("hibernate.order_updates", true); @@ -70,10 +60,8 @@ public LocalContainerEntityManagerFactoryBean devWriteEntityManager() { @Bean @Primary public DataSource devWriteDataSource() { - HikariDataSource dataSource - = new HikariDataSource(); - dataSource.setDriverClassName( - env.getProperty("jdbc.driverClassName")); + HikariDataSource dataSource = new HikariDataSource(); + dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); dataSource.setJdbcUrl(env.getProperty("jdbc.url")); dataSource.setUsername(env.getProperty("jdbc.user")); dataSource.setPassword(env.getProperty("jdbc.pass")); diff --git a/src/main/java/fi/hsl/transitlog/hfp/domain/Event.java b/src/main/java/fi/hsl/transitlog/hfp/domain/Event.java index d661f5e..ac21a09 100644 --- a/src/main/java/fi/hsl/transitlog/hfp/domain/Event.java +++ b/src/main/java/fi/hsl/transitlog/hfp/domain/Event.java @@ -16,13 +16,11 @@ @MappedSuperclass @EqualsAndHashCode -@JsonSubTypes({ - @JsonSubTypes.Type(value = VehiclePosition.class, name = "vehicleposition"), +@JsonSubTypes({@JsonSubTypes.Type(value = VehiclePosition.class, name = "vehicleposition"), @JsonSubTypes.Type(value = LightPriorityEvent.class, name = "lightpriorityevent"), @JsonSubTypes.Type(value = OtherEvent.class, name = "otherevent"), @JsonSubTypes.Type(value = StopEvent.class, name = "stopevent"), - @JsonSubTypes.Type(value = UnsignedEvent.class, name = "unsignedevent") -}) + @JsonSubTypes.Type(value = UnsignedEvent.class, name = "unsignedevent")}) @Data @Slf4j public abstract class Event { @@ -91,7 +89,8 @@ public Event(Hfp.Topic topic, Hfp.Payload payload) { this.route_id = topic.hasRouteId() ? topic.getRouteId() : null; this.direction_id = topic.hasDirectionId() ? topic.getDirectionId() : null; this.headsign = topic.hasHeadsign() ? topic.getHeadsign() : null; - Optional