{"size": 1362, "ext": "js", "max_stars_repo_path": "tests/processgraph.test.js", "max_stars_repo_name": "Open-EO/openeo-earthengine-driver", "max_stars_repo_stars_event_min_datetime": "2018-09-13T00:34:53.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-03T14:14:03.000Z", "max_issues_repo_path": "tests/processgraph.test.js", "max_issues_repo_name": "Open-EO/openeo-earthengine-driver", "max_issues_repo_issues_event_min_datetime": "2018-03-21T17:34:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-18T06:51:01.000Z", "max_forks_repo_path": "tests/processgraph.test.js", "max_forks_repo_name": "Open-EO/openeo-earthengine-driver", "max_forks_repo_forks_event_min_datetime": "2018-06-05T10:45:08.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-05T07:51:37.000Z"}
{"max_stars_count": 14, "max_issues_count": 59, "max_forks_count": 7, "avg_line_length": 34.9230769231, "max_line_length": 95, "alphanum_fraction": 0.6864904552}
const GeeProcessRegistry = require('../src/processgraph/registry');
const ServerContext = require('../src/servercontext');
const ProcessingContext = require('../src/processgraph/context');
const GeeProcessGraph = require('../src/processgraph/processgraph');
const json = require('./data/sample-processgraph.json');

describe('Process Graph Registry', () => {
	var p;

	beforeAll(async () => {
		let serverContext = new ServerContext();
		await serverContext.collections().loadCatalog();
		serverContext.processes().addFromFolder('./src/processes/');
		p = new GeeProcessGraph(json, new ProcessingContext(serverContext));
	});

	test('Processes', () => {
		let registry = p.getContext().server().processes();
		expect(registry.count()).toBe(66);
		expect(registry.get('load_collection')).not.toBe(null);
	});

	test('Collections', () => {
		let catalog = p.getContext().server().collections();
		expect(catalog.getData('COPERNICUS/S2')).not.toBe(null);
	});

	test('Validate', async () => {
		var errors = await p.validate(false);
		if (errors.count() > 0) {
			console.log(errors.getMessage());
		}
		expect(errors.count()).toBe(0);
		expect(p.getStartNodes().map(node => node.id)).toEqual(["load_collection"]);
		expect(p.getNode("load_collection").getNextNodes().map(n => n.id)).toEqual(["reduce_bands"]);
		expect(p.getResultNode().id).toBe("save");
	});

});