本文整理汇总了Java中org.springframework.samples.petclinic.model.Owner.setLastName方法的典型用法代码示例。如果您正苦于以下问题:Java Owner.setLastName方法的具体用法?Java Owner.setLastName怎么用?Java Owner.setLastName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.samples.petclinic.model.Owner
的用法示例。
在下文中一共展示了Owner.setLastName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFindForm
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {
// allow parameterless GET request for /owners to return all records
if (owner.getLastName() == null) {
owner.setLastName(""); // empty string signifies broadest possible search
}
// find owners by last name
Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
if (results.isEmpty()) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
} else if (results.size() == 1) {
// 1 owner found
owner = results.iterator().next();
return "redirect:/owners/" + owner.getId();
} else {
// multiple owners found
model.put("selections", results);
return "owners/ownersList";
}
}
示例2: shouldInsertOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void shouldInsertOwner() {
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
int found = owners.size();
Owner owner = new Owner();
owner.setFirstName("Sam");
owner.setLastName("Schultz");
owner.setAddress("4, Evans Street");
owner.setCity("Wollongong");
owner.setTelephone("4444444444");
this.clinicService.saveOwner(owner);
assertThat(owner.getId().longValue()).isNotEqualTo(0);
owners = this.clinicService.findOwnerByLastName("Schultz");
assertThat(owners.size()).isEqualTo(found + 1);
}
示例3: processFindForm
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {
// allow parameterless GET request for /owners to return all records
if (owner.getLastName() == null) {
owner.setLastName(""); // empty string signifies broadest possible search
}
// find owners by last name
Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
if (results.isEmpty()) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
}
else if (results.size() == 1) {
// 1 owner found
owner = results.iterator().next();
return "redirect:/owners/" + owner.getId();
}
else {
// multiple owners found
model.put("selections", results);
return "owners/ownersList";
}
}
示例4: shouldInsertOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void shouldInsertOwner() {
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
int found = owners.size();
Owner owner = new Owner();
owner.setFirstName("Sam");
owner.setLastName("Schultz");
owner.setAddress("4, Evans Street");
owner.setCity("Wollongong");
owner.setTelephone("4444444444");
this.clinicService.saveOwner(owner);
assertThat(owner.getId().longValue()).isNotEqualTo(0);
owners = this.clinicService.findOwnerByLastName("Schultz");
assertThat(owners.size()).isEqualTo(found + 1);
}
示例5: processFindForm
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {
// allow parameterless GET request for /owners to return all records
if (owner.getLastName() == null) {
owner.setLastName(""); // empty string signifies broadest possible search
}
// find owners by last name
Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
if (results.size() < 1) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
}
if (results.size() > 1) {
// multiple owners found
model.put("selections", results);
return "owners/ownersList";
} else {
// 1 owner found
owner = results.iterator().next();
return "redirect:/owners/" + owner.getId();
}
}
示例6: insertOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void insertOwner() {
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
int found = owners.size();
Owner owner = new Owner();
owner.setFirstName("Sam");
owner.setLastName("Schultz");
owner.setAddress("4, Evans Street");
owner.setCity("Wollongong");
owner.setTelephone("4444444444");
this.clinicService.saveOwner(owner);
Assert.assertNotEquals("Owner Id should have been generated", owner.getId().longValue(), 0);
owners = this.clinicService.findOwnerByLastName("Schultz");
assertEquals("Verifying number of owners after inserting a new one.", found + 1, owners.size());
}
示例7: shouldUpdateOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void shouldUpdateOwner() {
Owner owner = this.clinicService.findOwnerById(1);
String oldLastName = owner.getLastName();
String newLastName = oldLastName + "X";
owner.setLastName(newLastName);
this.clinicService.saveOwner(owner);
// retrieving new name from database
owner = this.clinicService.findOwnerById(1);
assertThat(owner.getLastName()).isEqualTo(newLastName);
}
示例8: setup
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.standaloneSetup(ownerController).build();
george = new Owner();
george.setId(TEST_OWNER_ID);
george.setFirstName("George");
george.setLastName("Franklin");
george.setAddress("110 W. Liberty St.");
george.setCity("Madison");
george.setTelephone("6085551023");
given(this.clinicService.findOwnerById(TEST_OWNER_ID)).willReturn(george);
}
示例9: shouldUpdateOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void shouldUpdateOwner() {
Owner owner = this.clinicService.findOwnerById(1);
String oldLastName = owner.getLastName();
String newLastName = oldLastName + "X";
owner.setLastName(newLastName);
this.clinicService.saveOwner(owner);
// retrieving new name from database
owner = this.clinicService.findOwnerById(1);
assertThat(owner.getLastName()).isEqualTo(newLastName);
}
示例10: updateOwner
import org.springframework.samples.petclinic.model.Owner; //导入方法依赖的package包/类
@Test
@Transactional
public void updateOwner() throws Exception {
Owner o1 = this.clinicService.findOwnerById(1);
String old = o1.getLastName();
o1.setLastName(old + "X");
this.clinicService.saveOwner(o1);
o1 = this.clinicService.findOwnerById(1);
assertEquals(old + "X", o1.getLastName());
}