コード例 #1
0
  /**
   * @see Encounter#getProvidersByRoles()
   * @verifies return all roles and providers
   */
  @Test
  public void getProvidersByRoles_shouldReturnAllRolesAndProviders() throws Exception {
    // given
    Encounter encounter = new Encounter();
    EncounterRole role = new EncounterRole();

    Provider provider = new Provider();
    encounter.addProvider(role, provider);

    Provider provider2 = new Provider();
    encounter.addProvider(role, provider2);

    EncounterRole role2 = new EncounterRole();
    Provider provider3 = new Provider();
    encounter.addProvider(role2, provider3);

    // when
    Map<EncounterRole, Set<Provider>> providersByRoles = encounter.getProvidersByRoles();

    // then
    Assert.assertEquals("Roles", 2, providersByRoles.size());
    Assert.assertTrue("Roles", providersByRoles.keySet().containsAll(Arrays.asList(role, role2)));

    Assert.assertEquals("Providers for role", 2, providersByRoles.get(role).size());
    Assert.assertTrue(
        "Providers for role",
        providersByRoles.get(role).containsAll(Arrays.asList(provider, provider2)));

    Assert.assertEquals("Provider for role2", 1, providersByRoles.get(role2).size());
    Assert.assertTrue("Providers for role2", providersByRoles.get(role2).contains(provider3));
  }
コード例 #2
0
  /**
   * @see Encounter#getProvidersByRoles()
   * @verifies return empty map if no providers
   */
  @Test
  public void getProvidersByRoles_shouldReturnEmptyMapIfNoProviders() throws Exception {
    // given
    Encounter encounter = new Encounter();

    // when
    Map<EncounterRole, Set<Provider>> providersByRoles = encounter.getProvidersByRoles();

    // then
    Assert.assertEquals(0, providersByRoles.size());
  }
コード例 #3
0
  /**
   * @see Encounter#setProvider(Person)
   * @verifies set existing provider for unknown role
   */
  @Test
  public void setProvider_shouldSetExistingProviderForUnknownRole() throws Exception {
    // given
    Encounter encounter = new Encounter();
    EncounterRole unknownRole = new EncounterRole();
    Person person = new Person();
    Provider provider = new Provider();
    provider.setPerson(person);
    List<Provider> providers = new ArrayList<Provider>();
    providers.add(provider);

    when(encounterService.getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID))
        .thenReturn(unknownRole);

    when(providerService.getProvidersByPerson(person)).thenReturn(providers);

    // when
    encounter.setProvider(person);

    // then
    assertEquals(1, encounter.getProvidersByRoles().size());
    assertEquals(1, encounter.getProvidersByRole(unknownRole).size());
    assertEquals(provider, encounter.getProvidersByRole(unknownRole).iterator().next());
  }