Polish
This commit is contained in:
@@ -22,7 +22,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import sample.data.gemfire.domain.Gemstone;
|
||||
import sample.data.gemfire.service.GemstoneService;
|
||||
import sample.data.gemfire.service.GemstoneServiceImpl.IllegalGemstoneException;
|
||||
import sample.data.gemfire.service.IllegalGemstoneException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -40,54 +40,42 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class SampleDataGemFireApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private GemstoneService gemstoneService;
|
||||
private GemstoneService service;
|
||||
|
||||
private final AtomicLong idGenerator = new AtomicLong(0L);
|
||||
|
||||
@Test
|
||||
public void gemstonesAppServiceEndpoints() {
|
||||
assertThat(this.gemstoneService.count()).isEqualTo(0);
|
||||
assertThat(this.gemstoneService.list()).isEmpty();
|
||||
|
||||
this.gemstoneService.save(createGemstone("Diamond"));
|
||||
this.gemstoneService.save(createGemstone("Ruby"));
|
||||
|
||||
assertThat(this.gemstoneService.count()).isEqualTo(2);
|
||||
assertThat(this.gemstoneService.list()).contains(
|
||||
getGemstones("Diamond", "Ruby"));
|
||||
|
||||
assertThat(this.service.count()).isEqualTo(0);
|
||||
assertThat(this.service.list()).isEmpty();
|
||||
this.service.save(createGemstone("Diamond"));
|
||||
this.service.save(createGemstone("Ruby"));
|
||||
assertThat(this.service.count()).isEqualTo(2);
|
||||
assertThat(this.service.list()).contains(getGemstones("Diamond", "Ruby"));
|
||||
try {
|
||||
this.gemstoneService.save(createGemstone("Coal"));
|
||||
this.service.save(createGemstone("Coal"));
|
||||
}
|
||||
catch (IllegalGemstoneException ignore) {
|
||||
// expected
|
||||
}
|
||||
|
||||
assertThat(this.gemstoneService.count()).isEqualTo(2);
|
||||
assertThat(this.gemstoneService.list()).contains(
|
||||
getGemstones("Diamond", "Ruby"));
|
||||
|
||||
this.gemstoneService.save(createGemstone("Pearl"));
|
||||
this.gemstoneService.save(createGemstone("Sapphire"));
|
||||
|
||||
assertThat(this.gemstoneService.count()).isEqualTo(4);
|
||||
assertThat(this.gemstoneService.list()).contains(
|
||||
getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
|
||||
|
||||
assertThat(this.service.count()).isEqualTo(2);
|
||||
assertThat(this.service.list()).contains(getGemstones("Diamond", "Ruby"));
|
||||
this.service.save(createGemstone("Pearl"));
|
||||
this.service.save(createGemstone("Sapphire"));
|
||||
assertThat(this.service.count()).isEqualTo(4);
|
||||
assertThat(this.service.list())
|
||||
.contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
|
||||
try {
|
||||
this.gemstoneService.save(createGemstone("Quartz"));
|
||||
this.service.save(createGemstone("Quartz"));
|
||||
}
|
||||
catch (IllegalGemstoneException ignore) {
|
||||
// expected
|
||||
}
|
||||
|
||||
assertThat(this.gemstoneService.count()).isEqualTo(4);
|
||||
assertThat(this.gemstoneService.list()).contains(
|
||||
getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
|
||||
assertThat(this.gemstoneService.get("Diamond")).isEqualTo(
|
||||
createGemstone("Diamond"));
|
||||
assertThat(this.gemstoneService.get("Pearl")).isEqualTo(
|
||||
createGemstone("Pearl"));
|
||||
assertThat(this.service.count()).isEqualTo(4);
|
||||
assertThat(this.service.list())
|
||||
.contains(getGemstones("Diamond", "Ruby", "Pearl", "Sapphire"));
|
||||
assertThat(this.service.get("Diamond")).isEqualTo(createGemstone("Diamond"));
|
||||
assertThat(this.service.get("Pearl")).isEqualTo(createGemstone("Pearl"));
|
||||
}
|
||||
|
||||
private Gemstone[] getGemstones(String... names) {
|
||||
|
||||
Reference in New Issue
Block a user