当前位置: 首页>>代码示例>>Java>>正文


Java Owner.setLastName方法代码示例

本文整理汇总了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";
    }
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:25,代码来源:OwnerController.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:19,代码来源:AbstractClinicServiceTests.java

示例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";
    }
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:27,代码来源:OwnerController.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:19,代码来源:AbstractClinicServiceTests.java

示例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();
    }
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:26,代码来源:OwnerController.java

示例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());
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:17,代码来源:AbstractClinicServiceTests.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:15,代码来源:AbstractClinicServiceTests.java

示例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);

}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:15,代码来源:OwnerControllerTests.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:15,代码来源:AbstractClinicServiceTests.java

示例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());
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:11,代码来源:AbstractClinicServiceTests.java


注:本文中的org.springframework.samples.petclinic.model.Owner.setLastName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。