text:
package org.apache.flink.api.common.operators;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

import org.apache.commons.lang3.ArrayUtils;

import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.api.java.tuple.Tuple7;
import org.apache.flink.api.java.typeutils.PojoTypeExtractionTest.ComplexNestedClass;
import org.apache.flink.api.java.typeutils.GenericTypeInfo;
import org.apache.flink.api.java.typeutils.TupleTypeInfo;
import org.apache.flink.api.java.typeutils.TypeExtractor;
import org.apache.flink.api.common.operators.SelectorFunctionKeysTest.KeySelector1;
import org.apache.flink.api.common.operators.SelectorFunctionKeysTest.KeySelector3;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;

@SuppressWarnings("unused")
@RunWith(PowerMockRunner.class)
public class ExpressionKeysTest {

	@Test
	public void testBasicType() {

		TypeInformation<Long> longType = BasicTypeInfo.LONG_TYPE_INFO;
		ExpressionKeys<Long> ek = new ExpressionKeys<>("*", longType);

		Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
	}

	@Test(expected = InvalidProgramException.class)
	public void testGenericNonKeyType() {
		// Fail: GenericType cannot be used as key
		TypeInformation<GenericNonKeyType> genericType = new GenericTypeInfo<>(GenericNonKeyType.class);
		new ExpressionKeys<>("*", genericType);
	}

	@Test
	public void testKeyGenericType() {

		TypeInformation<GenericKeyType> genericType = new GenericTypeInfo<>(GenericKeyType.class);
		ExpressionKeys<GenericKeyType> ek = new ExpressionKeys<>("*", genericType);

		Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
	}

	@Test
	public void testTupleRangeCheck() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {

		// test private static final int[] rangeCheckFields(int[] fields, int maxAllowedField)
		Method rangeCheckFieldsMethod = Whitebox.getMethod(Keys.class, "rangeCheckFields", int[].class, int.class);

		// valid indexes
		rangeCheckFieldsMethod.invoke(null, new int[]{1, 2, 3, 4}, 4);

		// corner case tests
		rangeCheckFieldsMethod.invoke(null, new int[] {0}, 0);

		Throwable ex = null;
		try {
			// throws illegal argument.
			rangeCheckFieldsMethod.invoke(null, new int[] {5}, 0);
		} catch(Throwable iae) {
			ex = iae;
		}
		Assert.assertNotNull(ex);
	}

	@Test
	public void testStandardTupleKeys() {
		TupleTypeInfo<Tuple7<String, String, String, String, String, String, String>> typeInfo = new TupleTypeInfo<>(
				BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,
				BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO);

		ExpressionKeys<Tuple7<String, String, String, String, String, String, String>> ek;

		for( int i = 1; i < 8; i++) {
			int[] ints = new int[i];
			for( int j = 0; j < i; j++) {
				ints[j] = j;
			}
			int[] inInts = Arrays.copyOf(ints, ints.length); // copy, just to make sure that the code is not cheating by changing the ints.
			ek = new ExpressionKeys<>(inInts, typeInfo);
			Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
			Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);

			ArrayUtils.reverse(ints);
			inInts = Arrays.copyOf(ints, ints.length);
			ek = new ExpressionKeys<>(inInts, typeInfo);
			Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
			Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);
		}
	}

	@Test
	public void testInvalidTuple() throws Throwable {
		TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
				BasicTypeInfo.STRING_TYPE_INFO,
				new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
				BasicTypeInfo.STRING_TYPE_INFO);

		String[][] tests = new String[][] {
				new String[] {"f0.f1"}, // nesting into unnested
				new String[] {"f11"},
				new String[] {"f-35"},
				new String[] {"f0.f33"},
				new String[] {"f1.f33"}
		};
		for (String[] test : tests) {
			Throwable e = null;
			try {
				new ExpressionKeys<>(test, typeInfo);
			} catch (Throwable t) {
				e = t;
			}
			Assert.assertNotNull(e);
		}
	}

	@Test(expected = InvalidProgramException.class)
	public void testTupleNonKeyField() {
		// selected field is not a key type
		TypeInformation<Tuple3<String, Long, GenericNonKeyType>> ti = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO,
			TypeExtractor.getForClass(GenericNonKeyType.class)
		);

		new ExpressionKeys<>(2, ti);
	}

	@Test
	public void testTupleKeyExpansion() {
		TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
				BasicTypeInfo.STRING_TYPE_INFO,
				new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
				BasicTypeInfo.STRING_TYPE_INFO);
		ExpressionKeys<Tuple3<String, Tuple3<String, String, String>, String>> fpk =
				new ExpressionKeys<>(0, typeInfo);
		Assert.assertArrayEquals(new int[] {0}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(1, typeInfo);
		Assert.assertArrayEquals(new int[] {1,2,3}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(2, typeInfo);
		Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(new int[] {0,1,2}, typeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(null, typeInfo, true); // empty case
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>("*", typeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());

		// scala style "select all"
		fpk = new ExpressionKeys<>("_", typeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());

		// this was a bug:
		fpk = new ExpressionKeys<>("f2", typeInfo);
		Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f1.f2", "f2"}, typeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f2"}, typeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,4}, fpk.computeLogicalKeyPositions());

		fpk = new ExpressionKeys<>(new String[] {"f2", "f0"}, typeInfo);
		Assert.assertArrayEquals(new int[] {4,0}, fpk.computeLogicalKeyPositions());

		TupleTypeInfo<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexTypeInfo = new TupleTypeInfo<>(
				BasicTypeInfo.STRING_TYPE_INFO,
				new TupleTypeInfo<Tuple3<Tuple3<String, String, String>, String, String>>(new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
				BasicTypeInfo.STRING_TYPE_INFO);

		ExpressionKeys<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexFpk =
		new ExpressionKeys<>(0, complexTypeInfo);
		Assert.assertArrayEquals(new int[] {0}, complexFpk.computeLogicalKeyPositions());

		complexFpk = new ExpressionKeys<>(new int[] {0,1,2}, complexTypeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());

		complexFpk = new ExpressionKeys<>("*", complexTypeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());

		// scala style select all
		complexFpk = new ExpressionKeys<>("_", complexTypeInfo);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());

		complexFpk = new ExpressionKeys<>("f1.f0.*", complexTypeInfo);
		Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());

		complexFpk = new ExpressionKeys<>("f1.f0", complexTypeInfo);
		Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());

		complexFpk = new ExpressionKeys<>("f2", complexTypeInfo);
		Assert.assertArrayEquals(new int[] {6}, complexFpk.computeLogicalKeyPositions());
	}

	@Test
	public void testPojoKeys() {
		TypeInformation<PojoWithMultiplePojos> ti = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
		ExpressionKeys<PojoWithMultiplePojos> ek;
		ek = new ExpressionKeys<>("*", ti);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("p1.*", ti);
		Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("p2.*", ti);
		Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("p1", ti);
		Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("p2", ti);
		Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("i0", ti);
		Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
	}

	@Test
	public void testTupleWithNestedPojo() {

		TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti =
				new TupleTypeInfo<>(
					BasicTypeInfo.INT_TYPE_INFO,
					TypeExtractor.getForClass(Pojo1.class),
					TypeExtractor.getForClass(PojoWithMultiplePojos.class)
				);

		ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek;

		ek = new ExpressionKeys<>(0, ti);
		Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>(1, ti);
		Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>(2, ti);
		Assert.assertArrayEquals(new int[] {3,4,5,6,7}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>(new int[]{}, ti, true);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("*", ti);
		Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());

		ek = new ExpressionKeys<>("f2.p1.*", ti);
		Assert.assertArrayEquals(new int[] {4,5}, ek.computeLogicalKeyPositions());
	}

	@Test
	public void testOriginalTypes() {

		TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti =
				new TupleTypeInfo<>(
						BasicTypeInfo.INT_TYPE_INFO,
						TypeExtractor.getForClass(Pojo1.class),
						TypeExtractor.getForClass(PojoWithMultiplePojos.class)
				);

		ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek;

		ek = new ExpressionKeys<>(0, ti);
		Assert.assertArrayEquals(new TypeInformation[] {BasicTypeInfo.INT_TYPE_INFO}, ek.getOriginalKeyFieldTypes());

		ek = new ExpressionKeys<>(1, ti);
		Assert.assertArrayEquals(new TypeInformation[] {TypeExtractor.getForClass(Pojo1.class)}, ek.getOriginalKeyFieldTypes());

		ek = new ExpressionKeys<>(2, ti);
		Assert.assertArrayEquals(new TypeInformation[] {TypeExtractor.getForClass(PojoWithMultiplePojos.class)}, ek.getOriginalKeyFieldTypes());

		ek = new ExpressionKeys<>(new int[]{}, ti, true);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { BasicTypeInfo.INT_TYPE_INFO,
						TypeExtractor.getForClass(Pojo1.class),
						TypeExtractor.getForClass(PojoWithMultiplePojos.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("*", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { ti },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f1", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(Pojo1.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f1.*", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(Pojo1.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f2.*", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(PojoWithMultiplePojos.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f2.p2", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(Pojo2.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f2.p2.*", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(Pojo2.class) },
				ek.getOriginalKeyFieldTypes()
		);

		ek = new ExpressionKeys<>("f2.p2._", ti);
		Assert.assertArrayEquals(
				new TypeInformation<?>[] { TypeExtractor.getForClass(Pojo2.class) },
				ek.getOriginalKeyFieldTypes()
		);

	}

	@Test(expected = InvalidProgramException.class)
	public void testNonKeyPojoField() {
		// selected field is not a key type
		TypeInformation<PojoWithNonKeyField> ti = TypeExtractor.getForClass(PojoWithNonKeyField.class);
		new ExpressionKeys<>("b", ti);
	}

	@Test
	public void testInvalidPojo() throws Throwable {
		TypeInformation<ComplexNestedClass> ti = TypeExtractor.getForClass(ComplexNestedClass.class);

		String[][] tests = new String[][] {
			new String[] {"nonexistent"},
			new String[] {"date.abc"} // nesting into unnested
		};
		for (String[] test : tests) {
			Throwable e = null;
			try {
				new ExpressionKeys<>(test, ti);
			} catch (Throwable t) {
				e = t;
			}
			Assert.assertNotNull(e);
		}
	}

	@Test
	public void testAreCompatible1() throws Keys.IncompatibleKeysException {
		TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);

		ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
		ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1);

		Assert.assertTrue(ek1.areCompatible(ek2));
		Assert.assertTrue(ek2.areCompatible(ek1));
	}

	@Test
	public void testAreCompatible2() throws Keys.IncompatibleKeysException {
		TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
		TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO
		);

		ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
		ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);

		Assert.assertTrue(ek1.areCompatible(ek2));
		Assert.assertTrue(ek2.areCompatible(ek1));
	}

	@Test
	public void testAreCompatible3() throws Keys.IncompatibleKeysException {
		TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
		TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO
		);

		ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
		ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);

		Assert.assertTrue(ek1.areCompatible(ek2));
		Assert.assertTrue(ek2.areCompatible(ek1));
	}

	@Test
	public void testAreCompatible4() throws Keys.IncompatibleKeysException {
		TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
		TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO,
			BasicTypeInfo.INT_TYPE_INFO
		);

		ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1);
		ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2);

		Assert.assertTrue(ek1.areCompatible(ek2));
		Assert.assertTrue(ek2.areCompatible(ek1));
	}

	@Test
	public void testAreCompatible5() throws Keys.IncompatibleKeysException {
		TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
		TypeInformation<Tuple2<String, String>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.STRING_TYPE_INFO
		);

		ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1.b", "p2.a2"}, t1);
		ExpressionKeys<Tuple2<String, String>> ek2 = new ExpressionKeys<>("*", t2);

		Assert.assertTrue(ek1.areCompatible(ek2));
		Assert.assertTrue(ek2.areCompatible(ek1));
	}

	@Test(expected = Keys.IncompatibleKeysException.class)
	public void testAreCompatible6() throws Keys.IncompatibleKeysException {
		TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
		TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO
		);

		ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
		ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(1, t2);

		ek1.areCompatible(ek2);
	}

	@Test(expected = Keys.IncompatibleKeysException.class)
	public void testAreCompatible7() throws Keys.IncompatibleKeysException {
		TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
		TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO
		);

		ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>(new String[]{"a", "b"}, t1);
		ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);

		ek1.areCompatible(ek2);
	}

	@Test
	public void testAreCompatible8() throws Keys.IncompatibleKeysException {
		TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
		TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class);

		ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
		Keys<Pojo2> ek2 = new Keys.SelectorFunctionKeys<>(
				new KeySelector1(),
				t2,
				BasicTypeInfo.STRING_TYPE_INFO
			);

		Assert.assertTrue(ek1.areCompatible(ek2));
	}

	@Test
	public void testAreCompatible9() throws Keys.IncompatibleKeysException {
		TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>(
			BasicTypeInfo.STRING_TYPE_INFO,
			BasicTypeInfo.LONG_TYPE_INFO,
			BasicTypeInfo.INT_TYPE_INFO
		);
		TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);

		ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1);
		Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>(
			new KeySelector3(),
			t2,
			new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO)
		);

		Assert.assertTrue(ek1.areCompatible(ek2));
	}

	public static class Pojo1 {
		public String a;
		public String b;
	}

	public static class Pojo2 {
		public String a2;
		public String b2;
	}

	public static class PojoWithMultiplePojos {
		public Pojo1 p1;
		public Pojo2 p2;
		public Integer i0;
	}

	public static class PojoWithNonKeyField {
		public String a;
		public GenericNonKeyType b;
	}

	public static class GenericNonKeyType {
		private String a;
		private String b;
	}

	public static class GenericKeyType implements Comparable<GenericNonKeyType> {
		private String a;
		private String b;

		@Override
		public int compareTo(GenericNonKeyType o) {
			return 0;
		}
	}
}


text:
#include "HTMLOptionElementImp.h"

#include <org/w3c/dom/html/HTMLOptGroupElement.h>
#include <org/w3c/dom/html/HTMLSelectElement.h>

#include "one_at_a_time.hpp"

constexpr auto Intern = &one_at_a_time::hash<char16_t>;

#include "utf.h"

#include "DocumentImp.h"
#include "ECMAScript.h"
#include "WindowProxy.h"
#include "HTMLSelectElementImp.h"

namespace org
{
namespace w3c
{
namespace dom
{
namespace bootstrap
{

HTMLOptionElementImp::HTMLOptionElementImp(DocumentImp* ownerDocument) :
    ObjectMixin(ownerDocument, u"option"),
    disabled(false),
    selected(false)
{
}

HTMLOptionElementImp::HTMLOptionElementImp(const HTMLOptionElementImp& org) :
    ObjectMixin(org),
    disabled(org.disabled),
    selected(org.selected)
{
}

void HTMLOptionElementImp::handleMutation(events::MutationEvent mutation)
{
    switch (Intern(mutation.getAttrName().c_str())) {
    case Intern(u"disabled"):
        if (mutation.getAttrChange() == events::MutationEvent::REMOVAL)
            disabled = false;
        else
            disabled = true;
        break;
    case Intern(u"selected"):
        if (mutation.getAttrChange() == events::MutationEvent::REMOVAL)
            selected = false;
        else
            selected = true;
        break;
    default:
        HTMLElementImp::handleMutation(mutation);
        break;
    }
}

HTMLSelectElementPtr HTMLOptionElementImp::getSelect()
{
    Element parent = getParentElement();
    if (!parent)
        return nullptr;
    if (html::HTMLOptGroupElement::hasInstance(parent))
        parent = parent.getParentElement();
    if (!html::HTMLSelectElement::hasInstance(parent))
        return nullptr;
    return std::dynamic_pointer_cast<HTMLSelectElementImp>(parent.self());
}

bool HTMLOptionElementImp::getDisabled()
{
    return disabled;
}

void HTMLOptionElementImp::setDisabled(bool disabled)
{
    setAttributeAsBoolean(u"disabled", disabled);
}

html::HTMLFormElement HTMLOptionElementImp::getForm()
{
    if (HTMLSelectElementPtr select = getSelect())
        return select->getForm();
    return nullptr;
}

std::u16string HTMLOptionElementImp::getLabel()
{
    Nullable<std::u16string> label(getAttribute(u"label"));
    if (label.hasValue())
        return label.value();
    return getText();
}

void HTMLOptionElementImp::setLabel(const std::u16string& label)
{
    setAttribute(u"label", label);
}

bool HTMLOptionElementImp::getDefaultSelected()
{
    return getSelected();
}

void HTMLOptionElementImp::setDefaultSelected(bool defaultSelected)
{
    setSelected(defaultSelected);
}

bool HTMLOptionElementImp::getSelected()
{
    return selected;
}

void HTMLOptionElementImp::setSelected(bool selected)
{
    setAttributeAsBoolean(u"selected", selected);
}

std::u16string HTMLOptionElementImp::getValue()
{
    Nullable<std::u16string> value(getAttribute(u"value"));
    if (value.hasValue())
        return value.value();
    return getText();
}

void HTMLOptionElementImp::setValue(const std::u16string& value)
{
    setAttribute(u"value", value);
}

std::u16string HTMLOptionElementImp::getText()
{
    std::u16string text = getTextContent();
    return stripLeadingAndTrailingWhitespace(text);
}

void HTMLOptionElementImp::setText(const std::u16string& text)
{
    setTextContent(text);
}

int HTMLOptionElementImp::getIndex()
{
    if (HTMLSelectElementPtr select = getSelect())
        return select->getIndex(std::static_pointer_cast<HTMLOptionElementImp>(self()));
    return 0;
}

}  // org::w3c::dom::bootstrap

namespace html {

namespace {

class Constructor : public Object
{
public:
    // Object
    virtual Any message_(uint32_t selector, const char* id, int argc, Any* argv) {
        auto window = dynamic_cast<bootstrap::WindowProxy*>(ECMAScriptContext::getCurrent());
        if (!window)
            return nullptr;
        auto owner = static_cast<bootstrap::DocumentImp*>(window->getDocument().self().get());
        if (!owner)
            return nullptr;
        bootstrap::HTMLOptionElementPtr option;
        switch (argc) {
        case 0:
            option = std::make_shared<bootstrap::HTMLOptionElementImp>(owner);
            break;
        case 1:
            option = std::make_shared<bootstrap::HTMLOptionElementImp>(owner);
            option->setText(argv[0].toString());
            break;
        case 2:
            option = std::make_shared<bootstrap::HTMLOptionElementImp>(owner);
            option->setText(argv[0].toString());
            option->setValue(argv[1].toString());
            break;
        case 3:
            option = std::make_shared<bootstrap::HTMLOptionElementImp>(owner);
            option->setText(argv[0].toString());
            option->setValue(argv[1].toString());
            option->setDefaultSelected(argv[2].toBoolean());
            break;
        case 4:
            option = std::make_shared<bootstrap::HTMLOptionElementImp>(owner);
            option->setText(argv[0].toString());
            option->setValue(argv[1].toString());
            option->setDefaultSelected(argv[2].toBoolean());
            option->setSelected(argv[3].toBoolean());
            break;
        default:
            break;
        }
        return option;
    }
    Constructor() :
        Object(this) {
    }
};

}  // namespace

Object HTMLOptionElement::getConstructor()
{
    static Constructor constructor;
    return constructor.self();
}

}

}}}  // org::w3c::dom::bootstrap

redpajama_set_name: RedPajamaGithub


text:
package com.google.javascript.rhino.jstype;

import com.google.javascript.rhino.Node;

/**
 * A builder class for function and arrow types.
 *
 * If you need to build an interface constructor,
 * use {@link JSTypeRegistry#createInterfaceType}.
 *
 * @author nicksantos@google.com (Nick Santos)
 */
public final class FunctionBuilder {
  private final JSTypeRegistry registry;
  private String name = null;
  private Node sourceNode = null;
  private Node parametersNode = null;
  private JSType returnType = null;
  private ObjectType typeOfThis = null;
  private String templateTypeName = null;
  private boolean inferredReturnType = false;
  private boolean isConstructor = false;
  private boolean isNativeType = false;

  public FunctionBuilder(JSTypeRegistry registry) {
    this.registry = registry;
  }

  /** Set the name of the function type. */
  public FunctionBuilder withName(String name) {
    this.name = name;
    return this;
  }

  /** Set the source node of the function type. */
  public FunctionBuilder withSourceNode(Node sourceNode) {
    this.sourceNode = sourceNode;
    return this;
  }

  /** Set the parameters of the function type from a FunctionParamBuilder. */
  public FunctionBuilder withParams(FunctionParamBuilder params) {
    this.parametersNode = params.build();
    return this;
  }

  /**
   * Set the parameters of the function type with a specially-formatted node.
   */
  public FunctionBuilder withParamsNode(Node parametersNode) {
    this.parametersNode = parametersNode;
    return this;
  }

  /** Set the return type. */
  public FunctionBuilder withReturnType(JSType returnType) {
    this.returnType = returnType;
    return this;
  }

  /** Set the return type and whether it's inferred. */
  public FunctionBuilder withReturnType(JSType returnType, boolean inferred) {
    this.returnType = returnType;
    this.inferredReturnType = inferred;
    return this;
  }

  /** Sets an inferred return type. */
  public FunctionBuilder withInferredReturnType(JSType returnType) {
    this.returnType = returnType;
    this.inferredReturnType = true;
    return this;
  }

  /** Set the "this" type. */
  public FunctionBuilder withTypeOfThis(ObjectType typeOfThis) {
    this.typeOfThis = typeOfThis;
    return this;
  }

  /** Set the template name. */
  public FunctionBuilder withTemplateName(String templateTypeName) {
    this.templateTypeName = templateTypeName;
    return this;
  }

  /** Make this a constructor. */
  public FunctionBuilder forConstructor() {
    this.isConstructor = true;
    return this;
  }

  /** Make this a native type. */
  FunctionBuilder forNativeType() {
    this.isNativeType = true;
    return this;
  }

  /** Copies all the information from another function type. */
  public FunctionBuilder copyFromOtherFunction(FunctionType otherType) {
    this.name = otherType.getReferenceName();
    this.sourceNode = otherType.getSource();
    this.parametersNode = otherType.getParametersNode();
    this.returnType = otherType.getReturnType();
    this.typeOfThis = otherType.getTypeOfThis();
    this.templateTypeName = otherType.getTemplateTypeName();
    this.isConstructor = otherType.isConstructor();
    this.isNativeType = otherType.isNativeObjectType();
    return this;
  }

  /** Construct a new function type. */
  public FunctionType build() {
    return new FunctionType(registry, name, sourceNode,
        new ArrowType(registry, parametersNode, returnType, inferredReturnType),
        typeOfThis, templateTypeName, isConstructor, isNativeType);
  }
}


text:
@implementation Product

@dynamic amount;
@dynamic price;
@dynamic title;
@dynamic country;

@end


text:
package org.codehaus.enunciate.modules.objc.config;

/**
 * A package-identifier mapping.
 *
 * @author Ryan Heaton
 */
public class PackageIdentifier {

  private String name;
  private String identifier;

  public String getName() {
    return name;
  }

  public void setName(String pckg) {
    this.name = pckg;
  }

  public String getIdentifier() {
    return identifier;
  }

  public void setIdentifier(String identifier) {
    this.identifier = identifier;
  }
}


text:
<?php

namespace Fdr\AdminBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * MissionAffretementRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class MissionAffretementRepository extends EntityRepository {

}


text:
<bill session="110" type="h" number="1995" updated="2009-01-08T21:01:27-05:00">
	<status><introduced date="1177300800" datetime="2007-04-23"/></status>

	<introduced date="1177300800" datetime="2007-04-23"/>
	<titles>
		<title type="short" as="introduced">Tulsa-Greenwood Race Riot Claims Accountability Act of 2007</title>
		<title type="official" as="introduced">To provide a mechanism for a determination on the merits of the claims brought by survivors and descendants of the victims of the Tulsa, Oklahoma, Race Riot of 1921 but who were denied that determination.</title>
	</titles>
	<sponsor id="400080"/>
	<cosponsors>
		<cosponsor id="400289" joined="2007-04-23"/>
	</cosponsors>
	<actions>
		<action date="1177300800" datetime="2007-04-23"><text>Sponsor introductory remarks on measure. (CR E834)</text></action>
		<action date="1177300800" datetime="2007-04-23"><text>Referred to the House Committee on the Judiciary.</text></action>
		<action date="1177300800" datetime="2007-04-23"><text>Referred to the Subcommittee on the Constitution, Civil Rights, and Civil Liberties.</text></action>
		<action date="1177387200" datetime="2007-04-24"><text>Subcommittee Hearings Held.</text></action>
	</actions>
	<committees>

	</committees>
	<relatedbills>

	</relatedbills>
	<subjects>

	</subjects>
	<amendments>

	</amendments>
	<summary>
	4/23/2007--Introduced.<br/>Tulsa-Greenwood Race Riots Claims Accountability Act of 2007 - Provides that any Greenwood, Oklahoma, claimant (a survivor or descendant of victims of the Tulsa, Oklahoma, Race Riot of 1921) who has not previously obtained a determination on the merits of a Greenwood claim may, in a civil action commenced within five years after enactment of this Act, obtain that determination.
	</summary>
</bill>


text:
<<<<<<< HEAD
<<<<<<< HEAD
markupsafe package
==================

Submodules
----------

markupsafe.tests module
-----------------------

.. automodule:: markupsafe.tests
    :members:
    :undoc-members:
    :show-inheritance:

Module contents
---------------

.. automodule:: markupsafe
    :members:
    :undoc-members:
    :show-inheritance:
=======
markupsafe package
==================

Submodules
----------

markupsafe.tests module
-----------------------

.. automodule:: markupsafe.tests
    :members:
    :undoc-members:
    :show-inheritance:

Module contents
---------------

.. automodule:: markupsafe
    :members:
    :undoc-members:
    :show-inheritance:
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453
=======
markupsafe package
==================

Submodules
----------

markupsafe.tests module
-----------------------

.. automodule:: markupsafe.tests
    :members:
    :undoc-members:
    :show-inheritance:

Module contents
---------------

.. automodule:: markupsafe
    :members:
    :undoc-members:
    :show-inheritance:
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453


text:
package org.elasticsearch.plugin.analysis.icu;

import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.index.analysis.IcuCollationTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuFoldingTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuNormalizerCharFilterFactory;
import org.elasticsearch.index.analysis.IcuNormalizerTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuTokenizerFactory;
import org.elasticsearch.index.analysis.IcuTransformTokenFilterFactory;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider;
import org.elasticsearch.plugins.AnalysisPlugin;
import org.elasticsearch.plugins.Plugin;

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

import static java.util.Collections.singletonMap;

public class AnalysisICUPlugin extends Plugin implements AnalysisPlugin {
    @Override
    public Map<String, AnalysisProvider<CharFilterFactory>> getCharFilters() {
        return singletonMap("icu_normalizer", IcuNormalizerCharFilterFactory::new);
    }

    @Override
    public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
        Map<String, AnalysisProvider<TokenFilterFactory>> extra = new HashMap<>();
        extra.put("icu_normalizer", IcuNormalizerTokenFilterFactory::new);
        extra.put("icu_folding", IcuFoldingTokenFilterFactory::new);
        extra.put("icu_collation", IcuCollationTokenFilterFactory::new);
        extra.put("icu_transform", IcuTransformTokenFilterFactory::new);
        return extra;
    }

    @Override
    public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
        return singletonMap("icu_tokenizer", IcuTokenizerFactory::new);
    }
}


text:
package com.beecavegames.persistence;

import java.io.IOException;
import java.io.Serializable;

import lombok.Getter;
import lombok.Setter;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIndexRangeKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.beecavegames.persistence.transcoders.Key;

@DynamoDBTable(tableName="fake")
@Getter @Setter
public class ExpirableLongKeyedVO<T extends Serializable> extends LongKeyedVO<T> {
	private static final long serialVersionUID = -8277994799880550746L;

	public ExpirableLongKeyedVO() {}

	public ExpirableLongKeyedVO(T entity) throws IOException {
		super(entity);
	}

	@DynamoDBHashKey
	@Key
	public Long getKey() {
		return key;
	}

	@DynamoDBAttribute
	public byte[] getData() {
		return data;
	}

	@DynamoDBAttribute
	public int getVersion() {
		return version;
	}

	@DynamoDBAttribute
	public int getFlags() {
		return flags;
	}

	@DynamoDBAttribute
	public int getVersionCode() {
		return versionCode;
	}

	@DynamoDBIndexHashKey(globalSecondaryIndexName="typeName-expiration-index")
	public String getTypeName() {
		return super.getTypeName();
	}

	@DynamoDBIndexRangeKey(globalSecondaryIndexName="typeName-expiration-index")
	public long getExpiration() {
		return super.getExpiration();
	}

}


text:
package powerflowApi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.fortiss.powerflowsim.model.CimModel;
import org.fortiss.powerflowsim.simulation.internal.BusBranchModel;
import org.fortiss.powerflowsim.simulation.internal.Solver;

import CIM15.IEC61970.Core.ConductingEquipment;
import CIM15.IEC61970.Topology.TopologicalNode;
import CIM15.IEC61970.Wires.EnergyConsumer;
import CIM15.IEC61970.Wires.EnergySource;
import configuration.GridArchitectConfiguration;

/**
 * PowerflowApi is used to initialize trigger the solver to calculate the
 * powerflow equations.
 *
 * @author Denis Bytschkow
 * @since Mar 13, 2014
 *
 */
public class PowerflowApi {

	private static Logger log = LogManager.getLogger(PowerflowApi.class);

	public static void execute() {

		// previous solution only as reminder
		// log.setLevel(Level.WARN);
		Configurator.setLevel(log.getName(), Level.WARN);

		log.debug("enter execute() method of PowerflowApi.class");
		log.info(PowerflowMapping.getPowerflowTopology() + " --- Execute Power Flow Calcultations");

		CimModel cimModel = PowerflowMapping.getPowerflowTopology().CIMmodel;

		for (String key : PowerflowMapping.actorResultsMap.keySet()) {
			// get mrid from mapping
			String mRID = PowerflowMapping.pathMridMap.get(key);

			// get object for mapped mRID
			Object object = cimModel.getObjectWithMRID(mRID);

			if (object instanceof TopologicalNode) {
				TopologicalNode bus = (TopologicalNode) object;

				ConductingEquipment conductingEquipment = bus.getTerminal().get(0).getConductingEquipment();

				// if the conducting equipment is a consumer, set the active
				// power consumption to the value of the active power set point
				// multiplied by (-1) and the reactive power consumption to the
				// value of the reactive power set point multiplied by (-1).
				// TODO check weather the multiplication with (-1) is really done.
				if (conductingEquipment instanceof EnergyConsumer) {

					//System.out.println("PowerflowApi.execute(): EnergyConsumer " + mRID);

					EnergyConsumer energyConsumer =	(EnergyConsumer) conductingEquipment;
					energyConsumer.setPfixed(new Float(PowerflowMapping.actorResultsMap.get(key).activePower));
					energyConsumer.setQfixed(new Float(PowerflowMapping.actorResultsMap.get(key).reactivePower));
				}

				// if the conducting equipment is a source, set the power
				// consumption to the value of the active power set point
				// reactive power is a lose variable for sources (!)
				else if (conductingEquipment instanceof EnergySource) {

					//System.out.println("PowerflowApi.execute(): EnergySource " + mRID);

					EnergySource energySource = (EnergySource) conductingEquipment;
					energySource.setActivePower(new Float(PowerflowMapping.actorResultsMap.get(key).activePower));
					energySource.setVoltageMagnitude(new Float(PowerflowMapping.actorResultsMap.get(key).voltage));
				}
			}
		}

		String matrixResults = Solver.solve_model(cimModel);
		log.debug(matrixResults);
		printResults();
	}

	/**
	 * Print the results to the console
	 */
	private static void printResults() {

		if (GridArchitectConfiguration.showPowerFlowDetails){

			System.out.println(PowerflowApi.class + " --> Results of the solver\n");

			BusBranchModel model = Solver.getSimulationModel();

			ArrayList<TopologicalNode> myList = new ArrayList<TopologicalNode>(model.indexNodeMap.values());

			Collections.sort(myList, new Comparator<TopologicalNode>(){

				/*
				public int compare(TopologicalNode t1, TopologicalNode t2) {
					return t1.getMRID().compareTo(t2.getMRID());
				}
				*/

	            public int compare(TopologicalNode t1, TopologicalNode t2) {
	                /*
	                 * Pattern:
	                 * Groß-/Kleinbuchstaben mit einem Vorkommen von 0 ... unendlich
	                 * Zahlen mit einem Vorkommen von 1 ... unendlich
	                 */
	                Pattern p = Pattern.compile("([a-zA-Z]*)([0-9]+)");
	                Matcher m;
	                int num1 = -1;
	                int num2 = -1;
	                String str1 = ""; // ÄNDERUNG
	                String str2 = ""; // ÄNDERUNG

	                // str1 & num1
	                m = p.matcher(t1.getMRID());
	                if(m.find()) {
	                    // Gruppenindex 0 => Gesamter Fund
	                    // Gruppenindex 1 => 1. Gruppe (hier die
	                    // Buchstabenkombination)
	                    // Gruppenindex 2 => 2. Gruppe (hier die Zahlenkombination)
	                    str1 = m.group(1); // ÄNDERUNG
	                    num1 = Integer.parseInt(m.group(2));
	                }

	                // str2 & num2
	                m = p.matcher(t2.getMRID());
	                if(m.find()) {
	                    // Gruppenindex 0 => Gesamter Fund
	                    // Gruppenindex 1 => 1. Gruppe (hier die
	                    // Buchstabenkombination)
	                    // Gruppenindex 2 => 2. Gruppe (hier die Zahlenkombination)
	                    str2 = m.group(1); // ÄNDERUNG
	                    num2 = Integer.parseInt(m.group(2));
	                }

	                // Vergleichen
	                if(str1.compareTo(str2) != 0) return str1.compareTo(str2); // ÄNDERUNG

	                // Gleiche Strings? Also Zahlenwerte prüfen!
	                if(num1 < num2) return -1;
	                if(num1 > num2) return 1;

	                return 0;
	            }
			});
			for (TopologicalNode topologicalNode : myList) {
				System.out.println(model.getPowerToNode(model.nodeIndexMap.get(topologicalNode)));
			}
		}
	}
}


text:
    // Init
    open('@{JPAController.init()}')
    assertTextPresent('Post1')
    assertTextPresent('Blue')
    assertTextPresent('Red')

    // Don't edit name
    open('@{JPAController.dontEditName()}')
    assertTextPresent('Post1')
    assertTextPresent('Blue')
    assertTextPresent('Red')

    // Edit name
    open('@{JPAController.editName()}')
    assertTextPresent('Kiki')
    assertTextPresent('Blue')
    assertTextPresent('Red')

    // Don't edit tags
    open('@{JPAController.dontEditTags()}')
    assertTextPresent('Kiki')
    assertTextPresent('Blue')
    assertTextPresent('Red')

    // Edit tags
    open('@{JPAController.editTags()}')
    assertTextPresent('Kiki')
    assertTextNotPresent('Blue')
    assertTextPresent('Red')

    // Don't replace tags
    open('@{JPAController.dontReplaceTags()}')
    assertTextPresent('Kiki')
    assertTextNotPresent('Blue')
    assertTextPresent('Red')
    assertTextNotPresent('Green')

    // Replace tags
    open('@{JPAController.replaceTags()}')
    assertTextPresent('Kiki')
    assertTextNotPresent('Blue')
    assertTextNotPresent('Red')
    assertTextPresent('Green')

    // Don't delete tags
    open('@{JPAController.dontDeleteTags()}')
    assertTextPresent('Kiki')
    assertTextNotPresent('Blue')
    assertTextNotPresent('Red')
    assertTextPresent('Green')

    // Delete tags
    open('@{JPAController.deleteTags()}')
    assertTextPresent('Kiki')
    assertTextNotPresent('Blue')
    assertTextNotPresent('Red')
    assertTextNotPresent('Green')

	// Will save
	open('@{JPAController.index()}')
	getEval('window.document.getElementById("form").action="@{JPAController.willSave()}"')
	type('name', 'Toto1')
	clickAndWait('save')
	assertTextPresent('Toto1')

	// Will not save
	open('@{JPAController.index()}')
	getEval('window.document.getElementById("form").action="@{JPAController.willNotSave()}"')
	type('name', 'Toto2')
	clickAndWait('save')
	assertTextNotPresent('Toto2')

	// Will save
	open('@{JPAController.index()}')
	getEval('window.document.getElementById("form").action="@{JPAController.willSave()}"')
	type('name', 'Toto2')
	clickAndWait('save')
	assertTextPresent('Toto2')

	// Edit
	open('@{JPAController.edit('Toto2', 'New toto2')}')
	assertTextPresent('Toto2')
	assertTextNotPresent('New toto2')

	// Edit and save
	open('@{JPAController.editAndSave('Toto2', 'New toto2')}')
	assertTextNotPresent('Toto2')
	assertTextPresent('New toto2')

	// Create and edit
	open('@{JPAController.createAndEdit('Toto3', 'New toto3')}')
	assertTextPresent('Toto3')
	assertTextNotPresent('New toto3')

	// Create and edit and save
	open('@{JPAController.createAndEditAndSave('Toto4', 'New toto4')}')
	assertTextNotPresent('Toto4')
	assertTextPresent('New toto4')

#{/selenium}


text:
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.net.spdyproxy;

import org.chromium.base.CalledByNative;
import org.chromium.base.ThreadUtils;

public class DataReductionProxySettings {

    public static class ContentLengths {
        private final long mOriginal;
        private final long mReceived;

        @CalledByNative("ContentLengths")
        public static ContentLengths create(long original, long received) {
            return new ContentLengths(original, received);
        }

        private ContentLengths(long original, long received) {
            mOriginal = original;
            mReceived = received;
        }

        public long getOriginal() {
            return mOriginal;
        }

        public long getReceived() {
            return mReceived;
        }
    }

    private static DataReductionProxySettings sSettings;

    public static DataReductionProxySettings getInstance() {
        ThreadUtils.assertOnUiThread();
        if (sSettings == null) {
            sSettings = new DataReductionProxySettings();
        }
        return sSettings;
    }

    private final long mNativeDataReductionProxySettings;

    private DataReductionProxySettings() {
        // Note that this technically leaks the native object, however,
        // DataReductionProxySettings is a singleton that lives forever and there's no clean
        // shutdown of Chrome on Android
        mNativeDataReductionProxySettings = nativeInit();
        initDataReductionProxySettings();
    }

    /**
     * Initializes the data reduction proxy at Chrome startup.
     */
    public void initDataReductionProxySettings() {
        nativeInitDataReductionProxySettings(mNativeDataReductionProxySettings);
    }

    /**
     * Add a pattern for hosts to bypass. Wildcards should be compatible with the JavaScript
     * function shExpMatch, which can be used in proxy PAC resolution. This should be called
     * before the proxy is used.
     * @param pattern A pattern to match.
     */
    public void bypassHostPattern(String pattern) {
        nativeBypassHostPattern(mNativeDataReductionProxySettings, pattern);
    }

    /**
     * Add a pattern for URLs to bypass. Wildcards should be compatible with the JavaScript
     * function shExpMatch, which can be used in proxy PAC resolution. This should be called
     * before the proxy is used.
     * @param pattern A pattern to match.
     */
    public void bypassURLPattern(String pattern) {
        nativeBypassURLPattern(mNativeDataReductionProxySettings, pattern);
    }

    /** Returns true if the SPDY proxy is allowed to be used. */
    public boolean isDataReductionProxyAllowed() {
        return nativeIsDataReductionProxyAllowed(mNativeDataReductionProxySettings);
    }

    /** Returns true if the SPDY proxy promo is allowed to be shown. */
    public boolean isDataReductionProxyPromoAllowed() {
        return nativeIsDataReductionProxyPromoAllowed(mNativeDataReductionProxySettings);
    }

    /**
     * Returns the current data reduction proxy origin.
     */
    public String getDataReductionProxyOrigin() {
        return nativeGetDataReductionProxyOrigin(mNativeDataReductionProxySettings);
    }

    /**
     * Sets the preference on whether to enable/disable the SPDY proxy. This will zero out the
     * data reduction statistics if this is the first time the SPDY proxy has been enabled.
     */
    public void setDataReductionProxyEnabled(boolean enabled) {
        nativeSetDataReductionProxyEnabled(mNativeDataReductionProxySettings, enabled);
    }

    /** Returns true if the SPDY proxy is enabled. */
    public boolean isDataReductionProxyEnabled() {
        return nativeIsDataReductionProxyEnabled(mNativeDataReductionProxySettings);
    }

    /** Returns true if the SPDY proxy is managed by an administrator's policy. */
    public boolean isDataReductionProxyManaged() {
        return nativeIsDataReductionProxyManaged(mNativeDataReductionProxySettings);
    }

    /**
     * Returns the time that the data reduction statistics were last updated.
     * @return The last update time in milliseconds since the epoch.
     */
    public long getDataReductionLastUpdateTime()  {
        return nativeGetDataReductionLastUpdateTime(mNativeDataReductionProxySettings);
    }

    /**
     * Returns aggregate original and received content lengths.
     * @return The content lengths.
     */
    public ContentLengths getContentLengths() {
        return nativeGetContentLengths(mNativeDataReductionProxySettings);
    }

    /**
     * Returns true if the host and realm (as passed in to Tab.onReceivedHttpAuthRequest()) are such
     * that a authentication token can be generated. The host must match one of the configured proxy
     * hosts, and the realm must be prefixed with the authentication realm string used by the data
     * reduction proxies.
     * @param host The host requesting authentication.
     * @param realm The authentication realm.
     * @return True if host and realm can be authenticated.
     */
    public boolean isAcceptableAuthChallenge(String host, String realm) {
        return nativeIsAcceptableAuthChallenge(mNativeDataReductionProxySettings, host, realm);
    }

    /**
     * Returns an authentication token for the data reduction proxy. If the token cannot be
     * generated, an empty string is returned.
     * @param host The host requesting authentication.
     * @param realm The authentication realm.
     * @return The generated token.
     */
    public String getTokenForAuthChallenge(String host, String realm) {
        return nativeGetTokenForAuthChallenge(mNativeDataReductionProxySettings, host, realm);
    }

    /**
     * Retrieves the history of daily totals of bytes that would have been
     * received if no data reducing mechanism had been applied.
     * @return The history of daily totals
     */
    public long[] getOriginalNetworkStatsHistory() {
        return nativeGetDailyOriginalContentLengths(mNativeDataReductionProxySettings);
    }

    /**
     * Retrieves the history of daily totals of bytes that were received after
     * applying a data reducing mechanism.
     * @return The history of daily totals
     */
    public long[] getReceivedNetworkStatsHistory() {
        return nativeGetDailyReceivedContentLengths(mNativeDataReductionProxySettings);
    }

    /**
     * @return The data reduction settings as a string percentage.
     */
    public String getContentLengthPercentSavings() {
        ContentLengths length = getContentLengths();
        String percent = "0%";
        if (length.getOriginal() > 0L  && length.getOriginal() > length.getReceived()) {
            percent = String.format(
                    "%.0f%%", 100.0 *
                    (length.getOriginal() - length.getReceived()) / length.getOriginal());
        }
        return percent;
    }

    private native long nativeInit();
    private native void nativeInitDataReductionProxySettings(
            long nativeDataReductionProxySettingsAndroid);
    private native void nativeBypassHostPattern(
            long nativeDataReductionProxySettingsAndroid, String pattern);
    private native void nativeBypassURLPattern(
            long nativeDataReductionProxySettingsAndroid, String pattern);
    private native boolean nativeIsDataReductionProxyAllowed(
            long nativeDataReductionProxySettingsAndroid);
    private native boolean nativeIsDataReductionProxyPromoAllowed(
            long nativeDataReductionProxySettingsAndroid);
    private native String nativeGetDataReductionProxyOrigin(
            long nativeDataReductionProxySettingsAndroid);
    private native boolean nativeIsDataReductionProxyEnabled(
            long nativeDataReductionProxySettingsAndroid);
    private native boolean nativeIsDataReductionProxyManaged(
            long nativeDataReductionProxySettingsAndroid);
    private native void nativeSetDataReductionProxyEnabled(
            long nativeDataReductionProxySettingsAndroid, boolean enabled);
    private native long nativeGetDataReductionLastUpdateTime(
            long nativeDataReductionProxySettingsAndroid);
    private native ContentLengths nativeGetContentLengths(
            long nativeDataReductionProxySettingsAndroid);
    private native boolean nativeIsAcceptableAuthChallenge(
            long nativeDataReductionProxySettingsAndroid, String host, String realm);
    private native String nativeGetTokenForAuthChallenge(
            long nativeDataReductionProxySettingsAndroid, String host, String realm);
    private native long[] nativeGetDailyOriginalContentLengths(
            long nativeDataReductionProxySettingsAndroid);
    private native long[] nativeGetDailyReceivedContentLengths(
            long nativeDataReductionProxySettingsAndroid);
}


text:
from gwt.ui.AbsolutePanel import (
    AbsolutePanel,
    ComplexPanel,
    DOM,
    Factory,
)


text:
import ray
from ray.monitor import parse_resource_demands

def test_parse_resource_demands():
    resource_load_by_shape = ray.gcs_utils.ResourceLoad(resource_demands=[
        ray.gcs_utils.ResourceDemand(
            shape={"CPU": 1},
            num_ready_requests_queued=1,
            num_infeasible_requests_queued=0,
            backlog_size=0),
        ray.gcs_utils.ResourceDemand(
            shape={"CPU": 2},
            num_ready_requests_queued=1,
            num_infeasible_requests_queued=0,
            backlog_size=1),
        ray.gcs_utils.ResourceDemand(
            shape={"CPU": 3},
            num_ready_requests_queued=0,
            num_infeasible_requests_queued=1,
            backlog_size=2),
        ray.gcs_utils.ResourceDemand(
            shape={"CPU": 4},
            num_ready_requests_queued=1,
            num_infeasible_requests_queued=1,
            backlog_size=2),
    ])

    waiting, infeasible = \
        parse_resource_demands(resource_load_by_shape)

    assert waiting.count({"CPU": 1}) == 1
    assert waiting.count({"CPU": 2}) == 2
    assert infeasible.count({"CPU": 3}) == 3
    # The {"CPU": 4} case here is inconsistent, but could happen. Since the
    # heartbeats are eventually consistent, we won't worry about whether it's
    # counted as infeasible or waiting, as long as it's accounted for and
    # doesn't cause an error.
    assert len(waiting + infeasible) == 10


text:
export function array_to_object(names,values) {
    return names.reduce(function(acc, val, i) {
        acc[val] = values[i];
        return acc;
    }, {});
}


text:
package com.asakusafw.modelgen.model;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 別のモデルを結合した構造を表現するモデル。
 */
public class JoinedModelDescription extends ModelDescription {

    private List<Source> leftCondition;

    private List<Source> rightCondition;

    /**
     * インスタンスを生成する。
     * @param reference 自身への参照
     * @param properties 結合結果のプロパティ一覧
     * @param leftCondition 左側の結合条件に利用するソースの一覧
     * @param rightCondition 右側の結合条件に利用するソースの一覧
     */
    public JoinedModelDescription(
            ModelReference reference,
            List<ModelProperty> properties,
            List<Source> leftCondition,
            List<Source> rightCondition) {
        super(reference, properties);
        if (leftCondition.isEmpty()) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "結合条件が指定されていません ({0})",
                    reference));
        }
        if (leftCondition.size() != rightCondition.size()) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "結合条件が左右で異なります ({0})",
                    reference));
        }
        this.leftCondition = Collections.unmodifiableList(
                new ArrayList<>(leftCondition));
        this.rightCondition = Collections.unmodifiableList(
                new ArrayList<>(rightCondition));
    }

    @Override
    protected Source convertPropertyToSource(ModelProperty property) {
        return new Source(
                Aggregator.IDENT,
                getReference(),
                property.getName(),
                property.getType(),
                Collections.<Attribute>emptySet());
    }

    /**
     * 左側のモデル(FROM _)の情報を返す。
     * @return 左側のモデル名
     */
    public ModelReference getFromModel() {
        return leftCondition.get(0).getDeclaring();
    }

    /**
     * 右側のモデル(JOIN _)の情報を返す。
     * @return 右側のモデル名
     */
    public ModelReference getJoinModel() {
        return rightCondition.get(0).getDeclaring();
    }

    /**
     * 左側の結合条件に利用するソースの一覧を返す。
     * @return 左側の結合条件に利用するソースの一覧
     */
    public List<Source> getFromCondition() {
        return leftCondition;
    }

    /**
     * 右側の結合条件に利用するソースの一覧を返す。
     * @return 右側の結合条件に利用するソースの一覧
     */
    public List<Source> getJoinCondition() {
        return rightCondition;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result += result * prime + getReference().hashCode();
        result += result * prime + getProperties().hashCode();
        result += result * prime + leftCondition.hashCode();
        result += result * prime + rightCondition.hashCode();
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        JoinedModelDescription other = (JoinedModelDescription) obj;
        if (getReference().equals(other.getReference()) == false) {
            return false;
        }
        if (getProperties().equals(other.getProperties()) == false) {
            return false;
        }
        if (leftCondition.equals(other.leftCondition) == false) {
            return false;
        }
        if (rightCondition.equals(other.rightCondition) == false) {
            return false;
        }
        return true;
    }
}


text:
import {Button} from 'antd';
import React from 'react';
import Page from '../components/Page';
import Padded from '../components/Padded';
import Playground from '../components/Playground/src';
import {Row, Col} from 'antd';
import './index.css';
import ReactNativeLogo from './logos/reactnative.png';
import LithoLogo from './logos/litho.png';
import ComponentKitLogo from './logos/componentkit.png';
import ReactPDFLogo from './logos/reactpdf.png';
import Link from 'gatsby-link';
import Footer from '../components/Footer';

const playgroundInitialState = {
  width: 500,
  height: 500,
  alignItems: 1,
  padding: {
    top: '20',
    right: '20',
    bottom: '20',
    left: '20',
  },
  children: [
    {
      width: 100,
      height: 100,
      minWidth: null,
      maxWidth: null,
      minHeight: null,
      maxHeight: null,
    },
    {
      width: 100,
      height: 100,
      margin: {
        right: '20',
        left: '20',
      },
      flexGrow: '1',
      minWidth: null,
      maxWidth: null,
      minHeight: null,
      maxHeight: null,
    },
    {
      width: 100,
      height: 100,
      minWidth: null,
      maxWidth: null,
      minHeight: null,
      maxHeight: null,
    },
  ],
  minWidth: null,
  maxWidth: null,
  minHeight: null,
  maxHeight: null,
};

const HeroSection = () => (
  <Padded>
    <Row className="hero">
      <Col md={12} sm={24} xs={24}>

INTRODUCING

          Flexible Layouts
 with Yoga

          Build flexible layouts on any platform with a highly optimized open
          source layout engine designed with speed, size, and ease of use in
          mind.

        <Link to="/docs">
          <Button type="primary" className="button">
            LEARN MORE
          </Button>
        </Link>
      </Col>
      <Col md={12} sm={0} xs={0}>

      </Col>
    </Row>
  </Padded>
);

const PlaygroundSection = () => (
  <Row>
    <Col lg={24} md={0} sm={0} xs={0}>
      <Playground
        selectedNodePath={[]}
        showGuides={true}
        height={601}
        layoutDefinition={playgroundInitialState}
      />
    </Col>
  </Row>
);

const AboutSectionOne = () => (
  <Padded className="about-section">
    <Row>
      <Col xl={16} lg={16} md={24} sm={24} xs={24}>

Open Source Adoption

          Yoga already powers widely used open source frameworks. It enables
          these frameworks to offer a simple and intuitive layout API that
          allows for engineers to collaborate more easily across platforms. Yoga
          has unlocked exciting features such as calculating layouts off of the
          main thread to help ensure smooth UI performance.

      </Col>
    </Row>

Litho

ComponentKit

React Native

React-PDF

  </Padded>
);

const AboutSectionTwo = () => (
  <Padded className="about-section">
    <Row>
      <Col xl={16} lg={16} md={24} sm={24} xs={24}>

Why You May Consider Yoga

PERFORMANCE

          Yoga was built to be fast and performance will always be one of Yoga's
          primary goals. For a layout engine to be able to power any range of
          applications, it needs to be fast and never stand in the way of a
          fluid user experience.

CROSS PLATFORM

          Yoga is built with cross platform in mind. To ensure Yoga can be used
          anywhere, it was written in portable C/C++ and has a low number of
          dependencies and small binary size. This means Yoga can be used on iOS
          and Android, sharing knowledge, and potentially code, between
          platforms.

EASY TO LEARN

          Yoga is easy to pick up and learn. The interactive documentation pages
          and a fully fledged layout editor makes it easy to play and learn all
          the features. If used with any of the major UI frameworks the layout
          editor even provides code generation.

      </Col>
    </Row>
  </Padded>
);

export default () => (

    <Page className="landing-page" title="A cross-platform layout engine">
      <HeroSection />
      <PlaygroundSection />
      <AboutSectionOne />

      <AboutSectionTwo />

    </Page>

);


text:
DROP VIEW IF EXISTS dropped_pipeline_reporter_slice;
CREATE VIEW dropped_pipeline_reporter_slice AS
SELECT slice.* FROM slice
INNER JOIN args
ON slice.arg_set_id = args.arg_set_id
WHERE
  slice.name = 'PipelineReporter'
  AND args.string_value = 'STATE_DROPPED';

-- Find the upid of the proccesses where the dropped frames occur.
DROP VIEW IF EXISTS dropped_frames_with_upid;
CREATE VIEW dropped_frames_with_upid AS
SELECT
  dropped_pipeline_reporter_slice.ts,
  process_track.upid
FROM dropped_pipeline_reporter_slice
INNER JOIN process_track
ON dropped_pipeline_reporter_slice.track_id = process_track.id;

-- Find the name and pid of the processes.
-- If the process name represents a file's pathname, the path part will be
-- removed from the display name of the process.
DROP VIEW IF EXISTS dropped_frames_with_process_info;
CREATE VIEW dropped_frames_with_process_info AS
SELECT
  dropped_frames_with_upid.ts,
  REPLACE(
    process.name,
    RTRIM(
      process.name,
      REPLACE(process.name, '/', '')
    ),
    '') AS process_name,
  process.pid AS process_id
FROM dropped_frames_with_upid
INNER JOIN process
ON dropped_frames_with_upid.upid = process.upid;

-- Create the derived event track for dropped frames.
-- All tracks generated from chrome_dropped_frames_event are
-- placed under a track group named 'Dropped Frames', whose summary
-- track is the first track ('All Processes') in chrome_dropped_frames_event.
-- Note that the 'All Processes' track is generated only when dropped frames
-- come from more than one origin process.
DROP VIEW IF EXISTS chrome_dropped_frames_event;
CREATE VIEW chrome_dropped_frames_event AS
SELECT
  'slice' AS track_type,
  'All Processes' AS track_name,
  ts,
  0 AS dur,
  'Dropped Frame' AS slice_name,
  'Dropped Frames' AS group_name
FROM dropped_frames_with_process_info
WHERE (SELECT COUNT(DISTINCT process_id)
       FROM dropped_frames_with_process_info) > 1
GROUP BY ts
UNION ALL
SELECT
  'slice' AS track_type,
  process_name || ' ' || process_id AS track_name,
  ts,
  0 AS dur,
  'Dropped Frame' AS slice_name,
  'Dropped Frames' AS group_name
FROM dropped_frames_with_process_info
GROUP BY process_id, ts;

-- Create the dropped frames metric output.
DROP VIEW IF EXISTS chrome_dropped_frames_output;
CREATE VIEW chrome_dropped_frames_output AS
SELECT ChromeDroppedFrames(
  'dropped_frame', (
    SELECT RepeatedField(
      ChromeDroppedFrames_DroppedFrame(
        'ts', ts,
        'process_name', process_name,
        'pid', process_id
      )
    )
    FROM dropped_frames_with_process_info
    ORDER BY ts
  )
);


text:
package com.twitter.finagle.loadbalancer

import com.twitter.app.App
import com.twitter.conversions.time._
import com.twitter.finagle._
import com.twitter.finagle.stats.{StatsReceiver, NullStatsReceiver, InMemoryStatsReceiver}
import com.twitter.finagle.util.Rng
import com.twitter.util.{Function => _, _}
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.SortedMap
import scala.language.reflectiveCalls

private[loadbalancer] trait P2CSuite {
  // number of servers
  val N: Int = 100
  // number of reqs
  val R: Int = 100000
  // tolerated variance
  val ε: Double = 0.0001*R

  class Clock extends (() => Long) {
    var time: Long = 0L
    def advance(tick: Long): Unit = { time += tick }
    def apply(): Long = time
  }

  trait P2CServiceFactory extends ServiceFactory[Unit, Int] {
    val weight: Double
    def normMeanLoad: Double
    def tup: (ServiceFactory[Unit, Int], Double) = (this, weight)
  }

  val noBrokers = new NoBrokersAvailableException

  def newBal(
    fs: Var[Traversable[P2CServiceFactory]],
    sr: StatsReceiver = NullStatsReceiver,
    clock: (() => Long) = System.nanoTime
  ) = new P2CBalancer(
    Activity(fs map { fs => Activity.Ok(fs.map(_.tup)) }),
    rng = Rng(12345L),
    statsReceiver = sr,
    emptyException = noBrokers
  ) {
    override def nanoTime(): Long = clock()
  }

  def assertEven(fs: Traversable[P2CServiceFactory]) {
    val nml = fs.head.normMeanLoad
    for (f <- fs) {
      assert(math.abs(f.normMeanLoad - nml) < ε,
        "nml=%f; f.nml=%f; ε=%f".format(nml, f.normMeanLoad, ε))
    }
  }
}

@RunWith(classOf[JUnitRunner])
class P2CBalancerTest extends FunSuite with App with P2CSuite {
  flag.parseArgs(Array("-com.twitter.finagle.loadbalancer.exp.loadMetric=leastReq"))

  case class LoadedFactory(which: Int, weight: Double) extends P2CServiceFactory {
    var available = true
    var load = 0
    var sum = 0
    var count = 0

    // This isn't quite the right notion of mean load, but it's good enough.
    def meanLoad = if (count == 0) 0.0 else sum.toDouble/count.toDouble
    def normMeanLoad = if (weight == 0) meanLoad else meanLoad/weight

    def apply(conn: ClientConnection) = {
      load += 1
      sum += load
      count += 1

      Future.value(new Service[Unit, Int] {
        def apply(req: Unit) = Future.value(which)
        override def close(deadline: Time) = {
          load -= 1
          sum += load
          count += 1
          Future.Done
        }
      })
    }

    def close(deadline: Time) = Future.Done
    override def toString = "LoadedFactory(%d)".format(load)
    override def isAvailable = available
  }

  def statsDict(r: InMemoryStatsReceiver) = new {
    private val zero = () => 0

    def size = r.gauges.getOrElse(Seq("size"), zero)()
    def adds = r.counters.getOrElse(Seq("adds"), 0)
    def removes = r.counters.getOrElse(Seq("removes"), 0)
    def load = r.gauges.getOrElse(Seq("load"), zero)()
    def available = r.gauges.getOrElse(Seq("available"), zero)()
    def meanweight = r.gauges.getOrElse(Seq("meanweight"), zero)()
  }

  test("Balances evenly when weights=i") {
    val init = Vector.tabulate(N) { i => new LoadedFactory(i, i + 1) }
    val bal = newBal(Var.value(init))
    for (_ <- 0 until R) bal()
    assertEven(init)
  }

  test("Balances evenly when weights=1") {
    val init = Vector.tabulate(N) { i => new LoadedFactory(i, 1) }
    val bal = newBal(Var.value(init))
    for (_ <- 0 until R) bal()
    assertEven(init)
  }

  test("Balances evenly when weights=0") {
    val init = Vector.tabulate(N) { i => new LoadedFactory(i, 0) }
    val bal = newBal(Var.value(init))
    for (_ <- 0 until R) bal()
    assertEven(init)
  }

  test("Balance evenly when load varies") {
    val rng = Rng(12345L)
    val init = Vector.tabulate(N) { i => LoadedFactory(i, i+1) }
    var pending = Set[Service[Unit, Int]]()
    val bal = newBal(Var.value(init))

    for (i <- 0 until R) {
      i%3 match {
        case 0 =>
          pending += Await.result(bal())
        case 1 if rng.nextInt(2) == 0 =>
          pending += Await.result(bal())
        case _ if pending.nonEmpty =>
          val hd = pending.head
          pending -= hd
          hd.close()
        case _ =>
      }
    }

    assertEven(init)
  }

  test("Dynamically incorporates updates") {
    val init = Vector.tabulate(N) { i => LoadedFactory(i, 1) }
    val vec = Var(init)
    val bal = newBal(vec)

    for (_ <- 0 until R) bal()
    assertEven(vec())

    val fN1 = LoadedFactory(N+1, 2)
    vec() :+= fN1

    for (_ <- 0 until R*2) bal()
    assertEven(vec())

    // Spot check!
    assert(math.abs(init(0).load*2 - fN1.load) < ε)

    val init0Load = init(0).load
    vec() = vec() drop 1

    for (_ <- 0 until R) bal()
    assert(init0Load === init(0).load)
  }

  test("Skip downed nodes; revive them") {
    val init = Vector.tabulate(N) { i => new LoadedFactory(i, 1) }
    val bal = newBal(Var.value(init))

    var byIndex = new mutable.HashMap[Int, mutable.Set[Closable]]
      with mutable.MultiMap[Int, Closable]

    def run(n: Int) {
      for (_ <- 0 until n) {
        val s = Await.result(bal())
        val i = Await.result(s(()))
        byIndex.addBinding(i, s)
      }
    }

    run(R)

    val init0Load = init(0).load
    init(0).available = false

    run(R)
    assert(init0Load === init(0).load)
    assertEven(init drop 1)

    Closable.all(byIndex(0).toSeq:_*).close()
    for (_ <- 0 until R) bal()
    assert(init(0).load === 0)
    assertEven(init drop 1)

    init(0).available = true

    run(R)

    // Because of 2-choices, we should see approximately
    // twice our normal load assignments in a period of R.
    // (This demonstrates nicely why and how P2C converges
    // slower than a heap-based balancer.)
    assert(math.abs(init(0).load - 2*R/N) < ε*5)
  }

  test("Handle empty vectors") {
    val vec = Var(Vector.empty[LoadedFactory])
    val bal = newBal(vec)
    val exc = intercept[NoBrokersAvailableException] { Await.result(bal()) }
    assert(exc eq noBrokers)

    vec() :+= new LoadedFactory(0, 1)
    for (_ <- 0 until R) Await.result(bal())
    assert(vec().head.load === R)

    vec() = Vector.empty
    intercept[NoBrokersAvailableException] { Await.result(bal()) }
  }

  test("Balance all-downed nodes.") {
    val init = Vector.tabulate(N) { i => new LoadedFactory(i, 1) }
    val bal = newBal(Var.value(init))

    for (_ <- 0 until R) bal()
    assertEven(init)

    val init0Load = init(0).load
    for (f <- init) f.available = false
    for (_ <- 0 until R) Await.result(bal()) // make sure we don't throw

    assertEven(init)
    val init0Load2 = init(0).load
    assert(math.abs(init0Load*2 - init0Load2) < ε)

    for (f <- init drop N/2) f.available = true
    for (_ <- 0 until R) bal()

    assert(init0Load2 === init(0).load)
    assertEven(init drop N/2)
    assertEven(init take N/2)
  }

  test("Stats") {
    val statsReceiver = new InMemoryStatsReceiver
    val vec = Var(Vector.empty[LoadedFactory])
    val bal = newBal(vec, statsReceiver)
    val stats = statsDict(statsReceiver)

    assert(stats.load === 0)
    assert(stats.size === 0)
    assert(stats.adds === 0)
    assert(stats.removes === 0)
    assert(stats.available === 0)
    assert(stats.meanweight === 0)

    vec() +:= new LoadedFactory(0, 1)

    assert(stats.load === 0)
    assert(stats.size === 1)
    assert(stats.adds === 1)
    assert(stats.removes === 0)
    assert(stats.available === 1)
    assert(stats.meanweight === 1)

    vec() +:= new LoadedFactory(1, 2)

    assert(stats.load === 0)
    assert(stats.size === 2)
    assert(stats.adds === 2)
    assert(stats.removes === 0)
    assert(stats.available === 2)
    assert(stats.meanweight === 1.5)

    vec()(0).available = false
    assert(stats.available === 1)

    val svcs = Seq.fill(R) { Await.result(bal()) }
    assert(stats.load === R)
    assert(vec()(0).load === 0)
    assert(vec()(1).load === R)
    Closable.all(svcs:_*).close()
    assert(vec()(1).load === 0)
    assert(stats.load === 0)
  }
}

@RunWith(classOf[JUnitRunner])
class P2CBalancerEwmaTest extends FunSuite with App with P2CSuite {
  override val ε: Double = 0.0005*R
  flag.parseArgs(Array("-com.twitter.finagle.loadbalancer.exp.loadMetric=ewma"))
  flag.parseArgs(Array("-com.twitter.finagle.loadbalancer.exp.decayTime=150.nanoseconds"))

  def run(fs: Traversable[P2CServiceFactory], n: Int): Unit = {
    val clock = new Clock
    val bal = newBal(Var.value(fs), clock=clock)
    @tailrec
    def go(step: Int, schedule: SortedMap[Long, Seq[Closable]]): Unit = {
      if (step != 0 && schedule.isEmpty) return
      val next = if (step >= n) schedule else {
        val svc = Await.result(bal())
        val latency = Await.result(svc()).toLong
        val work = (clock()+latency -> (schedule.getOrElse(clock()+latency, Nil) :+ svc))
        schedule + work
      }
      for (seq <- next.get(step); c <- seq) c.close()
      clock.advance(1)
      go(step+1, next-step)
    }
    go(0, SortedMap())
  }

  case class LatentFactory(which: Int, latency: Any => Int) extends P2CServiceFactory {
    val weight = 1D
    var load = 0
    var sum = 0
    def meanLoad = if (load == 0) 0.0 else sum.toDouble/load.toDouble
    def normMeanLoad = meanLoad
    def apply(conn: ClientConnection) = {
      load += 1
      sum += load
      Future.value(new Service[Unit, Int] {
        def apply(req: Unit) = Future.value(latency())
      })
    }
    def close(deadline: Time) = Future.Done
    override def toString = which.toString
    override def isAvailable = true
  }

  test("Balances evenly across identical nodes") {
    val init = Vector.tabulate(N) { i => LatentFactory(i, Function.const(5)) }
    run(init, R)
    assertEven(init)
  }

  test("Probe a node without latency history at most once") {
    val init = Vector.tabulate(N) { i => LatentFactory(i, Function.const(1)) }
    val vec = init :+ LatentFactory(N+1, Function.const(R*2))
    run(vec, R)
    assertEven(vec.init)
    assert(vec(N).load === 1)
  }

  test("Balances proportionally across nodes with varying latencies") {
    val latency = 5
    val init = Vector.tabulate(N) { i => LatentFactory(i, Function.const(latency)) }
    // This is dependent on decayTime for N+1 to receive 1/2 the the load of the rest.
    // There is probably an elegant way to normalize our load as a function of decayTime,
    // but it wasn't obvious to me. This also verifies that we are actually decaying
    // based on time when we don't receive load.
    val vec = init :+ LatentFactory(N+1, Function.const(2*latency))
    run(vec, R)
    assertEven(vec.init)
    assert((vec(0).meanLoad - 2*vec(N).meanLoad) < ε)
  }
}


text:
typedef struct spv_opcode_desc_t {
  const char* name;
  const SpvOp opcode;
  const uint32_t numCapabilities;
  const SpvCapability* capabilities;
  // operandTypes[0..numTypes-1] describe logical operands for the instruction.
  // The operand types include result id and result-type id, followed by
  // the types of arguments.
  const uint16_t numTypes;
  spv_operand_type_t operandTypes[16];  // TODO: Smaller/larger?
  const bool hasResult;  // Does the instruction have a result ID operand?
  const bool hasType;    // Does the instruction have a type ID operand?
  // A set of extensions that enable this feature. If empty then this operand
  // value is in core and its availability is subject to minVersion. The
  // assembler, binary parser, and disassembler ignore this rule, so you can
  // freely process invalid modules.
  const uint32_t numExtensions;
  const spvtools::Extension* extensions;
  // Minimal core SPIR-V version required for this feature, if without
  // extensions. ~0u means reserved for future use. ~0u and non-empty extension
  // lists means only available in extensions.
  const uint32_t minVersion;
} spv_opcode_desc_t;

typedef struct spv_operand_desc_t {
  const char* name;
  const uint32_t value;
  const uint32_t numCapabilities;
  const SpvCapability* capabilities;
  // A set of extensions that enable this feature. If empty then this operand
  // value is in core and its availability is subject to minVersion. The
  // assembler, binary parser, and disassembler ignore this rule, so you can
  // freely process invalid modules.
  const uint32_t numExtensions;
  const spvtools::Extension* extensions;
  const spv_operand_type_t operandTypes[16];  // TODO: Smaller/larger?
  // Minimal core SPIR-V version required for this feature, if without
  // extensions. ~0u means reserved for future use. ~0u and non-empty extension
  // lists means only available in extensions.
  const uint32_t minVersion;
} spv_operand_desc_t;

typedef struct spv_operand_desc_group_t {
  const spv_operand_type_t type;
  const uint32_t count;
  const spv_operand_desc_t* entries;
} spv_operand_desc_group_t;

typedef struct spv_ext_inst_desc_t {
  const char* name;
  const uint32_t ext_inst;
  const uint32_t numCapabilities;
  const SpvCapability* capabilities;
  const spv_operand_type_t operandTypes[16];  // TODO: Smaller/larger?
} spv_ext_inst_desc_t;

typedef struct spv_ext_inst_group_t {
  const spv_ext_inst_type_t type;
  const uint32_t count;
  const spv_ext_inst_desc_t* entries;
} spv_ext_inst_group_t;

typedef struct spv_opcode_table_t {
  const uint32_t count;
  const spv_opcode_desc_t* entries;
} spv_opcode_table_t;

typedef struct spv_operand_table_t {
  const uint32_t count;
  const spv_operand_desc_group_t* types;
} spv_operand_table_t;

typedef struct spv_ext_inst_table_t {
  const uint32_t count;
  const spv_ext_inst_group_t* groups;
} spv_ext_inst_table_t;

typedef const spv_opcode_desc_t* spv_opcode_desc;
typedef const spv_operand_desc_t* spv_operand_desc;
typedef const spv_ext_inst_desc_t* spv_ext_inst_desc;

typedef const spv_opcode_table_t* spv_opcode_table;
typedef const spv_operand_table_t* spv_operand_table;
typedef const spv_ext_inst_table_t* spv_ext_inst_table;

struct spv_context_t {
  const spv_target_env target_env;
  const spv_opcode_table opcode_table;
  const spv_operand_table operand_table;
  const spv_ext_inst_table ext_inst_table;
  spvtools::MessageConsumer consumer;
};

namespace spvtools {

// Sets the message consumer to |consumer| in the given |context|. The original
// message consumer will be overwritten.
void SetContextMessageConsumer(spv_context context, MessageConsumer consumer);
}  // namespace spvtools

// Populates *table with entries for env.
spv_result_t spvOpcodeTableGet(spv_opcode_table* table, spv_target_env env);

// Populates *table with entries for env.
spv_result_t spvOperandTableGet(spv_operand_table* table, spv_target_env env);

// Populates *table with entries for env.
spv_result_t spvExtInstTableGet(spv_ext_inst_table* table, spv_target_env env);

#endif  // SOURCE_TABLE_H_


text:
layout: organization
category: local

title: Marcus Garvey Nursing and Rehabilitation Center
impact_area: The Elderly
keywords:
location_services:
location_offices:
website: http://www.mgnh.com/

description:
mission:

cash_grants:
grants:
service_opp:
services:

learn:
cont_relationship:

salutation:
first_name:
last_name:
title_contact_person:

city: Brooklyn
state: NY
address: |
  810 St Marks Avenue
  Brooklyn NY 11213
lat: 40.674994
lng: -73.946041
phone: 718-467-7300
ext:
fax:
email:
preferred_contact:
contact_person_intro:
---


text:
require 'spec_helper'

describe BasePolicy, models: true do
  describe '.class_for' do
    it 'detects policy class based on the subject ancestors' do
      expect(DeclarativePolicy.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
    end

    it 'detects policy class for a presented subject' do
      presentee = Ci::BuildPresenter.new(Ci::Build.new)

      expect(DeclarativePolicy.class_for(presentee)).to eq(Ci::BuildPolicy)
    end

    it 'uses GlobalPolicy when :global is given' do
      expect(DeclarativePolicy.class_for(:global)).to eq(GlobalPolicy)
    end
  end
end


text:
package org.ossim.oms.apps;

import joms.oms.Init;
import joms.oms.ossimImageWriterFactoryRegistry;
import joms.oms.ossimStringVector;

public class ListImageFormats
{
	static
	{
		System.loadLibrary( "joms" );
	}

	/**
	 * @param args
	 */
	public static void main( String[] args )
	{
		Init.instance().initialize( args.length, args );

		ossimStringVector typeList = new ossimStringVector();

		ossimImageWriterFactoryRegistry.instance().getTypeNameList( typeList );

		for ( int i = 0; i < typeList.size(); i++ )
		{
			System.out.println( typeList.get( i ) );
		}
	}

}


text:
/*
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
//# sourceMappingURL=ITimeMeasurement.js.map


text:
using QuickFix;
using LionFire.Trading.QuickFix.ConsoleTest.Fields;
namespace LionFire.Trading.QuickFix.ConsoleTest
{
    public class BidResponse : Message
    {
        public const string MsgType = "l";

        public BidResponse():base()
        {
            this.Header.SetField(new QuickFix.Fields.MsgType(MsgType));
        }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID BidID
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID val) { this.BidID = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.BidID val) { return IsSetBidID(); }

        public bool IsSetBidID() { return IsSetField(Tags.BidID); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID ClientBidID
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID val) { this.ClientBidID = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.ClientBidID val) { return IsSetClientBidID(); }

        public bool IsSetClientBidID() { return IsSetField(Tags.ClientBidID); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents NoBidComponents
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents val) { this.NoBidComponents = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.NoBidComponents val) { return IsSetNoBidComponents(); }

        public bool IsSetNoBidComponents() { return IsSetField(Tags.NoBidComponents); }

        public class NoBidComponentsGroup : Group
        {
            public static int[] fieldOrder = {Tags.Commission, Tags.CommType, Tags.ListID, Tags.Country, Tags.Side, Tags.Price, Tags.PriceType, Tags.FairValue, Tags.NetGrossInd, Tags.SettlmntTyp, Tags.FutSettDate, Tags.TradingSessionID, Tags.Text, Tags.EncodedTextLen, Tags.EncodedText, 0};

            public NoBidComponentsGroup() : base(Tags.NoBidComponents, Tags.Commission, fieldOrder)
            {
            }

            public override Group Clone()
            {
                var clone = new NoBidComponentsGroup();
                clone.CopyStateFrom(this);
                return clone;
            }
        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission Commission
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission val) { this.Commission = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.Commission val) { return IsSetCommission(); }

        public bool IsSetCommission() { return IsSetField(Tags.Commission); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType CommType
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType val) { this.CommType = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.CommType val) { return IsSetCommType(); }

        public bool IsSetCommType() { return IsSetField(Tags.CommType); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID ListID
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID val) { this.ListID = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.ListID val) { return IsSetListID(); }

        public bool IsSetListID() { return IsSetField(Tags.ListID); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Country Country
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.Country();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.Country val) { this.Country = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Country Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.Country val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.Country val) { return IsSetCountry(); }

        public bool IsSetCountry() { return IsSetField(Tags.Country); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Side Side
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.Side();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.Side val) { this.Side = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Side Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.Side val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.Side val) { return IsSetSide(); }

        public bool IsSetSide() { return IsSetField(Tags.Side); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Price Price
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.Price();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.Price val) { this.Price = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Price Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.Price val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.Price val) { return IsSetPrice(); }

        public bool IsSetPrice() { return IsSetField(Tags.Price); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType PriceType
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType val) { this.PriceType = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.PriceType val) { return IsSetPriceType(); }

        public bool IsSetPriceType() { return IsSetField(Tags.PriceType); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue FairValue
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue val) { this.FairValue = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.FairValue val) { return IsSetFairValue(); }

        public bool IsSetFairValue() { return IsSetField(Tags.FairValue); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd NetGrossInd
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd val) { this.NetGrossInd = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.NetGrossInd val) { return IsSetNetGrossInd(); }

        public bool IsSetNetGrossInd() { return IsSetField(Tags.NetGrossInd); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp SettlmntTyp
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp val) { this.SettlmntTyp = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.SettlmntTyp val) { return IsSetSettlmntTyp(); }

        public bool IsSetSettlmntTyp() { return IsSetField(Tags.SettlmntTyp); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate FutSettDate
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate val) { this.FutSettDate = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.FutSettDate val) { return IsSetFutSettDate(); }

        public bool IsSetFutSettDate() { return IsSetField(Tags.FutSettDate); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID TradingSessionID
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID val) { this.TradingSessionID = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.TradingSessionID val) { return IsSetTradingSessionID(); }

        public bool IsSetTradingSessionID() { return IsSetField(Tags.TradingSessionID); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Text Text
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.Text();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.Text val) { this.Text = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.Text Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.Text val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.Text val) { return IsSetText(); }

        public bool IsSetText() { return IsSetField(Tags.Text); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen EncodedTextLen
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen val) { this.EncodedTextLen = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedTextLen val) { return IsSetEncodedTextLen(); }

        public bool IsSetEncodedTextLen() { return IsSetField(Tags.EncodedTextLen); }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText EncodedText
        {
            get
            {
                var val = new LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText();
                GetField(val);
                return val;
            }
            set { SetField(value); }
        }

        public void Set(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText val) { this.EncodedText = val; }

        public LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText Get(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText val)
        {
            GetField(val);
            return val;
        }

        public bool IsSet(LionFire.Trading.QuickFix.ConsoleTest.Fields.EncodedText val) { return IsSetEncodedText(); }

        public bool IsSetEncodedText() { return IsSetField(Tags.EncodedText); }

        }

    }
}


text:
from __future__ import unicode_literals
from ..featuredetection import GradientAnisotropicDiffusionImageFilter

def test_GradientAnisotropicDiffusionImageFilter_inputs():
    input_map = dict(args=dict(argstr='%s',
    ),
    conductance=dict(argstr='--conductance %f',
    ),
    environ=dict(nohash=True,
    usedefault=True,
    ),
    ignore_exception=dict(nohash=True,
    usedefault=True,
    ),
    inputVolume=dict(argstr='--inputVolume %s',
    ),
    numberOfIterations=dict(argstr='--numberOfIterations %d',
    ),
    outputVolume=dict(argstr='--outputVolume %s',
    hash_files=False,
    ),
    terminal_output=dict(deprecated='1.0.0',
    nohash=True,
    ),
    timeStep=dict(argstr='--timeStep %f',
    ),
    )
    inputs = GradientAnisotropicDiffusionImageFilter.input_spec()

    for key, metadata in list(input_map.items()):
        for metakey, value in list(metadata.items()):
            assert getattr(inputs.traits()[key], metakey) == value

def test_GradientAnisotropicDiffusionImageFilter_outputs():
    output_map = dict(outputVolume=dict(),
    )
    outputs = GradientAnisotropicDiffusionImageFilter.output_spec()

    for key, metadata in list(output_map.items()):
        for metakey, value in list(metadata.items()):
            assert getattr(outputs.traits()[key], metakey) == value