EntityLoaderBase implements EntityLoader { public Map<String, Object> load(File entitiesFile) { return loadEntitiesFromFile(jsonTools, this.getBeanClass(), entitiesFile); } @VisibleForTesting protected  EntityLoaderBase(final JsonTools jsonTools, final IdGenerator idGenerator); Object loadSingle(String name, File entitiesFile); Map<String, Object> load(File entitiesFile); @Override void load(final Bundle bundle, final File rootDir); @Override void load(Bundle bundle, String fullName, String value);  }
@Test void loadSingleYaml() { AtomicBoolean putToBundle = new AtomicBoolean(false); EntityLoader loader = new TestEntityLoader(putToBundle); loader.load(null, "test.yaml", "name: custom"); assertTrue(putToBundle.get()); putToBundle.set(false); loader.load(null, "test.yml", "{\"name\":\"custom\"}"); assertTrue(putToBundle.get()); }
@Test void loadFile() { AtomicBoolean putToBundle = new AtomicBoolean(false); EntityLoader loader = new TestEntityLoader(jsonTools, putToBundle); when(jsonTools.getDocumentFile(any(File.class), any(String.class))).thenReturn(new File("")); when(jsonTools.readDocumentFile(any(File.class), any(JavaType.class))).thenReturn(ImmutableMap.<String, TestEntity>builder().put("test", new TestEntity("custom")).build()); when(jsonTools.getTypeFromFile(any(File.class))).thenReturn(JsonTools.JSON); when(jsonTools.getObjectMapper(any(String.class))).thenReturn(JsonTools.INSTANCE.getObjectMapper(JsonTools.JSON)); loader.load(null, new File("")); assertTrue(putToBundle.get()); }