### Question:
JpaRegionWidgetRepository implements RegionWidgetRepository { @Override public RegionWidget save(RegionWidget item) { JpaRegionWidget region = regionWidgetConverter.convert(item); return saveOrUpdate(region.getEntityId(), manager, region); }  @Override Class<? extends RegionWidget> getType(); @Override RegionWidget get(String id); @Override RegionWidget save(RegionWidget item); @Override void delete(RegionWidget item); @Override List<RegionWidget> getAll(); @Override List<RegionWidget> getLimitedList(int offset, int pageSize); @Override int getCountAll();  }### Answer:
@Test @Rollback(true) public void save_newEntity() { RegionWidget regionWidget = new JpaRegionWidget(); regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>()); RegionWidget saved = repository.save(regionWidget); manager.flush(); assertThat(saved, is(sameInstance(regionWidget))); assertThat(saved.getId(), is(notNullValue())); }
@Test @Rollback(true) public void save_existingEntity() { RegionWidget regionWidget = new JpaRegionWidget(VALID_REGION_WIDGET_ID); regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>()); RegionWidget saved = repository.save(regionWidget); manager.flush(); assertThat(saved, is(not(sameInstance(regionWidget)))); assertThat(saved.getId(), is(equalTo(regionWidget.getId()))); }