Commit 12833a46 by jorgecacs

Implement and test done

parent e615b1e5
Pipeline #3 failed with stages
in 0 seconds
...@@ -44,12 +44,16 @@ ...@@ -44,12 +44,16 @@
<version>6.0</version> <version>6.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.microsoft.sqlserver</groupId>
<artifactId>h2</artifactId> <artifactId>mssql-jdbc</artifactId>
<version>1.4.196</version> <version>6.1.0.jre8</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
...@@ -2,6 +2,7 @@ package com.rshka.mcs.configuration; ...@@ -2,6 +2,7 @@ package com.rshka.mcs.configuration;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -15,14 +16,12 @@ public class DBConfiguration { ...@@ -15,14 +16,12 @@ public class DBConfiguration {
@Bean @Bean
public DataSource dataSource() { public DataSource dataSource() {
return new EmbeddedDatabaseBuilder() BasicDataSource dataSource = new BasicDataSource();
.generateUniqueName(false). dataSource.setUsername("sa");
setName("testdb") dataSource.setPassword("YourStrong!Passw0rd");
.setType(EmbeddedDatabaseType.H2) dataSource.setUrl("jdbc:sqlserver://localhost:1401;DatabaseName=demo_rshka");
.addDefaultScripts() dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
.setScriptEncoding("UTF-8") return dataSource;
.ignoreFailedDrops(true)
.build();
} }
@Bean @Bean
......
package com.rshka.mcs.configuration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.h2.server.web.WebServlet;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { AppConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
ServletRegistration.Dynamic servlet = servletContext.addServlet("h2-console", new WebServlet());
servlet.setLoadOnStartup(2);
servlet.addMapping("/console/*");
}
}
...@@ -3,7 +3,6 @@ package com.rshka.mcs.controllers; ...@@ -3,7 +3,6 @@ package com.rshka.mcs.controllers;
import java.util.List; import java.util.List;
import java.util.logging.ErrorManager; import java.util.logging.ErrorManager;
import org.h2.util.New;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
......
...@@ -90,7 +90,7 @@ public class CustomerDaoImpl implements CustomerDao { ...@@ -90,7 +90,7 @@ public class CustomerDaoImpl implements CustomerDao {
MapSqlParameterSource parameters = new MapSqlParameterSource(); MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("name", customer.getName()); parameters.addValue("name", customer.getName());
parameters.addValue("document", customer.getDocument()); parameters.addValue("document_number", customer.getDocument());
parameters.addValue("address", customer.getAddress()); parameters.addValue("address", customer.getAddress());
parameters.addValue("phone", customer.getPhoneNumber()); parameters.addValue("phone", customer.getPhoneNumber());
Number id = insert.executeAndReturnKey(parameters); Number id = insert.executeAndReturnKey(parameters);
......
...@@ -13,7 +13,7 @@ public class CustomerMapper implements RowMapper<Customer> { ...@@ -13,7 +13,7 @@ public class CustomerMapper implements RowMapper<Customer> {
Customer customer = new Customer(); Customer customer = new Customer();
customer.setAddress(rs.getString("address")); customer.setAddress(rs.getString("address"));
customer.setDocument(rs.getString("document")); customer.setDocument(rs.getString("document_number"));
customer.setName(rs.getString("name")); customer.setName(rs.getString("name"));
customer.setPhoneNumber(rs.getString("phone")); customer.setPhoneNumber(rs.getString("phone"));
return customer; return customer;
......
...@@ -17,26 +17,4 @@ ...@@ -17,26 +17,4 @@
<context:component-scan <context:component-scan
base-package="com.rshka.mcs" /> base-package="com.rshka.mcs" />
<!-- Use in-memory embedded H2 database -->
<jdbc:embedded-database id="dataSource"
type="H2">
</jdbc:embedded-database>
<!-- Run H2 web server within application that will access the same in-memory
database -->
<bean id="h2Server" class="org.h2.tools.Server"
factory-method="createTcpServer" init-method="start"
destroy-method="stop" depends-on="h2WebServer">
<constructor-arg
value="-tcp,-tcpAllowOthers,-tcpPort,9092" />
</bean>
<bean id="h2WebServer" class="org.h2.tools.Server"
factory-method="createWebServer" init-method="start"
destroy-method="stop">
<constructor-arg
value="-web,-webAllowOthers,-webPort,8082" />
</bean>
<bean factory-bean="dataSource" factory-method="getObject" />
</beans> </beans>
\ No newline at end of file
package com.example.demo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
@Test
public void contextLoads() {
}
}
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Thu Jan 16 07:31:55 PYST 2020 #Thu Jan 16 22:35:34 PYST 2020
version=0.0.1-SNAPSHOT version=0.0.1-SNAPSHOT
groupId=com.rshk.demo.mcs groupId=com.rshk.demo.mcs
m2e.projectName=demo_mcs m2e.projectName=demo_mcs
......
...@@ -44,12 +44,16 @@ ...@@ -44,12 +44,16 @@
<version>6.0</version> <version>6.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.microsoft.sqlserver</groupId>
<artifactId>h2</artifactId> <artifactId>mssql-jdbc</artifactId>
<version>1.4.196</version> <version>6.1.0.jre8</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
{
"info": {
"_postman_id": "19110da6-d426-4589-af54-86d64163d7ef",
"name": "DemoRshka",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "/customers/list",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/demo_mcs/customer/list",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"demo_mcs",
"customer",
"list"
]
}
},
"response": []
},
{
"name": "/api-customers/list",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/demo_itau/api-customers/list",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"demo_itau",
"api-customers",
"list"
]
}
},
"response": []
},
{
"name": "/customer/save",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"customer_name\":\"Persona Apellido\",\n\t\"customer_document\":\"1231231\",\n\t\"customer_address\":\"Avenida 1\",\n\t\"customer_number\":\"12312 12123\"\n}"
},
"url": {
"raw": "http://localhost:8080/demo_mcs/customer/save",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"demo_mcs",
"customer",
"save"
]
}
},
"response": []
},
{
"name": "/api-customer/save",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"customer_name\":\"Persona Apellido\",\n\t\"customer_document\":\"1231231\",\n\t\"customer_address\":\"Avenida 1\",\n\t\"customer_number\":\"12312 12123\"\n}"
},
"url": {
"raw": "http://localhost:8080/demo_itau/api-customers/save",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"demo_itau",
"api-customers",
"save"
]
}
},
"response": []
},
{
"name": "/customer/{document}",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/demo_mcs/customer/1231231",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"demo_mcs",
"customer",
"1231231"
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment