Added Test to illustrate access of store

Store access can now be achieved through data jpa tests
This commit is contained in:
Unknown 2018-04-02 22:30:34 -04:00
parent 267fbb9d9d
commit ed62231e88
3 changed files with 61 additions and 0 deletions

View file

@ -33,4 +33,8 @@ public class NewOwnerStore {
public StaticOwner convertToStaticOwner(Owner ownerEntity) { public StaticOwner convertToStaticOwner(Owner ownerEntity) {
return new StaticOwner(ownerEntity.getAddress(), ownerEntity.getCity(), ownerEntity.getTelephone()); return new StaticOwner(ownerEntity.getAddress(), ownerEntity.getCity(), ownerEntity.getTelephone());
} }
public Map<Integer, StaticOwner> getNewOwnerStore() {
return this.ownerStore;
}
} }

View file

@ -17,4 +17,17 @@ public class StaticOwner {
this.city = city; this.city = city;
this.telephone = telephone; this.telephone = telephone;
} }
public String getAddress () {
return address;
}
public String getCity() {
return city;
}
public String getTelephone () {
return telephone;
}
} }

View file

@ -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);
}
}
}