public Function getFunction(String id) { if (!Registry.containsFunction(id)) { throw new UnknownFunctionException(id); } return Registry.getFunction(id); }
public FunctionDocumentation getFunctionDocumentation(String id) { if (!Registry.containsFunctionDocumentation(id)) { throw new FunctionNotDocumentedException(id); } return Registry.getFunctionDocumentation(id); }
public static void clearAll() { clearFunctionDocumentation(); clearFunctions(); clearWorkAreas(); }
private void init() { DocumentationConfig documentationConfig = new DocumentationConfig(documentationXmlReader.getDataDictionary()); for (FunctionConfig functionConfig : this.geoclientXmlReader.getFunctions()) { log.info("Creating function from {}", functionConfig); Function function = functionConfig.createFunction(geoclient); Registry.addFunction(function); Registry.addFunctionDocumentation(documentationConfig.document(documentationXmlReader.getFunctionDocumentation(function.getId()) , function)); } }
@Test public void testOneWorkAreaConstructor() { assertSame(this.wa1Config, this.oneWorkAreaFunction.getWorkAreaOneConfig()); assertNull(this.oneWorkAreaFunction.getWorkAreaTwoConfig()); assertNull(this.oneWorkAreaFunction.getConfiguration()); assertFalse(this.oneWorkAreaFunction.isTwoWorkAreaFunction()); assertFalse(this.oneWorkAreaFunction.hasDefaultArguments()); }
public WorkArea createWorkArea() { if(Registry.containsWorkArea(this.id)) { return Registry.getWorkArea(this.id); } SortedSet<Field> uniqueSet = new TreeSet<Field>(); validate(this.fields, uniqueSet); List<Filter> oFilters = this.outputFilters != null ? this.outputFilters : Collections.<Filter>emptyList(); WorkArea workArea = new WorkArea(this.id, uniqueSet, oFilters); validate(workArea); Registry.addWorkArea(workArea); return workArea; }
@Test public void testCreateWorkArea() { Registry.clearWorkAreas(); WorkArea workArea = this.workAreaConfig.createWorkArea(); assertTrue(Registry.containsWorkArea(workArea.getId())); assertTrue(this.length==workArea.length()); assertTrue(workArea.isFiltered(TestData.fieldOne)); }
@Test(expected=InvalidWorkAreaLengthException.class) public void testCreateWorkArea_invalidLength() { Registry.clearWorkAreas(); new WorkAreaConfig(this.id, 13, this.isWorkAreaOne,this.fields,this.outputFilters).createWorkArea(); }
@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()); }
@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 public void testItemDocumentationDisplayNameSetProperly() { assertItemDocumentationDisplayNames(geosupportConfig.getFunctionDocumentation(Function.F1B), Arrays.asList("listOfSecondSetOf5Lgcs")); assertItemDocumentationDisplayNames(geosupportConfig.getFunctionDocumentation(Function.F2), Arrays.asList("dcpPreferredLgcForStreet1")); }
private Function getFunction(String functionName) { return this.geosupportConfiguration.getFunction(functionName); }
public FunctionDocumentation document(FunctionDocumentation functionDocumentation, Function function) { addItemDocumentation(functionDocumentation, getFieldIds(function.getWorkAreaOne())); if(function.isTwoWorkAreas()) { addItemDocumentation(functionDocumentation, getFieldIds(function.getWorkAreaTwo())); } return functionDocumentation; }
private void validate(WorkArea workArea) { if (workArea.length() != this.length) { InvalidWorkAreaLengthException e = new InvalidWorkAreaLengthException(workArea, this.length); log.error(e.getMessage()); throw e; } }
@Before public void setUp() throws Exception { this.id = "WA1"; this.length = 12; this.isWorkAreaOne = true; this.fields = TestData.newFieldList(TestData.fieldOne, TestData.fieldTwo); this.outputFilters = new ArrayList<Filter>(); this.outputFilters.add(new Filter(TestData.fieldOne.getId())); this.workAreaConfig = new WorkAreaConfig(this.id, this.length, this.isWorkAreaOne, this.fields, this.outputFilters); }
@BeforeClass public static void setUpBeforeClass() throws Exception { geosupportConfig = new GeosupportConfig(new GeoclientImpl()); }
@Test public void testTwoWorkAreaConstructor() { assertSame(this.wa1Config, this.twoWorkAreaFunction.getWorkAreaOneConfig()); assertSame(this.wa2Config, this.twoWorkAreaFunction.getWorkAreaTwoConfig()); assertNull(this.oneWorkAreaFunction.getConfiguration()); assertTrue(this.twoWorkAreaFunction.isTwoWorkAreaFunction()); assertFalse(this.twoWorkAreaFunction.hasDefaultArguments()); }
@Test(expected=UnknownFunctionException.class) public void nonExistentFunction() { geosupportConfig.getFunction("fun"); }
@Test public void testTwoWorkAreaArgumentsConstructor() { assertSame(this.wa1Config, this.twoWorkAreaDefaultArgsFunction.getWorkAreaOneConfig()); assertSame(this.wa2Config, this.twoWorkAreaDefaultArgsFunction.getWorkAreaTwoConfig()); assertSame(this.configuration, this.twoWorkAreaDefaultArgsFunction.getConfiguration()); assertTrue(this.twoWorkAreaDefaultArgsFunction.isTwoWorkAreaFunction()); assertTrue(this.twoWorkAreaDefaultArgsFunction.hasDefaultArguments()); }