Package demo.org.powermock.examples.tutorial.domainmocking.domain

Examples of demo.org.powermock.examples.tutorial.domainmocking.domain.Person


  /**
   * {@inheritDoc}
   */
  public boolean createPerson(String firstName, String lastName) {
    BusinessMessages messages = new BusinessMessages();
    Person person = null;
    try {
      person = new Person(firstName, lastName);
    } catch (IllegalArgumentException e) {
      throw new SampleServiceException(e.getMessage(), e);
    }

    personService.create(person, messages);
View Full Code Here


  /**
   * {@inheritDoc}
   */
  public boolean createPerson(String firstName, String lastName) {
    BusinessMessages messages = getNewBusinessMessagesInstance();
    Person person = null;
    try {
      person = new Person(firstName, lastName);
    } catch (IllegalArgumentException e) {
      throw new SampleServiceException(e.getMessage(), e);
    }

    personService.create(person, messages);
View Full Code Here

  @Test
  public void testCreatePerson() throws Exception {
    // Mock the creation of person
    final String firstName = "firstName";
    final String lastName = "lastName";
    Person personMock = createMockAndExpectNew(Person.class, firstName, lastName);

    // Mock the creation of BusinessMessages
    BusinessMessages businessMessagesMock = createMockAndExpectNew(BusinessMessages.class);

    personServiceMock.create(personMock, businessMessagesMock);
View Full Code Here

  @Test
  public void testCreatePerson_error() throws Exception {
    // Mock the creation of person
    final String firstName = "firstName";
    final String lastName = "lastName";
    Person personMock = createMockAndExpectNew(Person.class, firstName, lastName);

    // Mock the creation of BusinessMessages
    BusinessMessages businessMessagesMock = createMockAndExpectNew(BusinessMessages.class);

    personServiceMock.create(personMock, businessMessagesMock);
View Full Code Here

    Method getNewBusinessMessagesInstanceMethod = SampleServiceWithoutPowerMockImpl.class.getDeclaredMethod("getNewBusinessMessagesInstance");
    tested = createMock(SampleServiceWithoutPowerMockImpl.class, constructorArgs, new Method[] { getNewBusinessMessagesInstanceMethod });

    expect(tested.getNewBusinessMessagesInstance()).andReturn(businessMessagesMock);

    personServiceMock.create(eq(new Person(firstName, lastName)), same(businessMessagesMock));
    expectLastCall().once();

    expect(businessMessagesMock.hasErrors()).andReturn(false);

    replayAll();
View Full Code Here

    Method getNewBusinessMessagesInstanceMethod = SampleServiceWithoutPowerMockImpl.class.getDeclaredMethod("getNewBusinessMessagesInstance");
    tested = createMock(SampleServiceWithoutPowerMockImpl.class, constructorArgs, new Method[] { getNewBusinessMessagesInstanceMethod });

    expect(tested.getNewBusinessMessagesInstance()).andReturn(businessMessagesMock);

    final Person person = new Person(firstName, lastName);
    personServiceMock.create(eq(person), same(businessMessagesMock));
    expectLastCall().once();

    expect(businessMessagesMock.hasErrors()).andReturn(true);
View Full Code Here

TOP

Related Classes of demo.org.powermock.examples.tutorial.domainmocking.domain.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.