@Test public void getOrCreateScChamber_NotFound_Create() { String chamberName = "chamber name"; when(scChamberRepository.findOneByName(chamberName)).thenReturn(null); SupremeCourtChamber retScChamber = scChamberCreator.getOrCreateScChamber(chamberName); assertNotNull(retScChamber); assertEquals(chamberName, retScChamber.getName()); verify(scChamberRepository).findOneByName(chamberName); verify(scChamberRepository).saveAndFlush(retScChamber); verifyNoMoreInteractions(scChamberRepository); }
public SupremeCourtChamber getOrCreateScChamber(String chamberName) { Preconditions.checkArgument(StringUtils.isNotBlank(chamberName)); SupremeCourtChamber scChamber = scChamberRepository.findOneByName(chamberName); if (scChamber == null) { scChamber = new SupremeCourtChamber(); scChamber.setName(chamberName); scChamberRepository.saveAndFlush(scChamber); } return scChamber; }
ScChamberCreator { public SupremeCourtChamber getOrCreateScChamber(String chamberName) { Preconditions.checkArgument(StringUtils.isNotBlank(chamberName)); SupremeCourtChamber scChamber = scChamberRepository.findOneByName(chamberName); if (scChamber == null) { scChamber = new SupremeCourtChamber(); scChamber.setName(chamberName); scChamberRepository.saveAndFlush(scChamber); } return scChamber; } }
ScChamberCreator { public SupremeCourtChamber getOrCreateScChamber(String chamberName) { Preconditions.checkArgument(StringUtils.isNotBlank(chamberName)); SupremeCourtChamber scChamber = scChamberRepository.findOneByName(chamberName); if (scChamber == null) { scChamber = new SupremeCourtChamber(); scChamber.setName(chamberName); scChamberRepository.saveAndFlush(scChamber); } return scChamber; }  }
ScChamberCreator { public SupremeCourtChamber getOrCreateScChamber(String chamberName) { Preconditions.checkArgument(StringUtils.isNotBlank(chamberName)); SupremeCourtChamber scChamber = scChamberRepository.findOneByName(chamberName); if (scChamber == null) { scChamber = new SupremeCourtChamber(); scChamber.setName(chamberName); scChamberRepository.saveAndFlush(scChamber); } return scChamber; }  SupremeCourtChamber getOrCreateScChamber(String chamberName); @Autowired void setScChamberRepository(ScChamberRepository scChamberRepository); }
ScChamberCreator { public SupremeCourtChamber getOrCreateScChamber(String chamberName) { Preconditions.checkArgument(StringUtils.isNotBlank(chamberName)); SupremeCourtChamber scChamber = scChamberRepository.findOneByName(chamberName); if (scChamber == null) { scChamber = new SupremeCourtChamber(); scChamber.setName(chamberName); scChamberRepository.saveAndFlush(scChamber); } return scChamber; }  SupremeCourtChamber getOrCreateScChamber(String chamberName); @Autowired void setScChamberRepository(ScChamberRepository scChamberRepository);  }