Skip to content

Commit

Permalink
feat : sonar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Feb 9, 2024
1 parent 9536c4d commit e8515c5
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion graphql/boot-graphql-querydsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
<configuration>
<java>
<palantirJavaFormat>
<version>2.38.0</version>
<version>2.39.0</version>
</palantirJavaFormat>
<importOrder />
<removeUnusedImports />
Expand Down
2 changes: 1 addition & 1 deletion graphql/boot-graphql-webflux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<configuration>
<java>
<palantirJavaFormat>
<version>2.38.0</version>
<version>2.39.0</version>
</palantirJavaFormat>
<importOrder />
<removeUnusedImports />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ default void afterMapping(
.contains(tagEntity.getTagName()))
.toList();

for (TagEntity tagEntity : tagEntitiesToUpdate) {
for (TagsRequest tagsRequest : newPostRequest.tags()) {
if (tagEntity.getTagName().equalsIgnoreCase(tagsRequest.tagName())) {
tagEntity.setTagDescription(tagsRequest.tagDescription());
break;
}
}
}

List<TagsRequest> tagEntitiesToInsert =
newPostRequest.tags().stream()
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor {

@Override
public Object postProcessAfterInitialization(@NonNull Object bean, @NonNull String beanName) {
if (bean instanceof DataSource && !(bean instanceof ProxyDataSource)) {
if (bean instanceof DataSource dataSource && !(bean instanceof ProxyDataSource)) {

final ProxyFactory factory = new ProxyFactory(bean);
factory.setProxyTargetClass(true);
factory.addAdvice(new ProxyDataSourceInterceptor((DataSource) bean));
factory.addAdvice(new ProxyDataSourceInterceptor(dataSource));
return factory.getProxy();
}
return bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
Expand All @@ -29,7 +28,7 @@ public Specification<T> specificationBuilder(SearchCriteria[] searchCriteria) {
Stream.of(searchCriteria)
.filter(Objects::nonNull)
.map(this::createSpecification)
.collect(Collectors.toList());
.toList();

return Specification.allOf(specifications);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor {

@Override
public Object postProcessAfterInitialization(@NonNull Object bean, @NonNull String beanName) {
if (bean instanceof DataSource && !(bean instanceof ProxyDataSource)) {
if (bean instanceof DataSource dataSource && !(bean instanceof ProxyDataSource)) {

final ProxyFactory factory = new ProxyFactory(bean);
factory.setProxyTargetClass(true);
factory.addAdvice(new ProxyDataSourceInterceptor((DataSource) bean));
factory.addAdvice(new ProxyDataSourceInterceptor(dataSource));
return factory.getProxy();
}
return bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Movie {
private BigDecimal budget;

@OneToMany(mappedBy = "movie", cascade = CascadeType.ALL)
private List<Review> reviews;
private List<Reviews> reviews;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "director_id")
Expand Down Expand Up @@ -66,7 +66,7 @@ public Movie setBudget(BigDecimal budget) {
return this;
}

public Movie setReviews(List<Review> reviews) {
public Movie setReviews(List<Reviews> reviews) {
this.reviews = reviews;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Setter
@NoArgsConstructor
@Table(name = "reviews")
public class Review {
public class Reviews {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import com.example.locks.entities.Actor;
import com.example.locks.entities.Genre;
import com.example.locks.entities.Movie;
import com.example.locks.entities.Review;
import com.example.locks.entities.Reviews;
import com.example.locks.model.request.ActorRequest;
import com.example.locks.model.request.MovieRequest;
import com.example.locks.model.response.ActorResponse;
import com.example.locks.model.response.MovieResponse;
import java.util.List;
import java.util.stream.Collectors;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
Expand All @@ -23,7 +22,7 @@ public interface JpaLocksMapper {
default Movie movieRequestToMovieEntity(MovieRequest movieRequest) {
var movie = movieRequestToMovie(movieRequest);
for (Actor a : movie.getActors()) a.setMovies(List.of(movie));
for (Review r : movie.getReviews()) r.setMovie(movie);
for (Reviews r : movie.getReviews()) r.setMovie(movie);
for (Genre g : movie.getGenres()) g.setMovies(List.of(movie));
return movie;
}
Expand All @@ -33,7 +32,7 @@ default Movie movieRequestToMovieEntity(MovieRequest movieRequest) {
MovieResponse movieToMovieResponse(Movie movie);

default List<MovieResponse> moviesListToMovieResponseList(List<Movie> moviesList) {
return moviesList.stream().map(this::movieToMovieResponse).collect(Collectors.toList());
return moviesList.stream().map(this::movieToMovieResponse).toList();
}

ActorResponse actorToActorResponse(Actor actor);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.locks.repositories;

import com.example.locks.entities.Reviews;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ReviewsRepository extends JpaRepository<Reviews, Long> {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@DataJpaTest
@Disabled
public class ActorEntityTest {
class ActorEntityTest {

@Autowired
private TestEntityManager entityManager;
Expand All @@ -26,7 +26,7 @@ public class ActorEntityTest {

@Test
@Transactional
public void testPessimisticWriteLock() {
void testPessimisticWriteLock() {
Actor entityToSave = new Actor();
entityToSave.setActorName("TestEntityName");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.example.locks.model.request.MovieRequest;
import com.example.locks.model.request.ReviewRequest;
import com.example.locks.repositories.MovieRepository;
import com.example.locks.repositories.ReviewRepository;
import com.example.locks.repositories.ReviewsRepository;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
Expand All @@ -39,7 +39,7 @@ class MovieControllerIT extends AbstractIntegrationTest {
private MovieRepository movieRepository;

@Autowired
private ReviewRepository reviewRepository;
private ReviewsRepository reviewRepository;

private List<Movie> movieList = null;

Expand Down

0 comments on commit e8515c5

Please sign in to comment.