@Test public void getOrCreateScChamber_Found() { String chamberName = "chamber name"; SupremeCourtChamber scChamber = new SupremeCourtChamber(); when(scChamberRepository.findOneByName(chamberName)).thenReturn(scChamber); SupremeCourtChamber retScChamber = scChamberCreator.getOrCreateScChamber(chamberName); assertTrue(retScChamber == scChamber); verify(scChamberRepository).findOneByName(chamberName); 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);  }