@@ -45,6 +45,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.batch</groupId>
|
||||
|
||||
@@ -1,42 +1,32 @@
|
||||
package io.spring.billrun;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.billrun.model.Bill;
|
||||
import javax.sql.DataSource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.batch.test.context.SpringBatchTest;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBatchTest
|
||||
public class BillrunApplicationTests {
|
||||
public class BillRunApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobResults() {
|
||||
testResult();
|
||||
}
|
||||
|
||||
private void testResult() {
|
||||
List<Bill> billStatements = this.jdbcTemplate.query("select id, " +
|
||||
"first_name, last_name, minutes, data_usage, bill_amount " +
|
||||
"FROM bill_statements ORDER BY id",
|
||||
@@ -44,14 +34,15 @@ public class BillrunApplicationTests {
|
||||
rs.getString("FIRST_NAME"), rs.getString("LAST_NAME"),
|
||||
rs.getLong("DATA_USAGE"), rs.getLong("MINUTES"),
|
||||
rs.getDouble("bill_amount")));
|
||||
assertEquals(5, billStatements.size());
|
||||
|
||||
assertThat(billStatements.size()).isEqualTo(5);
|
||||
Bill billStatement = billStatements.get(0);
|
||||
assertEquals(6, billStatement.getBillAmount(), 1e-15);
|
||||
assertEquals("jane", billStatement.getFirstName());
|
||||
assertEquals("doe", billStatement.getLastName());
|
||||
assertEquals(new Long(1), billStatement.getId());
|
||||
assertEquals(new Long(500), billStatement.getMinutes());
|
||||
assertEquals(new Long(1000), billStatement.getDataUsage());
|
||||
assertThat(billStatement.getBillAmount()).isEqualTo(6.0);
|
||||
assertThat(billStatement.getFirstName()).isEqualTo("jane");
|
||||
assertThat(billStatement.getLastName()).isEqualTo("doe");
|
||||
assertThat(billStatement.getId()).isEqualTo(1);
|
||||
assertThat(billStatement.getMinutes()).isEqualTo(500);
|
||||
assertThat(billStatement.getDataUsage()).isEqualTo(1000);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.spring.billsetuptask;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest
|
||||
class BillSetupTaskApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Test
|
||||
public void testRepository() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
int result = jdbcTemplate.queryForObject(
|
||||
"SELECT COUNT(*) FROM BILL_STATEMENTS", Integer.class);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.billsetuptask;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BillsetuptaskApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Test
|
||||
public void testRepository() {
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
int result = jdbcTemplate.queryForObject(
|
||||
"SELECT COUNT(*) FROM BILL_STATEMENTS", Integer.class);
|
||||
|
||||
assertEquals(0, result);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
@@ -34,14 +34,6 @@
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-task-dependencies</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user