text:
package com.gs.collections.impl.map.immutable;

import java.util.HashMap;
import java.util.Map;

import com.gs.collections.api.map.ImmutableMap;
import com.gs.collections.api.map.MutableMap;
import org.junit.Assert;
import org.junit.Test;

/**
 * JUnit test for {@link ImmutableMap}.
 */
public abstract class ImmutableMapTestCase extends ImmutableMapIterableTestCase
{
    @Override
    protected abstract ImmutableMap<Integer, String> classUnderTest();

    @Test
    public void castToMap()
    {
        ImmutableMap<Integer, String> immutable = this.classUnderTest();
        Map<Integer, String> map = immutable.castToMap();
        Assert.assertSame(immutable, map);
        Assert.assertEquals(immutable, new HashMap<>(map));
    }

    @Test
    public void toMap()
    {
        ImmutableMap<Integer, String> immutable = this.classUnderTest();
        MutableMap<Integer, String> map = immutable.toMap();
        Assert.assertNotSame(immutable, map);
        Assert.assertEquals(immutable, map);
    }

    @Test
    public void entrySet()
    {
        ImmutableMap<Integer, String> immutable = this.classUnderTest();
        Map<Integer, String> map = new HashMap<>(immutable.castToMap());
        Assert.assertEquals(immutable.size(), immutable.castToMap().entrySet().size());
        Assert.assertEquals(map.entrySet(), immutable.castToMap().entrySet());
    }
}

redpajama_set_name: RedPajamaGithub


text:
/*global QUnit*/

sap.ui.define([
	"sap/ui/fl/apply/_internal/changes/descriptor/ui5/AddNewModel",
	"sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange"
],
function (
	AddNewModel,
	AppDescriptorChange
) {
	"use strict";

	QUnit.module("applyChange", {
	}, function() {
		var ADDED_MODEL = "the sap.ui5 model {0} was added correctly.";
		var ALREADY_EXISTING_MODEL = "the already existing sap.ui5 model {0} was not overridden or changed.";
		var ADDED_DATASOURCE = "the sap.app dataSource {0} was added correctly.";
		var ALREADY_EXISTING_DATASOURCE = "the already existing sap.app dataSource {0} was not overridden or changed.";

		QUnit.test("when calling '_applyChange' with adding a new model => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {
								localUri: "model/annotations.xml"
							}
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						"customer.fancy_dataSource": {
							uri: "/sap/opu/odata/snce/PO_S_SRV;v=2/",
							type: "OData",
							settings: {
								odataVersion: "2.0",
								annotations: ["customer.fancy_annotation"]
							}
						},
						"customer.fancy_annotation": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {}
						}
					},
					model: {
						"customer.fancy_model": {
							dataSource: "customer.fancy_dataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("customer.fancy_model"), true, ADDED_MODEL.replace("{0}", "object customer.fancy_model"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["customer.fancy_model"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["i18n"]["type"], "sap.ui.model.resource.ResourceModel", ALREADY_EXISTING_MODEL.replace("{0}", "type"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["i18n"]["uri"], "i18n/i18n.properties", ALREADY_EXISTING_MODEL.replace("{0}", "uri"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_dataSource"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_dataSource object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["uri"], "/sap/opu/odata/snce/PO_S_SRV;v=2/", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["type"], "OData", ADDED_DATASOURCE.replace("{0}", "type"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_annotation"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_annotation object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["uri"], "/sap/opu/odata/snce/PO_S_SRV;v=2/", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["type"], "OData", ADDED_DATASOURCE.replace("{0}", "type"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("equipmentanno"), true, ALREADY_EXISTING_DATASOURCE.replace("{0}", "equipmentanno"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["uri"], "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML", ALREADY_EXISTING_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["type"], "ODataAnnotation", ALREADY_EXISTING_DATASOURCE.replace("{0}", "type"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"].hasOwnProperty("settings"), true, ALREADY_EXISTING_DATASOURCE.replace("{0}", "settings object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["settings"]["localUri"], "model/annotations.xml", ALREADY_EXISTING_DATASOURCE.replace("{0}", "settings localUri"));
		});

		QUnit.test("when calling '_applyChange' with adding an already existing model => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/odata",
							type: "OData"
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The model 'i18n' already exists"),
			"throws error that model i18n already exists");
		});

		QUnit.test("when calling '_applyChange' with adding an already existing dataSource => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/odata",
							type: "OData"
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						equipmentanno: {
							uri: "/sap/odata",
							type: "OData"
						}
					},
					model: {
						myModel: {
							dataSource: "equipmentanno",
							uri: "my/model"
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The dataSource 'equipmentanno' already exists"),
			"throws error that dataSource equipmentanno already exists");
		});

		QUnit.test("when calling '_applyChange' by adding a new model which refers to a not existing dataSource in the change or manifest => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/test.json",
							type: "JSON"
						},
						otherDataSource: {
							uri: "/sap/odata",
							type: "OData"
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment: {
							preload: true,
							dataSource: "notExistingDataSource",
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The defined dataSource 'notExistingDataSource' in the model does not exists as dataSource or must be allowed type of OData|INA|XML|JSON|FHIR|http|WebSocket"),
			"throws error that some dataSource which is defined in a model does not exists in the manifest or in the change or is not type of OData|INA|XML|JSON|FHIR|http|WebSocket");
		});

		QUnit.test("when calling '_applyChange' with adding a new model which refers to an existing dataSource with no type is defined (default 'OData') => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							settings: {
								localUri: "model/oData.xml"
							}
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment: {
							preload: true,
							dataSource: "equipmentanno"
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("equipmentanno"), true, ALREADY_EXISTING_DATASOURCE.replace("{0}", "equipmentanno"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["uri"], "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML", ALREADY_EXISTING_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["type"], undefined, "there is no type defined but default is 'OData'");
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"].hasOwnProperty("settings"), true, ALREADY_EXISTING_DATASOURCE.replace("{0}", "settings object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentanno"]["settings"]["localUri"], "model/oData.xml", ALREADY_EXISTING_DATASOURCE.replace("{0}", "settings localUri"));

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("i18n"), true, ALREADY_EXISTING_MODEL.replace("{0}", "i18n"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["i18n"]["type"], "sap.ui.model.resource.ResourceModel", ALREADY_EXISTING_MODEL.replace("{0}", "type"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["i18n"]["uri"], "i18n/i18n.properties", ALREADY_EXISTING_MODEL.replace("{0}", "uri"));

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "equipmentanno", "the sap.ui5 model dataSource reference was checked in sap.app.dataSource and was added correctly.");
		});

		QUnit.test("when calling '_applyChange' check that either 'type' or 'dataSource' is defined in a property in sap.ui5.models => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {
								localUri: "model/annotations.xml"
							}
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment: {
							preload: true,
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("There is no 'dataSource' or 'type' in the change model defined. Please define either 'type' or 'dataSource' in property 'equipment'"),
			"throws error that either 'dataSource' or 'type' must be defined in the change model property");
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest without having models and dataSources => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						"customer.fancy_dataSource": {
							uri: "/sap/opu/odata/snce/PO_S_SRV;v=2/",
							type: "OData",
							settings: {
								odataVersion: "2.0",
								annotations: ["customer.fancy_annotation"]
							}
						},
						"customer.fancy_annotation": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {}
						}
					},
					model: {
						"customer.fancy_model": {
							dataSource: "customer.fancy_dataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("customer.fancy_model"), true, ADDED_MODEL.replace("{0}", "customer.fancy_model"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["customer.fancy_model"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_dataSource"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_dataSource object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["uri"], "/sap/opu/odata/snce/PO_S_SRV;v=2/", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["type"], "OData", ADDED_DATASOURCE.replace("{0}", "type"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_annotation"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_annotation object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["uri"], "/sap/opu/odata/snce/PO_S_SRV;v=2/", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_dataSource"]["type"], "OData", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type INA => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						inaDataSource: {
							uri: "/dataSource/ina",
							type: "INA"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "inaDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "inaDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("inaDataSource"), true, ADDED_DATASOURCE.replace("{0}", "inaDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["inaDataSource"]["uri"], "/dataSource/ina", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["inaDataSource"]["type"], "INA", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type XML => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						xmlDataSource: {
							uri: "/dataSource/xml",
							type: "XML"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "xmlDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "xmlDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("xmlDataSource"), true, ADDED_DATASOURCE.replace("{0}", "xmlDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["xmlDataSource"]["uri"], "/dataSource/xml", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["xmlDataSource"]["type"], "XML", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type JSON => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						jsonDataSource: {
							uri: "/dataSource/json",
							type: "JSON"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "jsonDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "jsonDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("jsonDataSource"), true, ADDED_DATASOURCE.replace("{0}", "jsonDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["jsonDataSource"]["uri"], "/dataSource/json", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["jsonDataSource"]["type"], "JSON", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type FHIR => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						fhirDataSource: {
							uri: "/dataSource/fhir",
							type: "FHIR"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "fhirDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "fhirDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("fhirDataSource"), true, ADDED_DATASOURCE.replace("{0}", "fhirDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["fhirDataSource"]["uri"], "/dataSource/fhir", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["fhirDataSource"]["type"], "FHIR", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with not supported dataSource => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						notSupportedDataSource: {
							uri: "/dataSource/notSupported",
							type: "NOTSUPPORTED"
						},
						supportedODataDataSource: {
							uri: "/dataSource/supportedODataDataSource",
							type: "OData"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "notSupportedDataSource",
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The defined dataSource 'notSupportedDataSource' in the model does not exists as dataSource or must be allowed type of OData|INA|XML|JSON|FHIR|http|WebSocket"),
			"throws error that the dataSource which is defined in the model has to have a supported type 'OData|INA|XML|JSON|FHIR|http|WebSocket' or no type (default OData)");
		});

		QUnit.test("when calling '_applyChange' checks that there is a dataSource with type 'ODataAnnotation' definded which has no dataSources with type 'OData' for that => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						equipmentanno: {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {
								localUri: "model/annotations.xml"
							}
						}
					}
				},
				"sap.ui5": {
					models: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						equipmentAnnotation: {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno.XML",
							type: "ODataAnnotation",
							settings: {
								localUri: "model/annotations.xml"
							}
						}
					},
					model: {
						localModel: {
							type: "some.local.model",
							uri: "local/local.properties"
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("There is no dataSource with type 'OData' defined which includes the annotation 'equipmentAnnotation'"),
			"throws error that there is a dataSource with type 'ODataAnnotation' definded which has no dataSources with type 'OData' for that");
		});

		QUnit.test("when calling '_applyChange' with adding a new model and 3 dataSources which has dataSource type 'ODataAnnotation' and one dataSource with type 'OData' => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						"customer.fancy_annotation1": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno1.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						"customer.fancy_annotation2": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno2.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						"customer.fancy_annotation3": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno3.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						equipmentDataSource: {
							uri: "/dataSource/odata",
							type: "OData",
							settings: {
								annotations: ["customer.fancy_annotation1", "customer.fancy_annotation2", "customer.fancy_annotation3"]
							}
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "equipmentDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_annotation1"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_annotation1 object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation1"]["uri"], "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno1.XML", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation1"]["type"], "ODataAnnotation", ADDED_DATASOURCE.replace("{0}", "type"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation1"]["settings"]), "{}", ADDED_DATASOURCE.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_annotation2"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_annotation2 object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation2"]["uri"], "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno2.XML", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation2"]["type"], "ODataAnnotation", ADDED_DATASOURCE.replace("{0}", "type"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation2"]["settings"]), "{}", ADDED_DATASOURCE.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("customer.fancy_annotation3"), true, ADDED_DATASOURCE.replace("{0}", "customer.fancy_annotation3 object"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation3"]["uri"], "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno3.XML", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation3"]["type"], "ODataAnnotation", ADDED_DATASOURCE.replace("{0}", "type"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.app"]["dataSources"]["customer.fancy_annotation3"]["settings"]), "{}", ADDED_DATASOURCE.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("equipmentDataSource"), true, ADDED_DATASOURCE.replace("{0}", "equipmentDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["uri"], "/dataSource/odata", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["type"], "OData", ADDED_DATASOURCE.replace("{0}", "type"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"].hasOwnProperty("settings"), true, ADDED_DATASOURCE.replace("{0}", "settings"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["settings"]["annotations"][0], "customer.fancy_annotation1", ADDED_DATASOURCE.replace("{0}", "annotations customer.fancy_annotation1"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["settings"]["annotations"][1], "customer.fancy_annotation2", ADDED_DATASOURCE.replace("{0}", "annotations customer.fancy_annotation2"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["settings"]["annotations"][2], "customer.fancy_annotation3", ADDED_DATASOURCE.replace("{0}", "annotations customer.fancy_annotation3"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["equipmentDataSource"]["settings"]["annotations"][3], undefined, "There are not more then 3 sap.app dataSource annotations.");
		});

		QUnit.test("when calling '_applyChange' with adding a new model and 3 dataSources which has dataSource type 'ODataAnnotation' and one dataSource with type 'OData' but not including one of the typed 'ODataAnnotation' dataSources => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						"customer.fancy_annotation1": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno1.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						"customer.fancy_annotation2": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno2.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						"customer.fancy_annotation3": {
							uri: "/sap/bc/bsp/sap/BSCBN_ANF_EAM/BSCBN_EQUIPMENT_SRV.anno3.XML",
							type: "ODataAnnotation",
							settings: {}
						},
						equipmentDataSource: {
							uri: "/dataSource/odata",
							type: "OData",
							settings: {
								annotations: ["customer.fancy_annotation1", "customer.fancy_annotation3"]
							}
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "equipmentDataSource",
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("There is no dataSource with type 'OData' defined which includes the annotation 'customer.fancy_annotation2'"),
			"throws error that when a dataSource is defined with the type 'ODataAnnotation', then there must be an additional dataSource that has the type 'OData' including the typed 'ODataAnnotation' in annotations array.");
		});

		QUnit.test("when calling '_applyChange' with adding only a new dataSource => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						notSupportedDataSource: {
							uri: "/dataSource/notSupported",
							type: "NOTSUPPORTED"
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("No model defined"),
			"throws error that for a dataSource in change there must be also a model in change");
		});

		QUnit.test("when calling '_applyChange' with adding unsed dataSource => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						notUsedDataSource: {
							uri: "/not/used/dataSource",
							type: "OData"
						}
					},
					model: {
						i18n: {
							type: "sap.ui.model.resource.ResourceModel",
							uri: "i18n/i18n.properties"
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The dataSource in the change 'notUsedDataSource' is not used by any model in the change. A dataSource in the change must be used by model in the change"),
			"throws error that the dataSource in change is not used from any model in the change");
		});

		QUnit.test("when calling '_applyChange' by adding a new model which refers to an existing dataSource in the manifest (without type check) => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						anyTypeDataSource: {
							uri: "/any/type/dataSource",
							type: "ANYTYPE"
						}
					}
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment: {
							preload: true,
							dataSource: "anyTypeDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "anyTypeDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("anyTypeDataSource"), true, ALREADY_EXISTING_DATASOURCE.replace("{0}", "anyTypeDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["anyTypeDataSource"]["uri"], "/any/type/dataSource", ALREADY_EXISTING_DATASOURCE.replace("{0}", "dataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["anyTypeDataSource"]["type"], "ANYTYPE", ALREADY_EXISTING_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' by adding a new model which refers to an existing dataSource in the manifest which is type of 'ODataAnnotation' => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						annoDataSource: {
							uri: "/anno/dataSource",
							type: "ODataAnnotation"
						}
					}
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment: {
							preload: true,
							dataSource: "annoDataSource",
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("The already existing dataSource 'annoDataSource' in the manifest is type of 'ODataAnnotation'. A model must not reference to a dataSource which is of type 'ODataAnnotation'"),
			"throws error that the model in the change is referencing to a dataSource which is type of 'ODataAnnotation' and this is not allowed'");
		});

		QUnit.test("when calling '_applyChange' by adding '2' new models => ERROR", function (assert) {
			var oManifest = {
				"sap.app": {
					dataSources: {
						fhirDataSource: {
							uri: "/fhir/dataSource",
							type: "FHIR"
						},
						oDataDataSource: {
							uri: "/odata/dataSource",
							type: "OData"
						}
					}
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					model: {
						equipment1: {
							preload: true,
							dataSource: "fhirDataSource",
							settings: {}
						},
						equipment2: {
							preload: true,
							dataSource: "oDataDataSource",
							settings: {}
						}
					}
				}
			});

			assert.throws(function() {
				AddNewModel.applyChange(oManifest, oChange);
			}, Error("There are currently '2' models in the change. Currently it is only allowed to add '1' model"),
			"throws error that currently only '1' model can be added");
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type http => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						httpDataSource: {
							uri: "/dataSource/http",
							type: "http"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "httpDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "httpDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("httpDataSource"), true, ADDED_DATASOURCE.replace("{0}", "httpDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["httpDataSource"]["uri"], "/dataSource/http", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["httpDataSource"]["type"], "http", ADDED_DATASOURCE.replace("{0}", "type"));
		});

		QUnit.test("when calling '_applyChange' with adding a new model and dataSource in a manifest with dataSource type WebSocket => SUCCESS", function (assert) {
			var oManifest = {
				"sap.app": {
				},
				"sap.ui5": {
				}
			};

			var oChange = new AppDescriptorChange({
				flexObjectMetadata: {
					changeType: "appdescr_ui5_addNewModel"
				},
				content: {
					dataSource: {
						webSocketDataSource: {
							uri: "/dataSource/webSocket",
							type: "WebSocket"
						}
					},
					model: {
						equipment: {
							preload: true,
							dataSource: "webSocketDataSource",
							settings: {}
						}
					}
				}
			});

			var oNewManifest = AddNewModel.applyChange(oManifest, oChange);

			assert.strictEqual(oNewManifest["sap.ui5"]["models"].hasOwnProperty("equipment"), true, ADDED_MODEL.replace("{0}", "object equipment"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["preload"], true, ADDED_MODEL.replace("{0}", "preload"));
			assert.strictEqual(oNewManifest["sap.ui5"]["models"]["equipment"]["dataSource"], "webSocketDataSource", ADDED_MODEL.replace("{0}", "dataSource"));
			assert.strictEqual(JSON.stringify(oNewManifest["sap.ui5"]["models"]["equipment"]["settings"]), "{}", ADDED_MODEL.replace("{0}", "settings"));

			assert.strictEqual(oNewManifest["sap.app"]["dataSources"].hasOwnProperty("webSocketDataSource"), true, ADDED_DATASOURCE.replace("{0}", "webSocketDataSource"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["webSocketDataSource"]["uri"], "/dataSource/webSocket", ADDED_DATASOURCE.replace("{0}", "uri"));
			assert.strictEqual(oNewManifest["sap.app"]["dataSources"]["webSocketDataSource"]["type"], "WebSocket", ADDED_DATASOURCE.replace("{0}", "type"));
		});
	});

	QUnit.done(function() {
		document.getElementById("qunit-fixture").style.display = "none";
	});
});


text:
#include <vector>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "lullaby/modules/render/material_info.h"
#include "lullaby/util/hash.h"
#include "lullaby/tests/portable_test_macros.h"

using ::testing::Eq;
using ::testing::Not;

namespace lull {

TEST(MaterialInfoTest, TextureUsageInfoConstructors) {
  TextureUsageInfo single_usage_info(MaterialTextureUsage_BaseColor);
  EXPECT_THAT(single_usage_info.GetChannelUsage(0),
              Eq(MaterialTextureUsage_BaseColor));
  EXPECT_THAT(single_usage_info.GetChannelUsage(1),
              Eq(MaterialTextureUsage_Unused));
  EXPECT_THAT(single_usage_info.GetChannelUsage(2),
              Eq(MaterialTextureUsage_Unused));
  EXPECT_THAT(single_usage_info.GetChannelUsage(3),
              Eq(MaterialTextureUsage_Unused));

  std::vector<MaterialTextureUsage> usages = {MaterialTextureUsage_Occlusion,
                                              MaterialTextureUsage_Roughness};
  TextureUsageInfo multi_usage_info(usages);
  EXPECT_THAT(multi_usage_info.GetChannelUsage(0),
              Eq(MaterialTextureUsage_Occlusion));
  EXPECT_THAT(multi_usage_info.GetChannelUsage(1),
              Eq(MaterialTextureUsage_Roughness));
  EXPECT_THAT(multi_usage_info.GetChannelUsage(2),
              Eq(MaterialTextureUsage_Unused));
  EXPECT_THAT(multi_usage_info.GetChannelUsage(3),
              Eq(MaterialTextureUsage_Unused));
}

TEST(MaterialInfoTest, TextureUsageInfoEquality) {
  std::vector<MaterialTextureUsage> unused_roughness_metallic = {
      MaterialTextureUsage_Unused, MaterialTextureUsage_Roughness,
      MaterialTextureUsage_Metallic};
  TextureUsageInfo usage_info_a(unused_roughness_metallic);
  TextureUsageInfo usage_info_b(unused_roughness_metallic);
  EXPECT_THAT(usage_info_a, Eq(usage_info_b));

  std::vector<MaterialTextureUsage> occlusion_roughness_metallic = {
      MaterialTextureUsage_Occlusion, MaterialTextureUsage_Roughness,
      MaterialTextureUsage_Metallic};
  TextureUsageInfo usage_info_c(occlusion_roughness_metallic);
  EXPECT_THAT(usage_info_a, Not(Eq(usage_info_c)));
}

TEST(MaterialInfoTest, TextureUsageInfoToHash) {
  std::vector<MaterialTextureUsage> unused_roughness_metallic = {
      MaterialTextureUsage_Unused, MaterialTextureUsage_Roughness,
      MaterialTextureUsage_Metallic};
  TextureUsageInfo usage_info(unused_roughness_metallic);
  EXPECT_THAT(usage_info.GetHash(),
              Eq(Hash("Texture_UnusedRoughnessMetallic")));
}

TEST(MaterialInfoTest, TextureUsageInfoHasher) {
  TextureUsageInfo::Hasher hasher;

  std::vector<MaterialTextureUsage> unused_roughness_metallic = {
      MaterialTextureUsage_Unused, MaterialTextureUsage_Roughness,
      MaterialTextureUsage_Metallic};
  TextureUsageInfo usage_info_a(unused_roughness_metallic);
  TextureUsageInfo usage_info_b(unused_roughness_metallic);
  const size_t hash_a = hasher(usage_info_a);
  const size_t hash_b = hasher(usage_info_b);
  EXPECT_THAT(hash_a, Eq(hash_b));

  std::vector<MaterialTextureUsage> occlusion_roughness_metallic = {
      MaterialTextureUsage_Occlusion, MaterialTextureUsage_Roughness,
      MaterialTextureUsage_Metallic};
  TextureUsageInfo usage_info_c(occlusion_roughness_metallic);
  const size_t hash_c = hasher(usage_info_c);
  EXPECT_THAT(hash_a, Not(Eq(hash_c)));
}

}  // namespace lull


text:
import Controller from 'ember-runtime/controllers/controller';
import { moduleFor, ApplicationTest } from '../../utils/test-case';
import { strip } from '../../utils/abstract-test-case';
import Route from 'ember-routing/system/route';

moduleFor('Application test: rendering', class extends ApplicationTest {

  ['@test it can render the application template'](assert) {
    this.registerTemplate('application', 'Hello world!');

    return this.visit('/').then(() => {
      this.assertText('Hello world!');
    });
  }

  ['@test it can access the model provided by the route'](assert) {
    this.registerRoute('application', Route.extend({
      model() {
        return ['red', 'yellow', 'blue'];
      }
    }));

    this.registerTemplate('application', strip`

        {{#each model as |item|}}

{{item}}

        {{/each}}

    `);

    return this.visit('/').then(() => {
      this.assertComponentElement(this.firstChild, {
        content: strip`

red

yellow

blue

        `
      });
    });
  }

  ['@test it can render a nested route'](assert) {
    this.router.map(function() {
      this.route('lists', function() {
        this.route('colors', function() {
          this.route('favorite');
        });
      });
    });

    // The "favorite" route will inherit the model
    this.registerRoute('lists.colors', Route.extend({
      model() {
        return ['red', 'yellow', 'blue'];
      }
    }));

    this.registerTemplate('lists.colors.favorite', strip`

        {{#each model as |item|}}

{{item}}

        {{/each}}

    `);

    return this.visit('/lists/colors/favorite').then(() => {
      this.assertComponentElement(this.firstChild, {
        content: strip`

red

yellow

blue

        `
      });
    });
  }

  ['@test it can render into named outlets'](assert) {
    this.router.map(function() {
      this.route('colors');
    });

    this.registerTemplate('application', strip`
      {{outlet "nav"}}
      {{outlet}}
    `);

    this.registerTemplate('nav', strip`
      Ember
    `);

    this.registerRoute('application', Route.extend({
      renderTemplate() {
        this.render();
        this.render('nav', {
          into: 'application',
          outlet: 'nav'
        });
      }
    }));

    this.registerRoute('colors', Route.extend({
      model() {
        return ['red', 'yellow', 'blue'];
      }
    }));

    this.registerTemplate('colors', strip`

        {{#each model as |item|}}

{{item}}

        {{/each}}

    `);

    return this.visit('/colors').then(() => {
      this.assertComponentElement(this.firstChild, {
        content: strip`

            Ember

red

yellow

blue

        `
      });
    });
  }

  ['@test it can render into named outlets'](assert) {
    this.router.map(function() {
      this.route('colors');
    });

    this.registerTemplate('application', strip`
      {{outlet "nav"}}
      {{outlet}}
    `);

    this.registerTemplate('nav', strip`
      Ember
    `);

    this.registerRoute('application', Route.extend({
      renderTemplate() {
        this.render();
        this.render('nav', {
          into: 'application',
          outlet: 'nav'
        });
      }
    }));

    this.registerRoute('colors', Route.extend({
      model() {
        return ['red', 'yellow', 'blue'];
      }
    }));

    this.registerTemplate('colors', strip`

        {{#each model as |item|}}

{{item}}

        {{/each}}

    `);

    return this.visit('/colors').then(() => {
      this.assertComponentElement(this.firstChild, {
        content: strip`

            Ember

red

yellow

blue

        `
      });
    });
  }

  ['@test it should update the outlets when switching between routes'](assert) {
    this.router.map(function() {
      this.route('a');
      this.route('b', function() {
        this.route('c');
        this.route('d');
      });
    });

    this.registerTemplate('a', 'A{{outlet}}');
    this.registerTemplate('b', 'B{{outlet}}');
    this.registerTemplate('b.c', 'C');
    this.registerTemplate('b.d', 'D');

    return this.visit('/b/c').then(() => {
      // this.assertComponentElement(this.firstChild, { content: 'BC' });
      this.assertText('BC');
      return this.visit('/a');
    }).then(() => {
      // this.assertComponentElement(this.firstChild, { content: 'A' });
      this.assertText('A');
      return this.visit('/b/d');
    }).then(() => {
      this.assertText('BD');
      // this.assertComponentElement(this.firstChild, { content: 'BD' });
    });
  }

  ['@test it should produce a stable DOM when the model changes'](assert) {
    this.router.map(function() {
      this.route('color', { path: '/colors/:color' });
    });

    this.registerRoute('color', Route.extend({
      model(params) {
        return params.color;
      }
    }));

    this.registerTemplate('color', 'color: {{model}}');

    return this.visit('/colors/red').then(() => {
      this.assertComponentElement(this.firstChild, { content: 'color: red' });
      this.takeSnapshot();
      return this.visit('/colors/green');
    }).then(() => {
      this.assertComponentElement(this.firstChild, { content: 'color: green' });
      this.assertInvariants();
    });
  }

  ['@test it should update correctly when the controller changes'](assert) {
    this.router.map(function() {
      this.route('color', { path: '/colors/:color' });
    });

    this.registerRoute('color', Route.extend({
      model(params) {
        return { color: params.color };
      },

      renderTemplate(controller, model) {
        this.render({ controller: model.color, model });
      }
    }));

    this.registerController('red', Controller.extend({
      color: 'red'
    }));

    this.registerController('green', Controller.extend({
      color: 'green'
    }));

    this.registerTemplate('color', 'model color: {{model.color}}, controller color: {{color}}');

    return this.visit('/colors/red').then(() => {
      this.assertComponentElement(this.firstChild, { content: 'model color: red, controller color: red' });
      this.takeSnapshot();
      return this.visit('/colors/green');
    }).then(() => {
      this.assertComponentElement(this.firstChild, { content: 'model color: green, controller color: green' });
      this.assertInvariants();
    });
  }

  ['@test it should produce a stable DOM when two routes render the same template'](assert) {
    this.router.map(function() {
      this.route('a');
      this.route('b');
    });

    this.registerRoute('a', Route.extend({
      model() {
        return 'A';
      },

      renderTemplate(controller, model) {
        this.render('common', { controller: 'common', model });
      }
    }));

    this.registerRoute('b', Route.extend({
      model() {
        return 'B';
      },

      renderTemplate(controller, model) {
        this.render('common', { controller: 'common', model });
      }
    }));

    this.registerController('common', Controller.extend({
      prefix: 'common'
    }));

    this.registerTemplate('common', '{{prefix}} {{model}}');

    return this.visit('/a').then(() => {
      this.assertComponentElement(this.firstChild, { content: 'common A' });
      this.takeSnapshot();
      return this.visit('/b');
    }).then(() => {
      this.assertComponentElement(this.firstChild, { content: 'common B' });
      this.assertInvariants();
    });
  }

  // Regression test, glimmer child outlets tried to assume the first element.
  // but the if put-args clobbered the args used by did-create-element.
  // I wish there was a way to assert that the OutletComponentManager did not
  // receive a didCreateElement.
  ['@test a child outlet is always a fragment']() {
    this.registerTemplate('application', '{{outlet}}');
    this.registerTemplate('index', '{{#if true}}1{{/if}}
2
');
    return this.visit('/').then(() => {
      this.assertComponentElement(this.firstChild, { content: '1
2
' });
    });
  }
});


text:
"""
Static variables used within geoconnect
"""

# --------------------------------------
# Used for incoming Dataverse Files
#   Note: The value types: 'shapefile', 'tabular', etc are in the
#         info returned by the Dataverse API
# --------------------------------------
DV_MAP_TYPE_SHAPEFILE = 'shapefile'
DV_MAP_TYPE_TABULAR = 'tabular'
DV_MAP_TYPE_GEOTIFF = 'geotiff'

DV_FILE_TYPES = (DV_MAP_TYPE_SHAPEFILE,\
                DV_MAP_TYPE_TABULAR,\
                DV_MAP_TYPE_GEOTIFF)
DV_FILE_TYPE_CHOICES = [(x, x) for x in DV_FILE_TYPES]

def is_valid_dv_type(map_type):
    return map_type in DV_FILE_TYPES

def is_dv_type_shapefile(map_type):
    return map_type == DV_MAP_TYPE_SHAPEFILE

def is_dv_type_tabular(map_type):
    return map_type == DV_MAP_TYPE_TABULAR

def is_dv_type_geotiff(map_type):
    return map_type == DV_MAP_TYPE_GEOTIFF

# --------------------------------------
# Used for classify and delete forms
# --------------------------------------
TYPE_SHAPEFILE_LAYER = 'TYPE_SHAPEFILE_LAYER'
TYPE_JOIN_LAYER = 'TYPE_JOIN_LAYER'
TYPE_LAT_LNG_LAYER = 'TYPE_LAT_LNG_LAYER'

# Tuple of array types
LAYER_TYPES = (TYPE_SHAPEFILE_LAYER, TYPE_JOIN_LAYER, TYPE_LAT_LNG_LAYER)

# Array types for "choices" settings
LAYER_TYPE_CHOICES = [(x, x) for x in LAYER_TYPES]

def is_valid_layer_type(map_type):
    return map_type in LAYER_TYPES

#from gc_apps.layer_types.static_vals import


text:
module ShopifyAPI
  class Checkout < Base
  end
end


text:
// ReSharper disable InvalidXmlDocComment
// ReSharper disable InconsistentNaming
// ReSharper disable CheckNamespace
// ReSharper disable MemberCanBePrivate.Global

using System;
using System.Runtime.InteropServices;

// Source file C:\Program Files\Epic Games\UE_4.22\Engine\Source\Runtime\AIModule\Classes\Actions\PawnAction.h:47

namespace UnrealEngine
{
	public partial class UPawnAction : UObject
	{
		public UPawnAction(IntPtr adress)
			: base(adress)
		{
		}

		public UPawnAction(UObject Parent = null, string Name = "PawnAction")
			: base(IntPtr.Zero)
		{
			NativePointer = E_NewObject_UPawnAction(Parent, Name);
			NativeManager.AddNativeWrapper(NativePointer, this);
		}

		#region DLLInmport
		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern IntPtr E_NewObject_UPawnAction(IntPtr Parent, string Name);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_Activate(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetChildAction(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetController(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern StringWrapper E_UPawnAction_GetDisplayName(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetInstigator(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetOwnerComponent(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetParentAction(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern ObjectPointerDescription E_UPawnAction_GetPawn(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern StringWrapper E_UPawnAction_GetPriorityName(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern StringWrapper E_UPawnAction_GetStateDescription(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_HasActionObserver(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_HasBeenStarted(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_IsActive(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_IsBeingAborted(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_IsFinished(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_IsPaused(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_OnPopped(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_Pause(IntPtr self, IntPtr pausedBy);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_PushChildAction(IntPtr self, IntPtr action);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_Resume(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_SetOwnerComponent(IntPtr self, IntPtr component);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_ShouldPauseMovement(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_Start(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_StopWaitingForMessages(IntPtr self);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_Tick(IntPtr self, float deltaTime);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_TickAction(IntPtr self, float deltaTime);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern void E_UPawnAction_WaitForMessage(IntPtr self, string messageType, IntPtr requestID);

		[DllImport(NativeManager.UnrealDotNetDll, CallingConvention = CallingConvention.Cdecl)]
		private static extern bool E_UPawnAction_WantsTick(IntPtr self);

		#endregion

		#region ExternMethods

		/// <summary>
		/// starts or resumes action, depending on internal state
		/// </summary>
		protected bool Activate()
			=> E_UPawnAction_Activate(this);

		public UPawnAction GetChildAction()
			=> E_UPawnAction_GetChildAction(this);

		public AController GetController()
			=> E_UPawnAction_GetController(this);

		public virtual string GetDisplayName()
			=> E_UPawnAction_GetDisplayName(this);

		public UObject GetInstigator()
			=> E_UPawnAction_GetInstigator(this);

		protected UPawnActionsComponent GetOwnerComponent()
			=> E_UPawnAction_GetOwnerComponent(this);

		public UPawnAction GetParentAction()
			=> E_UPawnAction_GetParentAction(this);

		public APawn GetPawn()
			=> E_UPawnAction_GetPawn(this);

		public string GetPriorityName()
			=> E_UPawnAction_GetPriorityName(this);

		public string GetStateDescription()
			=> E_UPawnAction_GetStateDescription(this);

		public bool HasActionObserver()
			=> E_UPawnAction_HasActionObserver(this);

		protected bool HasBeenStarted()
			=> E_UPawnAction_HasBeenStarted(this);

		public bool IsActive()
			=> E_UPawnAction_IsActive(this);

		public bool IsBeingAborted()
			=> E_UPawnAction_IsBeingAborted(this);

		public bool IsFinished()
			=> E_UPawnAction_IsFinished(this);

		public bool IsPaused()
			=> E_UPawnAction_IsPaused(this);

		protected void OnPopped()
			=> E_UPawnAction_OnPopped(this);

		/// <summary>
		/// called to pause action when higher priority or child action kicks in
		/// </summary>
		protected virtual bool Pause(UPawnAction pausedBy)
			=> E_UPawnAction_Pause(this, pausedBy);

		/// <summary>
		/// apart from doing regular push request copies additional values from Parent, like Priority and Instigator
		/// </summary>
		protected bool PushChildAction(UPawnAction action)
			=> E_UPawnAction_PushChildAction(this, action);

		/// <summary>
		/// called to resume action after being paused
		/// </summary>
		protected virtual bool Resume()
			=> E_UPawnAction_Resume(this);

		protected void SetOwnerComponent(UPawnActionsComponent component)
			=> E_UPawnAction_SetOwnerComponent(this, component);

		public bool ShouldPauseMovement()
			=> E_UPawnAction_ShouldPauseMovement(this);

		/// <summary>
		/// called to start off the Action
		/// <para>@NOTE if action fails to start no finishing or aborting mechanics will be triggered </para>
		/// </summary>
		/// <return>true</return>
		protected virtual bool Start()
			=> E_UPawnAction_Start(this);

		protected void StopWaitingForMessages()
			=> E_UPawnAction_StopWaitingForMessages(this);

		protected virtual void Tick(float deltaTime)
			=> E_UPawnAction_Tick(this, deltaTime);

		protected void TickAction(float deltaTime)
			=> E_UPawnAction_TickAction(this, deltaTime);

		public void WaitForMessage(string messageType, FAIRequestID requestID)
			=> E_UPawnAction_WaitForMessage(this, messageType, requestID);

		public bool WantsTick()
			=> E_UPawnAction_WantsTick(this);

		#endregion

		public static implicit operator IntPtr(UPawnAction self)
		{
			return self?.NativePointer ?? IntPtr.Zero;
		}

		public static implicit operator UPawnAction(ObjectPointerDescription PtrDesc)
		{
			return NativeManager.GetWrapper<UPawnAction>(PtrDesc);
		}
}
}


text:
/**
 * @file
 * @brief IronBee++ --- Operator
 *
 * This file defines (Const)Operator, a wrapper for ib_operator_t and
 * (Const)OperatorInstance, a wrapper for ib_operator_inst_t.
 *
 * @remark Developers should be familiar with @ref ironbeepp to understand
 * aspects of this code, e.g., the public/non-virtual inheritance.
 *
 * @author Christopher Alfeld <calfeld@qualys.com>
 */

#ifndef __IBPP__OPERATOR__
#define __IBPP__OPERATOR__

#include <ironbeepp/catch.hpp>
#include <ironbeepp/common_semantics.hpp>
#include <ironbeepp/context.hpp>
#include <ironbeepp/c_trampoline.hpp>
#include <ironbeepp/engine.hpp>
#include <ironbeepp/field.hpp>
#include <ironbeepp/memory_manager.hpp>
#include <ironbeepp/transaction.hpp>

#include <ironbee/operator.h>

#ifdef __clang__
#pragma clang diagnostic push
#if __has_warning("-Wunused-local-typedef")
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
#endif
#include <boost/bind.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#include <boost/function.hpp>

#include <ostream>

namespace IronBee {

/**
 * Const Operator; equivalent to a const pointer to ib_operator_t.
 *
 * Provides operators ==, !=, <, >, <=, >= and evaluation as a boolean for
 * singularity via CommonSemantics.
 *
 * See Operator for discussion of Operator
 *
 * @sa Operator
 * @sa ironbeepp
 * @sa ib_operator_t
 * @nosubgrouping
 **/
class ConstOperator :
    public CommonSemantics<ConstOperator>
{
public:
    //! C Type.
    typedef const ib_operator_t* ib_type;

    /**
     * Construct singular ConstOperator.
     *
     * All behavior of a singular ConstOperator is undefined except for
     * assignment, copying, comparison, and evaluate-as-bool.
     **/
    ConstOperator();

    /**
     * Lookup operator in an engine.
     *
     * @param[in] engine Engine to lookup in.
     * @param[in] name Name of operator.
     * @param[in] name_length Length of @a name.
     * @returns Operator.
     **/
    static
    ConstOperator lookup(
        Engine      engine,
        const char *name,
        size_t      name_length
    );

    /**
     * Lookup operator in an engine.
     *
     * @param[in] engine Engine to lookup in.
     * @param[in] name Name of operator.
     * @returns Operator.
     **/
    static
    ConstOperator lookup(
        Engine             engine,
        const std::string& name
    );

    /**
     * Lookup stream operator in an engine.
     *
     * @param[in] engine Engine to lookup in.
     * @param[in] name Name of operator.
         * @param[in] name_length Length of @a name.
     * @returns Operator.
     **/
    static
    ConstOperator stream_lookup(
        Engine      engine,
        const char *name,
        size_t      name_length
    );

    /**
     * Lookup stream operator in an engine.
     *
     * @param[in] engine Engine to lookup in.
     * @param[in] name Name of operator.
     * @returns Operator.
     **/
    static
    ConstOperator stream_lookup(
        Engine             engine,
        const std::string& name
    );

    /**
     * @name C Interoperability
     * Methods to access underlying C types.
     **/
    ///@{

    //! const ib_operator_t accessor.
    // Intentionally inlined.
    ib_type ib() const
    {
        return m_ib;
    }

    //! Construct Operator from ib_operator_t.
    explicit
    ConstOperator(ib_type ib_operator);

    ///@}

    //! Name of operator.
    const char* name() const;

    //! Capabilities of operator.
    ib_flags_t capabilities() const;

    /**
     * Register with an engine.
     *
     * @param[in] engine Engine to register with.
     **/
    void register_with(Engine engine);

    /**
     * Register stream operator with an engine.
     *
     * @param[in] engine Engine to register with.
     **/
    void register_stream_with(Engine engine);

private:
    ib_type m_ib;
};

/**
 * Operator; equivalent to a pointer to ib_operator_t.
 *
 * Operator can be treated as ConstOperator.  See @ref ironbeepp for
 * details on IronBee++ object semantics.
 *
 * An operator represents a test on data.  It takes input and returns true
 * or false (represented by 1 and 0).  It can also, optionally, output a
 * "capture" collection containing additional results.
 *
 * @sa ConstOperator
 * @sa ironbeepp
 * @sa ib_operator_t
 * @nosubgrouping
 **/
class Operator :
    public ConstOperator
{
public:
    //! C Type.
    typedef ib_operator_t* ib_type;

    /**
     * Remove the constness of a ConstOperator.
     *
     * @warning This is as dangerous as a @c const_cast, use carefully.
     *
     * @param[in] operator_ ConstOperator to remove const from.
     * @returns Operator pointing to same underlying operator as @a operator.
     **/
    static Operator remove_const(ConstOperator operator_);

    /**
     * Construct singular Operator.
     *
     * All behavior of a singular Operator is undefined except for
     * assignment, copying, comparison, and evaluate-as-bool.
     **/
    Operator();

    /**
     * Create from 0-3 functionals.
     *
     * @tparam InstanceData Type of data used by instances.
     * @param[in] memory_manager Memory manager to allocate memory from.
     * @param[in] name Name of operator.
     * @param[in] capabilities Capabilities of operator.
     * @param[in] create Functional to call on creation.  Passed context,
     *                   memory manager and parameters and should return a
     *                   pointer to InstanceData.  If singular, defaults to
     *                   nop.
     * @param[in] destroy Functional to call on destruction.  Passed instance
     *                    data the create functional returned.  Defaults to
     *                    nop.
     * @param[in] execute Functional to call on execution. Passed transaction,
     *                    input, capture, and instance data.  Should return
     *                    result (0 = false, 1 = true usually).  If singular,
     *                    defaults to constant 1 function.
     * @returns New operator.
     **/
    template <typename InstanceData>
    static Operator create(
        MemoryManager memory_manager,
        const char*   name,
        ib_flags_t    capabilities,
        boost::function<InstanceData*(Context, MemoryManager, const char*)>
            create,
        boost::function<void(InstanceData*)>
            destroy,
        boost::function<int(Transaction, ConstField, Field, InstanceData*)>
            execute
    );

    /**
     * Operator as functional.
     *
     * A functional to call as an operator.  Generated by an
     * @ref operator_generator_t.  See non-templated create().
     *
     * Parameters are current transaction, input field, and capture field.
     * Return value is result.
     **/
    typedef boost::function<
        int(
            Transaction,
            ConstField,
            Field
        )
    > operator_instance_t;

    /**
     * Operator as operator instance generator.
     *
     * A functional to call to generate an @ref operator_instance_t.  See
     * non-templated create().
     *
     * Parameters are current context, memory manager, and parameters.
     * Return value is an @ref operator_instance_t.
     **/
    typedef boost::function<
        operator_instance_t(
            Context,
            MemoryManager,
            const char*
        )
    > operator_generator_t;

    /**
     * Create operator from a single generator functional.
     *
     * @param[in] memory_manager Memory manager to allocate memory from.
     * @param[in] name Name of operator.
     * @param[in] capabilities Capabilities of operator.
     * @param[in] generator Functional to call when a new instance is needed.
     *                      Is passed context and parameters and should return
     *                      a new functional that will be called with
     *                      transaction, input, and capture on instance
     *                      execution.
     * @returns New operator.
     **/
    static
    Operator create(
        MemoryManager        memory_manager,
        const char*          name,
        ib_flags_t           capabilities,
        operator_generator_t generator
    );

    /**
     * @name C Interoperability
     * Methods to access underlying C types.
     **/
    ///@{

    //! ib_operator_t accessor.
    ib_type ib() const
    {
        return m_ib;
    }

    //! Construct Operator from ib_operator_t.
    explicit
    Operator(ib_type ib_operator);

    ///@}

private:
    ib_type m_ib;
};

/**
 * Output operator for Operator.
 *
 * Output IronBee::Operator[@e value] where @e value is the name.
 *
 * @param[in] o Ostream to output to.
 * @param[in] operator_ Operator to output.
 * @return @a o
 **/
std::ostream& operator<<(std::ostream& o, const ConstOperator& operator_);

/**
 * Const OperatorInstance; equivalent to a const pointer to ib_operator_inst_t.
 *
 * Provides operators ==, !=, <, >, <=, >= and evaluation as a boolean for
 * singularity via CommonSemantics.
 *
 * See OperatorInstance for discussion of OperatorInstance
 *
 * @sa OperatorInstance
 * @sa ironbeepp
 * @sa ib_operator_inst_t
 * @nosubgrouping
 **/
class ConstOperatorInstance :
    public CommonSemantics<ConstOperatorInstance>
{
public:
    //! C Type.
    typedef const ib_operator_inst_t* ib_type;

    /**
     * Construct singular ConstOperatorInstance.
     *
     * All behavior of a singular ConstOperatorInstance is undefined except for
     * assignment, copying, comparison, and evaluate-as-bool.
     **/
    ConstOperatorInstance();

    /**
     * @name C Interoperability
     * Methods to access underlying C types.
     **/
    ///@{

    //! const ib_operator_inst_t accessor.
    // Intentionally inlined.
    ib_type ib() const
    {
        return m_ib;
    }

    //! Construct OperatorInstance from ib_operator_inst_t.
    explicit
    ConstOperatorInstance(ib_type ib_operator_instance);

    ///@}

    //! Operator accessor.
    ConstOperator operator_() const;

    //! Parameters accessor.
    const char* parameters() const;

    //! Data accessor.
    void* data() const;

    /**
     * Execute operator instance.
     *
     * @param[in] tx      Transaction.
     * @param[in] input   Input.
     * @param[in] capture Capture field.
     *
     * @return 1 or 0.
     **/
    int execute(
        Transaction tx,
        ConstField  input,
        Field       capture = Field()
    ) const;

private:
    ib_type m_ib;
};

/**
 * OperatorInstance; equivalent to a pointer to ib_operator_inst_t.
 *
 * OperatorInstance can be treated as ConstOperatorInstance.  See @ref ironbeepp for
 * details on IronBee++ object semantics.
 *
 * An operator instance is an instantiation of an Operator for a particular
 * context and set of parameters.
 *
 * @sa ConstOperatorInstance
 * @sa ironbeepp
 * @sa ib_operator_inst_t
 * @nosubgrouping
 **/
class OperatorInstance :
    public ConstOperatorInstance
{
public:
    //! C Type.
    typedef ib_operator_inst_t* ib_type;

    /**
     * Remove the constness of a ConstOperatorInstance.
     *
     * @warning This is as dangerous as a @c const_cast, use carefully.
     *
     * @param[in] operator_instance ConstOperatorInstance to remove const from.
     * @returns OperatorInstance pointing to same underlying operator instance as @a operator_instance.
     **/
    static OperatorInstance remove_const(ConstOperatorInstance operator_instance);

    /**
     * Construct singular OperatorInstance.
     *
     * All behavior of a singular OperatorInstance is undefined except for
     * assignment, copying, comparison, and evaluate-as-bool.
     **/
    OperatorInstance();

    /**
     * Create an operator instance.
     *
     * @param[in] memory_manager Memory manager to determine lifetime.
     * @param[in] context Context.
     * @param[in] op Operator.
     * @param[in] required_capabilities Requires capabilities.
     * @param[in] parameters Parameters.
     *
     * @return Operator instance for @a op.
     **/
    static
    OperatorInstance create(
        MemoryManager memory_manager,
        Context       context,
        ConstOperator op,
        ib_flags_t    required_capabilities,
        const char*   parameters
    );

    /**
     * @name C Interoperability
     * Methods to access underlying C types.
     **/
    ///@{

    //! ib_operator_inst_t accessor.
    ib_type ib() const
    {
        return m_ib;
    }

    //! Construct OperatorInstance from ib_operator_inst_t.
    explicit
    OperatorInstance(ib_type ib_operator_instance);

    ///@}

private:
    ib_type m_ib;
};

/**
 * Output operator for OperatorInstance.
 *
 * Output IronBee::OperatorInstance[@e value] where @e value is the name
 * and parameters.
 *
 * @param[in] o Ostream to output to.
 * @param[in] operator_instance OperatorInstance to output.
 * @return @a o
 **/
std::ostream& operator<<(std::ostream& o, const ConstOperatorInstance& operator_instance);

// Implementation

namespace Impl {

struct operator_create_data_t
{
    std::pair<ib_operator_create_fn_t,  void*> create_trampoline;
    std::pair<ib_operator_execute_fn_t, void*> execute_trampoline;
    std::pair<ib_operator_destroy_fn_t, void*> destroy_trampoline;
};

void operator_cleanup(operator_create_data_t data);

namespace {

template <typename InstanceData>
ib_status_t operator_create_translator(
    boost::function<InstanceData*(Context, MemoryManager, const char*)>
        create,
    ib_context_t* ib_context,
    ib_mm_t       ib_memory_manager,
    const char*   parameters,
    void*         instance_data
)
{
    Context context(ib_context);
    MemoryManager memory_manager(ib_memory_manager);

    try {
        *(void **)instance_data = value_to_data(
            create(context, memory_manager, parameters),
            memory_manager.ib()
        );
    }
    catch (...) {
        return convert_exception(context.engine());
    }
    return IB_OK;
}

template <typename InstanceData>
ib_status_t operator_execute_translator(
    boost::function<int(Transaction, ConstField, Field, InstanceData*)>
        execute,
    ib_tx_t*          ib_tx,
    const ib_field_t* ib_field,
    ib_field_t*       ib_capture,
    ib_num_t*         result,
    void*             raw_instance_data
)
{
    Transaction tx(ib_tx);
    ConstField field(ib_field);
    Field capture(ib_capture);

    try {
        *result = execute(
            tx,
            field,
            capture,
            raw_instance_data ?
                data_to_value<InstanceData*>(raw_instance_data) : NULL
        );
    }
    catch (...) {
        return convert_exception(tx.engine());
    }
    return IB_OK;
}

template <typename InstanceData>
void operator_destroy_translator(
    boost::function<void(InstanceData*)> destroy,
    void* raw_instance_data
)
{
    destroy(data_to_value<InstanceData*>(raw_instance_data));
}

}
} // Impl

template <typename InstanceData>
Operator Operator::create(
    MemoryManager memory_manager,
    const char*   name,
    ib_flags_t    capabilities,
    boost::function<InstanceData*(Context, MemoryManager, const char*)>
        create,
    boost::function<void(InstanceData*)>
        destroy,
    boost::function<int(Transaction, ConstField, Field, InstanceData*)>
        execute
)
{
    Impl::operator_create_data_t data;

    if (create) {
        data.create_trampoline = make_c_trampoline<
            ib_status_t(ib_context_t*, ib_mm_t, const char *, void *)
        >(
            boost::bind(
                &Impl::operator_create_translator<InstanceData>,
                create, _1, _2, _3, _4
            )
        );
    }
    if (execute) {
        data.execute_trampoline = make_c_trampoline<
            ib_status_t(ib_tx_t*, const ib_field_t*, ib_field_t*, ib_num_t*, void*)
        >(
            boost::bind(
                &Impl::operator_execute_translator<InstanceData>,
                execute, _1, _2, _3, _4, _5
            )
        );
    }
    if (destroy) {
        data.destroy_trampoline = make_c_trampoline<
            void(void *)
        >(
            boost::bind(
                &Impl::operator_destroy_translator<InstanceData>,
                destroy, _1
            )
        );
    }

    ib_operator_t* op;
    throw_if_error(
        ib_operator_create(
            &op,
            memory_manager.ib(),
            name,
            capabilities,
            data.create_trampoline.first,  data.create_trampoline.second,
            data.destroy_trampoline.first, data.destroy_trampoline.second,
            data.execute_trampoline.first, data.execute_trampoline.second
        )
    );

    memory_manager.register_cleanup(
        boost::bind(&Impl::operator_cleanup, data)
    );

    return Operator(op);
}

} // IronBee

#endif


text:
package org.jsefa.common.validator.traversal;

import java.util.Collection;

import org.jsefa.common.validator.Validator;

abstract class TraversingValidator implements Validator {
    private boolean trivial;

    protected boolean checkTriviality(Collection<Validator> validators) {
        this.trivial = true;
        for (Validator validator : validators) {
            if (validator instanceof TraversingValidator) {
                if (((TraversingValidator) validator).isTrivial()) {
                    continue;
                }
            }
            this.trivial = false;
        }
        return this.trivial;
    }

    protected boolean isTrivial() {
        return this.trivial;
    }
}


text:
Created and maintained by **Colby Rountree** (http://www.colbyrountree.com/).

* https://github.com/colbyrountree


text:
namespace rocksdb {

Iterator* MockTableReader::NewIterator(const ReadOptions&, Arena* arena) {
  return new MockTableIterator(table_);
}

Status MockTableReader::Get(const ReadOptions&, const Slice& key,
                            GetContext* get_context) {
  std::unique_ptr<MockTableIterator> iter(new MockTableIterator(table_));
  for (iter->Seek(key); iter->Valid(); iter->Next()) {
    ParsedInternalKey parsed_key;
    if (!ParseInternalKey(iter->key(), &parsed_key)) {
      return Status::Corruption(Slice());
    }

    if (!get_context->SaveValue(parsed_key, iter->value())) {
      break;
    }
  }
  return Status::OK();
}

std::shared_ptr<const TableProperties> MockTableReader::GetTableProperties()
    const {
  return std::shared_ptr<const TableProperties>(new TableProperties());
}

MockTableFactory::MockTableFactory() : next_id_(1) {}

Status MockTableFactory::NewTableReader(
    const ImmutableCFOptions& ioptions, const EnvOptions& env_options,
    const InternalKeyComparator& internal_key,
    unique_ptr<RandomAccessFile>&& file, uint64_t file_size,
    unique_ptr<TableReader>* table_reader) const {
  uint32_t id = GetIDFromFile(file.get());

  MutexLock lock_guard(&file_system_.mutex);

  auto it = file_system_.files.find(id);
  if (it == file_system_.files.end()) {
    return Status::IOError("Mock file not found");
  }

  table_reader->reset(new MockTableReader(it->second));

  return Status::OK();
}

TableBuilder* MockTableFactory::NewTableBuilder(
    const ImmutableCFOptions& ioptions,
    const InternalKeyComparator& internal_key, WritableFile* file,
    const CompressionType compression_type,
    const CompressionOptions& compression_opts) const {
  uint32_t id = GetAndWriteNextID(file);

  return new MockTableBuilder(id, &file_system_);
}

uint32_t MockTableFactory::GetAndWriteNextID(WritableFile* file) const {
  uint32_t next_id = next_id_.fetch_add(1);
  char buf[4];
  EncodeFixed32(buf, next_id);
  file->Append(Slice(buf, 4));
  return next_id;
}

uint32_t MockTableFactory::GetIDFromFile(RandomAccessFile* file) const {
  char buf[4];
  Slice result;
  file->Read(0, 4, &result, buf);
  assert(result.size() == 4);
  return DecodeFixed32(buf);
}

void MockTableFactory::AssertSingleFile(
    const std::map<std::string, std::string>& file_contents) {
  ASSERT_EQ(file_system_.files.size(), 1U);
  ASSERT_TRUE(file_contents == file_system_.files.begin()->second);
}

}  // namespace rocksdb


text:
We welcome your feedback feedback  to help us improve this service.

Logout


text:
package org.kaaproject.kaa.server.operations.service.akka.actors.core.endpoint;

import java.util.UUID;

import org.kaaproject.kaa.common.hash.EndpointObjectHash;
import org.kaaproject.kaa.server.operations.service.akka.AkkaContext;

import akka.japi.Creator;

/**
 * The Class ActorCreator.
 */
public abstract class EndpointActorCreator<T> implements Creator<T> {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** The Akka service context */
    protected final AkkaContext context;

    /** The actor key */
    protected final String actorKey;

    /** The app token. */
    protected final String appToken;

    /** The endpoint key. */
    protected final EndpointObjectHash endpointKey;

    /**
     * Instantiates a new actor creator.
     *
     * @param context
     *            the context
     * @param endpointActorKey
     *            the endpoint actor key
     * @param appToken
     *            the app token
     * @param endpointKey
     *            the endpoint key
     */
    public EndpointActorCreator(AkkaContext context, String endpointActorKey, String appToken, EndpointObjectHash endpointKey) {
        super();
        this.context = context;
        this.actorKey = endpointActorKey;
        this.appToken = appToken;
        this.endpointKey = endpointKey;
    }

    public static String generateActorKey(){
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}