[04.02.20] Attempting Spock Tests

This commit is contained in:
andyjk15 2020-02-04 17:42:45 +00:00
parent 0e7fbf9408
commit 434a6d1504
6 changed files with 105 additions and 18 deletions

25
pom.xml
View File

@ -101,11 +101,36 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.3-groovy-2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>Cryptosky DB Gateway</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>

View File

@ -1,7 +1,9 @@
package cryptosky.me.graphql.pricing.models.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Table;

View File

@ -36,9 +36,9 @@ public class CryptoPriceModel {
@Column(name = "volume")
private float volume;
private transient String formattedDate;
public String getFormattedDate() {
return getTimestamp().toString();
}
// private transient String formattedDate;
//
// public String getFormattedDate() {
// return getTimestamp().toString();
// }
}

View File

@ -1,13 +0,0 @@
package cryptosky.me.dbgateway;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DbGatewayApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -0,0 +1,44 @@
package integration.pricing.models.repositories
import cryptosky.me.graphql.pricing.models.entities.BtcPriceModel
import cryptosky.me.graphql.pricing.models.repositories.BtcPriceRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.Specification
@SpringBootTest
@DataJpaTest
class BtcPriceRepositoryTest extends Specification {
@Autowired
BtcPriceRepository btcPriceRepository
BtcPriceModel btcPriceModel
def setup() {
btcPriceModel = new BtcPriceModel("", "", 23F, 23.2F, 22.91F, 23.01F, 245F)
}
def "Data should be able to be saved to the repository if it required class variables"() {
when: "Load BTC price entity"
// btcPriceModel.setTimestamp("2020-02-03T15:00:00+00:00")
// btcPriceModel.setType("BTC-GBP")
// btcPriceModel.setAverage_price(23F)
// btcPriceModel.setHigh_price(23.12F)
// btcPriceModel.setLow_price(22.87F)
// btcPriceModel.setClose_price(23.1F)
// btcPriceModel.setVolume(345F)
println(btcPriceModel)
def entity = btcPriceRepository.save(btcPriceModel)
def result = btcPriceRepository.findOne(entity.getTimestamp())
then: "A single entry to exist in the repository"
btcPriceRepository.count() == 1L
entity.getTimestamp() == result.get().timestamp
}
}

View File

@ -0,0 +1,29 @@
package unit.groovy.pricing
import spock.lang.Specification
class BtcPriceServiceTest extends Specification {
void setup() {
}
void cleanup() {
}
def "CreateBtc"() {
}
def "GetAllPrices"() {
}
def "GetPricesBetweenCounts"() {
}
def "GetLatest"() {
}
def "GetPriceForCreatedDate"() {
}
def "GetPriceBetweenDates"() {
}
}