### Question:
SameCodeManager { public List<SameCode> listSameCodes() { try{ return ImmutableList.copyOf(new ArrayList<SameCode>(sameCodes.get(Boolean.TRUE).getSameCodes().values())); }catch (ExecutionException e){ throw new UncheckedExecutionException(e.getCause()); } } SameCodeManager(Resource sameCodesResource, Resource stateCodeMappingResource); List<SameCode> listSameCodes(); String getSameCode(String stateCode, String county); List<String> listSameCounties(String stateCode); List<SameState> listSameStates();  }### Answer:
@Test public void testWatchedSAMECodeFileAndExpectSizes() throws Exception { final CountDownLatch latch = new CountDownLatch(1); _SAMECodeResource.addWatch(new ResourceListener() { @Override public void onChange() { latch.countDown(); } }); Thread.sleep(1000); String[] inputData = { "006059,Orange, CA" }; SameCode sameCode = new SameCode("006059","Orange","CA", "California"); TestUtils.appendLinesToFile(_SAMECodeFile, inputData); boolean changeDetected = latch.await(20, TimeUnit.SECONDS); assertTrue(changeDetected); List<SameCode> sameCodes = sameCodeManager.listSameCodes(); assertTrue(sameCodes.contains(sameCode)); }
@Test public void testWatchedSAMECodeFileAndExpectSizesForNewState() throws Exception { final CountDownLatch latch1 = new CountDownLatch(1); _SAMECodeResource.addWatch(new ResourceListener() { @Override public void onChange() { latch1.countDown(); } }); final CountDownLatch latch2 = new CountDownLatch(1); stateMappingResource.addWatch(new ResourceListener() { @Override public void onChange() { latch2.countDown(); } }); Thread.sleep(1000); String[] inputData = { "029151,Osage, MO" }; SameCode sameCode = new SameCode("029151","Osage","MO", "Missouri"); TestUtils.appendLinesToFile(_SAMECodeFile, inputData); boolean changeDetected = latch1.await(20, TimeUnit.SECONDS); assertTrue(changeDetected); assertFalse(sameCodeManager.listSameCodes().contains(sameCode)); String[] stateInputData = { "MO,Missouri"}; TestUtils.appendLinesToFile(stateMappingFile, stateInputData); changeDetected = latch2.await(30, TimeUnit.SECONDS); assertTrue(changeDetected); assertTrue(sameCodeManager.listSameCodes().contains(sameCode)); }