### Question:
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);  }### Answer:
@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); }
@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); }