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

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


  /**
   * {@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);

    final boolean hasErrors = messages.hasErrors();
    if (hasErrors) {
      eventService.sendErrorEvent(person, messages);
    }

    return !hasErrors;
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);

    final boolean hasErrors = messages.hasErrors();
    if (hasErrors) {
      eventService.sendErrorEvent(person, messages);
    }

    return !hasErrors;
View Full Code Here

   * override this method in our test and have it return a mock.
   *
   * @return A new instance of a {@link BusinessMessages} object.
   */
  protected BusinessMessages getNewBusinessMessagesInstance() {
    return new BusinessMessages();
  }
View Full Code Here

    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);
    expectLastCall().times(1);

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

    replayAll();

    assertTrue(tested.createPerson(firstName, lastName));
View Full Code Here

    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);
    expectLastCall().times(1);

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

    eventService.sendErrorEvent(personMock, businessMessagesMock);
    expectLastCall().times(1);

    replayAll();
View Full Code Here

TOP

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

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.