Skip to content

Commit

Permalink
Merge pull request openmrs#356 from isha-tripathi/TRUNK-3736
Browse files Browse the repository at this point in the history
modified Provider.toString() to return provider id with name
  • Loading branch information
dkayiwa committed Jul 31, 2013
2 parents 571f23a + 24e631e commit 249b805
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/src/main/java/org/openmrs/Provider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.common.base.Objects;

/**
* Represents a person who may provide care to a patient during an encounter
*
*
* @since 1.9
*/
public class Provider extends BaseCustomizableMetadata<ProviderAttribute> {
Expand Down Expand Up @@ -107,8 +105,10 @@ public String getIdentifier() {

@Override
public String toString() {
return Objects.toStringHelper(getClass()).add("providerId", providerId).add("identifier", identifier).add("person",
person).toString();
StringBuilder sb = new StringBuilder();
sb.append(providerId);
sb.append((person != null) ? person.getNames() : "");
return "[Provider: providerId: " + sb.toString() + " ]";
}

/**
Expand Down
19 changes: 19 additions & 0 deletions api/src/test/java/org/openmrs/ProviderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,23 @@ public void getName_shouldReturnPersonFullNameIfPersonIsNotNull() throws Excepti
provider.setPerson(person);
Assert.assertEquals(person.getPersonName().getFullName(), provider.getName());
}

/**
* @see {@link Provider#toString()}
*/
@Test
@Verifies(value = "return person all names of person with specific format", method = "toString()")
public void toString_shouldReturnPersonAllNamesWithSpecificFormat() throws Exception {
final String providerName = "Provider Name";

Provider provider = new Provider();
provider.setName(providerName);
provider.setProviderId(1);

Person person = new Person(1);
person.addName(new PersonName("givenName", "middleName", "familyName"));
provider.setPerson(person);
Assert.assertEquals(provider.toString(), "[Provider: providerId: 1[givenName middleName familyName] ]");
}

}

0 comments on commit 249b805

Please sign in to comment.