Exemplo n.º 1
0
  @Test
  public void shouldSearchExistingFlwsAndUpdateFlw() {
    Flw toBeUpdatedFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName1",
            flwGroupWithNameAndId("64a9a0928dde95d187544babf6c0ad38", "oldGroupName"));
    Flw notToBeUpdateFlw = flw("5ba9a0928dde95d187544babf6c0ad25", "FirstName2", new FlwGroup());
    template.saveOrUpdateAll(Arrays.asList(toBeUpdatedFlw, notToBeUpdateFlw));

    Flw newFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName3",
            flwGroupWithNameAndId("38a9a0928dde95d187544babf6c0ad64", "newGroupName"));
    ArrayList<Flw> flwsToUpdate = new ArrayList<>();
    flwsToUpdate.add(newFlw);

    careService.saveOrUpdateAllByExternalPrimaryKey(Flw.class, flwsToUpdate);

    Flw updatedFlw = template.load(Flw.class, toBeUpdatedFlw.getId());
    assertReflectionEqualsWithIgnore(
        newFlw, updatedFlw, new String[] {"id", "creationTime", "lastModifiedTime"});
    assertDateIgnoringSeconds(new Date(), updatedFlw.getCreationTime());
    assertDateIgnoringSeconds(new Date(), updatedFlw.getLastModifiedTime());

    Flw unchangedFlw = template.load(Flw.class, notToBeUpdateFlw.getId());
    assertEquals("FirstName2", unchangedFlw.getFirstName());
  }
Exemplo n.º 2
0
  @Test
  public void shouldSearchForExistingGroupBeforeUpdating() throws Exception {
    FlwGroup toBeUpdatedGroup =
        new FlwGroupBuilder()
            .groupId("5ba9a0928dde95d187544babf6c0ad24")
            .name("afrisis team 1")
            .domain("care-bihar")
            .awcCode("001")
            .caseSharing(true)
            .reporting(true)
            .build();
    FlwGroup notToBeUpdatedGroup =
        flwGroupWithNameAndId("5ba9a0928dde95d187544babf6c0af36", "ashok team 1");

    template.saveOrUpdateAll(Arrays.asList(toBeUpdatedGroup, notToBeUpdatedGroup));

    FlwGroup updatedGroup = updatedGroup();

    careService.saveOrUpdateAllByExternalPrimaryKey(FlwGroup.class, Arrays.asList(updatedGroup));

    FlwGroup loadedFlwGroup = template.load(FlwGroup.class, toBeUpdatedGroup.getId());
    FlwGroup unchangedFlwGroup = template.load(FlwGroup.class, notToBeUpdatedGroup.getId());
    assertReflectionEqualsWithIgnore(
        updatedGroup(), loadedFlwGroup, new String[] {"id", "creationTime", "lastModifiedTime"});
    assertDateIgnoringSeconds(new Date(), loadedFlwGroup.getCreationTime());
    assertDateIgnoringSeconds(new Date(), loadedFlwGroup.getLastModifiedTime());
    assertEquals("ashok team 1", unchangedFlwGroup.getName());
  }
Exemplo n.º 3
0
  @Test
  public void shouldCreateNewFlw() {
    Flw newFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName1",
            flwGroupWithNameAndId("64a9a0928dde95d187544babf6c0ad38", "oldGroupName"));

    careService.saveOrUpdateAllByExternalPrimaryKey(Flw.class, Arrays.asList(newFlw));

    List<Flw> flwsFromDb = template.loadAll(Flw.class);
    assertEquals(1, flwsFromDb.size());
    assertReflectionContains(newFlw, flwsFromDb, new String[] {"id"});
  }
Exemplo n.º 4
0
  @Test
  public void shouldSaveNewGroup() throws Exception {
    FlwGroup newGroup =
        new FlwGroupBuilder()
            .groupId("5ba9a0928dde95d187544babf6c0ad24")
            .name("amir team 1")
            .domain("care-mp")
            .awcCode("007")
            .caseSharing(true)
            .reporting(true)
            .build();

    careService.saveOrUpdateAllByExternalPrimaryKey(FlwGroup.class, Arrays.asList(newGroup));

    List<FlwGroup> flwGroupsFromDb = template.loadAll(FlwGroup.class);
    assertEquals(1, flwGroupsFromDb.size());
    assertReflectionContains(newGroup, flwGroupsFromDb, new String[] {"id"});
  }