URLFactoryBuilder { public Optional<FactoryDto> createFactoryFromJson(RemoteFactoryUrl remoteFactoryUrl) { if (remoteFactoryUrl.factoryFileLocation() != null) { final String factoryJsonContent = urlFetcher.fetchSafely(remoteFactoryUrl.factoryFileLocation()); if (!isNullOrEmpty(factoryJsonContent)) { FactoryDto factoryDto = DtoFactory.getInstance() .createDtoFromJson(factoryJsonContent, FactoryDto.class) .withSource(remoteFactoryUrl.getFactoryFilename()); return Optional.of(factoryDto); } } return Optional.empty(); } @Inject  URLFactoryBuilder(
      @Named("che.factory.default_editor") String defaultCheEditor,
      @Named("che.factory.default_plugins") String defaultChePlugins,
      URLFetcher urlFetcher,
      DevfileParser devfileParser); Optional<FactoryDto> createFactoryFromJson(RemoteFactoryUrl remoteFactoryUrl); Optional<FactoryDto> createFactoryFromDevfile(
      RemoteFactoryUrl remoteFactoryUrl,
      FileContentProvider fileContentProvider,
      Map<String, String> overrideProperties); WorkspaceConfigDto buildDefaultWorkspaceConfig(String name); DevfileDto buildDefaultDevfile(String name);  }
@Test public void checkWithCustomFactoryJsonFile() throws Exception { WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class); FactoryDto templateFactory = newDto(FactoryDto.class) .withV(CURRENT_VERSION) .withName("florent") .withWorkspace(workspaceConfigDto); String jsonFactory = DtoFactory.getInstance().toJson(templateFactory); String myLocation = "http: when(urlFetcher.fetchSafely(myLocation)).thenReturn(jsonFactory); FactoryDto factory = urlFactoryBuilder .createFactoryFromJson( new DefaultFactoryUrl() .withFactoryFileLocation(myLocation) .withFactoryFilename(".factory.json")) .get(); assertEquals(templateFactory.withSource(".factory.json"), factory); }