### Question:
FixtureAnnotations { public static void initFixtures(Object targetInstance) throws Exception { initFixtures(targetInstance, null); }  static void initFixtures(Object targetInstance); static void initFixtures(Object targetInstance, Settings.Builder settings);  }### Answer:
@Test public void shouldInitializeBeans() throws Exception { FixtureAnnotations.initFixtures(this); checkFixture1(bean1); assertThat(bean2).isNotNull(); assertThat(bean2.getStringProperty()).isEqualTo("property2"); assertThat(bean2.getIntProperty()).isEqualTo(1); assertThat(bean3).isNotNull(); assertThat(bean3.getStringProperty()).isEqualTo("property"); assertThat(bean3.getIntProperty()).isEqualTo(1); assertThat(bean3.getListProperty()).containsExactly("element1", "element2", "element3"); assertThat(bean4).isNotNull(); assertThat(bean4.getStringProperty()).isEqualTo("property"); assertThat(bean4.getIntProperty()).isEqualTo(3); checkList(beanList); checkSet(beanSet); checkList(Arrays.asList(beanArray)); }
@Test public void defaultFixtureNames() throws Exception { FixtureAnnotations.initFixtures(this); checkFixture1(fixture1); checkList(fixture6); }
@Test public void shouldUseDifferentSettingsInEachThread() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); FileNamingStrategy fileNamingStrategy = (folder, fileNamePrefix, fixtureName) -> "abc.test"; Settings.Builder settings = new Settings.Builder().setObjectMapper(objectMapper) .setDefaultSnapshotWriter() .setGeneratorFileNamingStrategy(fileNamingStrategy) .setSnapshotFileNamingStrategy(fileNamingStrategy); FixtureAnnotations.initFixtures(this, settings); Thread t2 = new Thread() { @Override public void run() { FileNamingStrategy fileNamingStrategy = (folder, fileNamePrefix, fixtureName) -> "cba.test"; Settings.Builder settings = new Settings.Builder().setDefaultObjectMapper() .setGeneratorFileNamingStrategy(fileNamingStrategy) .setSnapshotFolderPath("a/b/c"); try { FixtureAnnotations.initFixtures(this, settings); } catch (Exception e) { throw new RuntimeException(e); } assertThat(settings().getObjectMapper()).isNotEqualTo(objectMapper); assertThat(settings().getGeneratorFileNamingStrategy()).isEqualTo(fileNamingStrategy); assertThat(settings().getSnapshotFileNamingStrategy()).isEqualTo(fileNamingStrategy); assertThat(settings().getSnapshotFixtureWriter()).isInstanceOf(StaticPathDefaultSnapshotWriter.class); } }; t2.start(); t2.join(); assertThat(settings().getObjectMapper()).isEqualTo(objectMapper); assertThat(settings().getGeneratorFileNamingStrategy()).isEqualTo(fileNamingStrategy); assertThat(settings().getSnapshotFileNamingStrategy()).isEqualTo(fileNamingStrategy); assertThat(settings().getSnapshotFixtureWriter()).isInstanceOf(DefaultSnapshotWriter.class); }