@Before public void setUp() throws Exception { this.wa1Config = new WorkAreaConfig("WW1", 12, true, TestData.newFieldList(TestData.fieldOne, TestData.fieldTwo), Collections.<Filter>emptyList()); this.wa2Config = new WorkAreaConfig("WW2_F1B", 4, false, TestData.newFieldList(TestData.makeField("pqr", 1, 4)), Collections.<Filter>emptyList()); this.configuration = new DefaultConfiguration(); // Don't use the names of real functions. Previously, using function "1B" // was causing the real 1B in GeosupportConfigIntegration test to fail // when all tests were run from Maven; basically, the 1B that was // returned by the integration test was the mock one created in // FunctionConfigTest. Issue did not occur within Eclipse or when // test was run individually. this.oneWorkAreaFunction = new FunctionConfig("EG", this.wa1Config, null); this.twoWorkAreaFunction = new FunctionConfig("9B", this.wa1Config, this.wa2Config); this.twoWorkAreaDefaultArgsFunction = new FunctionConfig("12", this.wa1Config, this.wa2Config, this.configuration); }
@Test//(expected=DuplicateFieldNameException.class) public void testCreateTwoWorkAreaFunction_duplicateFields() { WorkAreaConfig duplicateFieldWa2 = new WorkAreaConfig("DUP", TestData.fieldDuplicateIdOfOne.getLength(), true, TestData.newFieldList(TestData.fieldDuplicateIdOfOne),Collections.<Filter>emptyList()); FunctionConfig badFun = new FunctionConfig("DUP", this.wa1Config, duplicateFieldWa2); badFun.createFunction(new GeoclientStub()); }
@Test public void testCreateNewDefaultConfigurationEvenIfFieldIsNull() { FunctionConfig functionConfig = new FunctionConfig("XX", this.wa1Config, this.wa2Config); Function function = functionConfig.createFunction(new GeoclientStub()); assertNotNull(function.getConfiguration()); }
@Test public void testCreateUsesGivenDefaultConfiguration() { DefaultConfiguration config = new DefaultConfiguration(); FunctionConfig functionConfig = new FunctionConfig("XX", this.wa1Config, this.wa2Config,config); Function function = functionConfig.createFunction(new GeoclientStub()); assertSame(config, function.getConfiguration()); }