### Question:
ConnectedRealm extends PanacheEntityBase { public ConnectedRealm update(final ConnectedRealm connectedRealm) { return ConnectedRealmMapper.INSTANCE.toEntity(this, connectedRealm); } @Builder(toBuilder = true)  ConnectedRealm(
        final String id,
        final Region region,
        @Singular
        final Set<Realm> realms,
        final Map<FolderType, Folder> folders,
        final Set<AuctionFile> files); void addRealm(final Realm realm); ConnectedRealm create(); ConnectedRealm update(final ConnectedRealm connectedRealm);  }### Answer:
@Test @Transactional void update() { ConnectedRealm connectedRealm = ConnectedRealm.builder() .id(UUID.randomUUID().toString()) .region(Region.EU) .realms(new HashSet<>()) .realm(Realm.builder() .id(UUID.randomUUID().toString()) .name("Hellscream") .slug("hellscream") .build()) .build(); connectedRealm.create(); connectedRealm.flush(); ConnectedRealm updateRealm = connectedRealm.toBuilder() .realm(Realm.builder() .id(UUID.randomUUID().toString()) .name("Thrall") .slug("thrall") .connectedRealm(connectedRealm) .build()) .build(); Optional<ConnectedRealm> findConnectedRealm = ConnectedRealm.findByIdOptional(updateRealm.getId()); assertTrue(findConnectedRealm.isPresent()); assertEquals(1, findConnectedRealm.get().getRealms().size()); findConnectedRealm.ifPresent(updateRealm::update); findConnectedRealm.ifPresent(updatedRealm -> { assertEquals(connectedRealm.getId(), updatedRealm.getId()); assertEquals(2, updatedRealm.getRealms().size()); }); }