This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile group: 'org.springframework.boot', name: 'spring-boot-starter' | |
testImplementation('org.junit.jupiter:junit-jupiter-api:5.2.0') | |
testCompile('org.junit.jupiter:junit-jupiter-params:5.2.0') | |
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.2.0') | |
testCompile "org.mockito:mockito-core:2.+" | |
testCompile('org.mockito:mockito-junit-jupiter:2.18.3') | |
testCompile('org.springframework.boot:spring-boot-starter-test') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(classes = {DbConfig.class}) | |
@ActiveProfiles("DaoTest") | |
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:dao/TestData.sql") | |
public class PostgresEmbeddedDaoTestingApplicationTests { | |
@Autowired | |
private CustomerRepository customerRepository; | |
@Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableTransactionManagement | |
@EnableJpaRepositories(basePackageClasses = {CustomerRepository.class}) | |
@Profile("DaoTest") | |
public class DbConfig { | |
private static final List<String> DEFAULT_ADDITIONAL_INIT_DB_PARAMS = Arrays | |
.asList("--nosync", "--locale=en_US.UTF-8"); | |
/** | |
* @param config the PostgresConfig configuration to use to start Postgres db process | |
* @return PostgresProcess , the started db process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | |
public interface CustomerMapper { | |
CustomerDto mapCustomerToDto(Customer customer); | |
Customer mapeDtoToCustomer(CustomerDto customerDto); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* main customer repository | |
*/ | |
@Repository | |
@Transactional | |
public interface CustomerRepository extends CrudRepository<Customer, Long> { | |
Optional<Customer> findCustomerByName(String name); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity(name = "customer") | |
@Data | |
@AllArgsConstructor | |
@NoArgsConstructor | |
@Builder | |
public class Customer { | |
@Id | |
private long id; | |
private String name; | |
private String address; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* the db spring configuration to use in production , to be replaced with actual production configuration , that is for local run only | |
*/ | |
@Configuration | |
@EnableTransactionManagement | |
public class DbConfig { | |
private static final List<String> DEFAULT_ADDITIONAL_INIT_DB_PARAMS = Arrays | |
.asList("--nosync", "--locale=en_US.UTF-8"); | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>ru.yandex.qatools.embed</groupId> | |
<artifactId>postgresql-embedded</artifactId> | |
<version>2.9</version> | |
</dependency> | |
<dependency> | |
<groupId>org.postgresql</groupId> | |
<artifactId>postgresql</artifactId> | |
<scope>runtime</scope> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>org.xolstice.maven.plugins</groupId> | |
<artifactId>protobuf-maven-plugin</artifactId> | |
<version>0.5.1</version> | |
<configuration> | |
<protocExecutable>/usr/local/opt/protobuf/bin/protoc</protocExecutable> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The main order domain REST API | |
* | |
* @author romeh | |
*/ | |
@RestController | |
@RequestMapping("/orders") | |
@Api(value = "Order Manager REST API demo") | |
public class OrderRestController { |