本文整理汇总了Java中org.springframework.samples.petclinic.model.PetType类的典型用法代码示例。如果您正苦于以下问题:Java PetType类的具体用法?Java PetType怎么用?Java PetType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PetType类属于org.springframework.samples.petclinic.model包,在下文中一共展示了PetType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findById
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
JdbcPet pet;
try {
Map<String, Object> params = new HashMap<>();
params.put("id", id);
pet = this.namedParameterJdbcTemplate.queryForObject(
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
params,
new JdbcPetRowMapper());
} catch (EmptyResultDataAccessException ex) {
throw new ObjectRetrievalFailureException(Pet.class, id);
}
Owner owner = this.ownerRepository.findById(pet.getOwnerId());
owner.addPet(pet);
pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
for (Visit visit : visits) {
pet.addVisit(visit);
}
return pet;
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:24,代码来源:JdbcPetRepositoryImpl.java
示例2: shouldInsertPetIntoDatabaseAndGenerateId
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
@Transactional
public void shouldInsertPetIntoDatabaseAndGenerateId() {
Owner owner6 = this.clinicService.findOwnerById(6);
int found = owner6.getPets().size();
Pet pet = new Pet();
pet.setName("bowser");
Collection<PetType> types = this.clinicService.findPetTypes();
pet.setType(EntityUtils.getById(types, PetType.class, 2));
pet.setBirthDate(new LocalDate());
owner6.addPet(pet);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
this.clinicService.savePet(pet);
this.clinicService.saveOwner(owner6);
owner6 = this.clinicService.findOwnerById(6);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
// checks that id has been generated
assertThat(pet.getId()).isNotNull();
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:23,代码来源:AbstractClinicServiceTests.java
示例3: shouldInsertPetIntoDatabaseAndGenerateId
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
@Transactional
public void shouldInsertPetIntoDatabaseAndGenerateId() {
Owner owner6 = this.clinicService.findOwnerById(6);
int found = owner6.getPets().size();
Pet pet = new Pet();
pet.setName("bowser");
Collection<PetType> types = this.clinicService.findPetTypes();
pet.setType(EntityUtils.getById(types, PetType.class, 2));
pet.setBirthDate(new Date());
owner6.addPet(pet);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
this.clinicService.savePet(pet);
this.clinicService.saveOwner(owner6);
owner6 = this.clinicService.findOwnerById(6);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
// checks that id has been generated
assertThat(pet.getId()).isNotNull();
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:23,代码来源:AbstractClinicServiceTests.java
示例4: loadPetsAndVisits
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
public void loadPetsAndVisits(final Owner owner) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", owner.getId().intValue());
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE owner_id=:id",
params,
new JdbcPetRowMapper()
);
for (JdbcPet pet : pets) {
owner.addPet(pet);
pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
for (Visit visit : visits) {
pet.addVisit(visit);
}
}
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:18,代码来源:JdbcOwnerRepositoryImpl.java
示例5: findById
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
JdbcPet pet;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", id);
pet = this.namedParameterJdbcTemplate.queryForObject(
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
params,
new JdbcPetRowMapper());
} catch (EmptyResultDataAccessException ex) {
throw new ObjectRetrievalFailureException(Pet.class, new Integer(id));
}
Owner owner = this.ownerRepository.findById(pet.getOwnerId());
owner.addPet(pet);
pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
for (Visit visit : visits) {
pet.addVisit(visit);
}
return pet;
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:24,代码来源:JdbcPetRepositoryImpl.java
示例6: shouldInsertPetIntoDatabaseAndGenerateId
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
@Transactional
public void shouldInsertPetIntoDatabaseAndGenerateId() {
Owner owner6 = this.clinicService.findOwnerById(6);
int found = owner6.getPets().size();
Pet pet = new Pet();
pet.setName("bowser");
Collection<PetType> types = this.clinicService.findPetTypes();
pet.setType(EntityUtils.getById(types, PetType.class, 2));
pet.setBirthDate(new DateTime());
owner6.addPet(pet);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
this.clinicService.savePet(pet);
this.clinicService.saveOwner(owner6);
owner6 = this.clinicService.findOwnerById(6);
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
// checks that id has been generated
assertThat(pet.getId()).isNotNull();
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:23,代码来源:AbstractClinicServiceTests.java
示例7: findById
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
JdbcPet pet;
try {
Map<String, Object> params = new HashMap<>();
params.put("id", id);
pet = this.namedParameterJdbcTemplate.queryForObject(
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
params,
new JdbcPetRowMapper());
} catch (EmptyResultDataAccessException ex) {
throw new ObjectRetrievalFailureException(Pet.class, id);
}
Owner owner = this.ownerRepository.findById(pet.getOwnerId());
owner.addPet(pet);
pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));
List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
for (Visit visit : visits) {
pet.addVisit(visit);
}
return pet;
}
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:24,代码来源:JdbcPetRepositoryImpl.java
示例8: insertPet
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
@Transactional
public void insertPet() {
Owner owner6 = this.clinicService.findOwnerById(6);
int found = owner6.getPets().size();
Pet pet = new Pet();
pet.setName("bowser");
Collection<PetType> types = this.clinicService.findPetTypes();
pet.setType(EntityUtils.getById(types, PetType.class, 2));
pet.setBirthDate(new DateTime());
owner6.addPet(pet);
assertEquals(found + 1, owner6.getPets().size());
// both storePet and storeOwner are necessary to cover all ORM tools
this.clinicService.savePet(pet);
this.clinicService.saveOwner(owner6);
owner6 = this.clinicService.findOwnerById(6);
assertEquals(found + 1, owner6.getPets().size());
assertNotNull("Pet Id should have been generated", pet.getId());
}
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:20,代码来源:AbstractClinicServiceTests.java
示例9: parse
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public PetType parse(String text, Locale locale) throws ParseException {
Collection<PetType> findPetTypes = this.clinicService.findPetTypes();
for (PetType type : findPetTypes) {
if (type.getName().equals(text)) {
return type;
}
}
throw new ParseException("type not found: " + text, 0);
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:11,代码来源:PetTypeFormatter.java
示例10: loadPetsAndVisits
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
public void loadPetsAndVisits(final Owner owner) {
Map<String, Object> params = new HashMap<>();
params.put("id", owner.getId());
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
"SELECT pets.id, name, birth_date, type_id, owner_id, visits.id as visit_id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id",
params,
new JdbcPetVisitExtractor()
);
Collection<PetType> petTypes = getPetTypes();
for (JdbcPet pet : pets) {
pet.setType(EntityUtils.getById(petTypes, PetType.class, pet.getTypeId()));
owner.addPet(pet);
}
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:15,代码来源:JdbcOwnerRepositoryImpl.java
示例11: findPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public List<PetType> findPetTypes() throws DataAccessException {
Map<String, Object> params = new HashMap<>();
return this.namedParameterJdbcTemplate.query(
"SELECT id, name FROM types ORDER BY name",
params,
BeanPropertyRowMapper.newInstance(PetType.class));
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:9,代码来源:JdbcPetRepositoryImpl.java
示例12: testPrint
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
public void testPrint() {
PetType petType = new PetType();
petType.setName("Hamster");
String petTypeName = petTypeFormatter.print(petType, Locale.ENGLISH);
assertEquals("Hamster", petTypeName);
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:8,代码来源:PetTypeFormatterTests.java
示例13: makePetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
/**
* Helper method to produce some sample pet types just for test purpose
*
* @return {@link Collection} of {@link PetType}
*/
private Collection<PetType> makePetTypes() {
Collection<PetType> petTypes = new ArrayList<>();
petTypes.add(new PetType(){
{
setName("Dog");
}
});
petTypes.add(new PetType(){
{
setName("Bird");
}
});
return petTypes;
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:20,代码来源:PetTypeFormatterTests.java
示例14: shouldFindAllPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
public void shouldFindAllPetTypes() {
Collection<PetType> petTypes = this.clinicService.findPetTypes();
PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
assertThat(petType1.getName()).isEqualTo("cat");
PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
assertThat(petType4.getName()).isEqualTo("snake");
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:10,代码来源:AbstractClinicServiceTests.java
示例15: setup
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Before
public void setup() {
this.mockMvc = MockMvcBuilders
.standaloneSetup(petController)
.setConversionService(formattingConversionServiceFactoryBean.getObject())
.build();
PetType cat = new PetType();
cat.setId(3);
cat.setName("hamster");
given(this.clinicService.findPetTypes()).willReturn(Lists.newArrayList(cat));
given(this.clinicService.findOwnerById(TEST_OWNER_ID)).willReturn(new Owner());
given(this.clinicService.findPetById(TEST_PET_ID)).willReturn(new Pet());
}
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:15,代码来源:PetControllerTests.java
示例16: findPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public List<PetType> findPetTypes() throws DataAccessException {
Map<String, Object> params = new HashMap<String, Object>();
return this.namedParameterJdbcTemplate.query(
"SELECT id, name FROM types ORDER BY name",
params,
BeanPropertyRowMapper.newInstance(PetType.class));
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:9,代码来源:JdbcPetRepositoryImpl.java
示例17: findPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public List<PetType> findPetTypes() throws DataAccessException {
Map<String, Object> params = new HashMap<>();
return this.namedParameterJdbcTemplate.query(
"SELECT id, name FROM types ORDER BY name",
params,
BeanPropertyRowMapper.newInstance(PetType.class));
}
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:9,代码来源:JdbcPetRepositoryImpl.java
示例18: findPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Override
public List<PetType> findPetTypes() throws DataAccessException {
Map<String, Object> params = new HashMap<String, Object>();
return this.namedParameterJdbcTemplate.query(
"SELECT id, name FROM types ORDER BY name",
params,
ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
}
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:9,代码来源:JdbcPetRepositoryImpl.java
示例19: findPet
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
public void findPet() {
Collection<PetType> types = this.clinicService.findPetTypes();
Pet pet7 = this.clinicService.findPetById(7);
assertTrue(pet7.getName().startsWith("Samantha"));
assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), pet7.getType().getId());
assertEquals("Jean", pet7.getOwner().getFirstName());
Pet pet6 = this.clinicService.findPetById(6);
assertEquals("George", pet6.getName());
assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), pet6.getType().getId());
assertEquals("Peter", pet6.getOwner().getFirstName());
}
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:13,代码来源:AbstractClinicServiceTests.java
示例20: getPetTypes
import org.springframework.samples.petclinic.model.PetType; //导入依赖的package包/类
@Test
public void getPetTypes() {
Collection<PetType> petTypes = this.clinicService.findPetTypes();
PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
assertEquals("cat", petType1.getName());
PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
assertEquals("snake", petType4.getName());
}
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:10,代码来源:AbstractClinicServiceTests.java
注:本文中的org.springframework.samples.petclinic.model.PetType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论