mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 05:55:51 +00:00
Added Test to illustrate access of store
Store access can now be achieved through data jpa tests
This commit is contained in:
parent
267fbb9d9d
commit
ed62231e88
3 changed files with 61 additions and 0 deletions
|
@ -33,4 +33,8 @@ public class NewOwnerStore {
|
|||
public StaticOwner convertToStaticOwner(Owner ownerEntity) {
|
||||
return new StaticOwner(ownerEntity.getAddress(), ownerEntity.getCity(), ownerEntity.getTelephone());
|
||||
}
|
||||
|
||||
public Map<Integer, StaticOwner> getNewOwnerStore() {
|
||||
return this.ownerStore;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,17 @@ public class StaticOwner {
|
|||
this.city = city;
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public String getAddress () {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public String getTelephone () {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Software property of Acquisio. Copyright 2003-2018.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.newDataStore;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.samples.petclinic.owner.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.owner.StaticOwner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Gibran
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest
|
||||
public class NewOwnerStoreTest {
|
||||
|
||||
@Autowired
|
||||
OwnerRepository owner;
|
||||
|
||||
NewOwnerStore testOwnerStore;
|
||||
|
||||
@Test
|
||||
public void testPopulation() {
|
||||
testOwnerStore = new NewOwnerStore(owner);
|
||||
testOwnerStore.populateStore();
|
||||
Map<Integer, StaticOwner> ownerStore = testOwnerStore.getNewOwnerStore();
|
||||
|
||||
for (Integer id: ownerStore.keySet()){
|
||||
|
||||
Integer key = id;
|
||||
String value = ownerStore.get(id).getAddress();
|
||||
System.out.println(key + " " + value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue