Skip to content

Commit

Permalink
Merge pull request #92 from Backbase/ssdk16-review
Browse files Browse the repository at this point in the history
fix ArchUnit violations
  • Loading branch information
miladbb authored Aug 23, 2023
2 parents 0ae2130 + 5f21408 commit 3450612
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.backbase.example;
package com.backbase.example.api;

import com.backbase.example.Message;
import com.backbase.example.domain.Greeting;
import com.backbase.example.mapper.GreetingsMapper;
import com.backbase.example.service.GreetingsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import com.backbase.example.Message;
import com.backbase.example.domain.Greeting;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
@Mapper(unmappedTargetPolicy= ReportingPolicy.ERROR)
public interface GreetingsMapper {

GreetingsMapper INSTANCE = Mappers.getMapper( GreetingsMapper.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,43 @@

import com.backbase.example.domain.Greeting;
import com.backbase.example.repository.GreetingsRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

import java.util.List;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly=true)
public class GreetingsServiceImpl implements GreetingsService {

private static final Logger log = LoggerFactory.getLogger(GreetingsServiceImpl.class);

@Autowired
private GreetingsRepository greetingsRepository;

@Override
@PreAuthorize("permitAll()")
public List<Greeting> getGreetings() {
log.debug("Service getGreetings is called {}", 1);
return greetingsRepository.findAll();
}

@Override
@PreAuthorize("permitAll()")
public Greeting getGreetingById(String id) {
log.debug("Service getGreetingById is called {}", id);
return greetingsRepository.findById(id).get();
}

@Override
@PreAuthorize("permitAll()")
@Transactional
public void addNewGreeting(Greeting greeting) {
log.debug("Service addNewGreeting is called {}", 1);
greetingsRepository.save(greeting);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.backbase.example;
package com.backbase.example.api;

import com.backbase.example.Message;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.backbase.banking;
package com.backbase.banking.api;

import com.backbase.banking.Message;
import com.backbase.messaging.api.client.v2.MessageApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.backbase.banking;
package com.backbase.banking.config;

import com.backbase.buildingblocks.communication.client.ApiClientConfig;
import com.backbase.buildingblocks.communication.http.HttpCommunicationConfiguration;
import com.backbase.messaging.api.client.ApiClient;
import com.backbase.messaging.api.client.v2.MessageApi;
import org.springframework.context.annotation.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

// tag::MessagingServiceRestClientConfiguration[]
@Configuration
@ConfigurationProperties("backbase.communication.services.name")
@Validated
public class MessagingServiceRestClientConfiguration extends ApiClientConfig {

public static final String MESSAGING_SERVICE_ID = "messaging-service";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<output>${project.basedir}/target/boat-lint-reports</output>
<writeLintReport>true</writeLintReport>
<failOnWarning>true</failOnWarning>
<ignoreRules>219,215,218,115,134,104,105,110,176,M011,151,S007,S005,B013,H001</ignoreRules>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<properties>
<java.version>17</java.version>
<boat-maven-plugin.version>0.17.5</boat-maven-plugin.version>
] </properties>
</properties>

<dependencies>
<!-- tag::openapi-dependency[] -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.backbase.message;
package com.backbase.message.api;

import com.backbase.dbs.messaging_service.api.service.v2.MessageApi;
import com.backbase.dbs.messaging_service.api.service.v2.model.MessagePostResponseBody;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.backbase.example;
package com.backbase.example.api;

import com.backbase.buildingblocks.presentation.errors.InternalServerErrorException;
import com.backbase.example.api.client.v1.MessageApi;
import com.backbase.example.api.client.v1.model.MessagePostResponseBody;
import com.backbase.example.integration.MessageClient;
import com.backbase.example.client.MessageClient;
import com.backbase.example.mapper.IntegrationMessageMapper;
import com.backbase.example.model.Message;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.backbase.example.integration;
package com.backbase.example.client;

import com.backbase.example.model.Message;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.backbase.example.integration;
package com.backbase.example.client;

import com.backbase.example.model.Message;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

@Service
@Component
public class MessageClientImpl implements MessageClient {

private static final String SERVICE_URL = "http://echo.jsontest.com/messageId/abcdef-393939-dffdfdf/message/Hello%20World/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
public interface IntegrationMessageMapper {

IntegrationMessageMapper INSTANCE = Mappers.getMapper( IntegrationMessageMapper.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<output>${project.basedir}/target/boat-lint-reports</output>
<writeLintReport>true</writeLintReport>
<failOnWarning>true</failOnWarning>
<ignoreRules>219,215,218,115,134,104,105,110,176,M011,151,S007,S005,B013,H001</ignoreRules>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.backbase.example.domain.Greeting;
import com.backbase.example.repository.GreetingsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -16,24 +17,28 @@ public class GreetingsServiceImpl implements GreetingsService {

@Override
@Transactional(readOnly = true)
@PreAuthorize("permitAll()")
public List<Greeting> getGreetings() {
return greetingsRepository.findAll();
}

@Override
@Transactional(readOnly = true)
@PreAuthorize("permitAll()")
public Greeting getGreetingById(String id) {
return greetingsRepository.findById(id).get();
}

@Override
@Transactional
@PreAuthorize("permitAll()")
public void saveGreeting(Greeting greeting) {
greetingsRepository.save(greeting);
}

@Override
@Transactional
@PreAuthorize("permitAll()")
public void deleteGreeting(Greeting greeting) {
greetingsRepository.delete(greeting);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.backbase.example;
package com.backbase.example.controller;

import com.backbase.example.domain.Greeting;
import com.backbase.example.mapper.GreetingsMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.backbase.example.repository.GreetingsRepository;
import com.backbase.integration.example.client.v1.MessageApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -21,30 +22,35 @@ public class GreetingsServiceImpl implements GreetingsService {

@Override
@Transactional(readOnly = true)
@PreAuthorize("permitAll()")
public List<Greeting> getGreetings() {
return greetingsRepository.findAll();
}

// tag::getExternalGreetings[]
@Override
@Transactional(readOnly = true)
@PreAuthorize("permitAll()")
public List<Greeting> getExternalGreetings() {
return GreetingsMapper.INSTANCE.integrationMessageToGreeting(exampleIntegrationApiClient.getMessages());
}
// end::getExternalGreetings[]

@Override
@Transactional(readOnly = true)
@PreAuthorize("permitAll()")
public Greeting getGreetingById(String id) {
return greetingsRepository.findById(id).get();
}

@Override
@PreAuthorize("permitAll()")
public void saveGreeting(Greeting greeting) {
greetingsRepository.save(greeting);
}

@Override
@PreAuthorize("permitAll()")
public void deleteGreeting(Greeting greeting) {
greetingsRepository.delete(greeting);
}
Expand Down

0 comments on commit 3450612

Please sign in to comment.