GeosupportFunction implements Function { @Override public Map<String, Object> call(Map<String, Object> parameters) { if (isTwoWorkAreas()) { return doTwoWorkAreaCall(parameters); } return doOneWorkAreaCall(parameters); } GeosupportFunction(String id, WorkArea workAreaOne, WorkArea workAreaTwo, Geoclient geoclient, Configuration configuration);  GeosupportFunction(String id, WorkArea workAreaOne, WorkArea workAreaTwo, Geoclient geoclient);  GeosupportFunction(String id, WorkArea workAreaOne, Geoclient geoclient); @Override Map<String, Object> call(Map<String, Object> parameters); String getId(); WorkArea getWorkAreaOne(); WorkArea getWorkAreaTwo(); @Override String toString(); boolean isTwoWorkAreas(); Configuration getConfiguration();  }
@Test public void testCall_twoWorkAreas() { Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> result1 = new HashMap<String, Object>(); result1.put("one", "1"); Map<String, Object> result2 = new HashMap<String, Object>(); result2.put("two", "2"); ByteBuffer buffer1 = ByteBuffer.allocate(2); ByteBuffer buffer2 = ByteBuffer.allocate(2); Mockito.when(this.workAreaOneMock.createBuffer(params)).thenReturn(buffer1); Mockito.when(this.workAreaTwoMock.createBuffer()).thenReturn(buffer2); Mockito.when(this.workAreaOneMock.parseResults(buffer1)).thenReturn(result1); Mockito.when(this.workAreaTwoMock.parseResults(buffer2)).thenReturn(result2); this.geoclientMock.callgeo(buffer1, buffer2); Map<String, Object> actualResult = this.function_twoWorkAreas.call(params); assertEquals("1", actualResult.get("one")); assertEquals("2", actualResult.get("two")); }
@Test public void testCall_oneWorkArea() { Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> result1 = new HashMap<String, Object>(); result1.put("one", "1"); ByteBuffer buffer1 = ByteBuffer.allocate(2); Mockito.when(this.workAreaOneMock.createBuffer(params)).thenReturn(buffer1); Mockito.when(this.workAreaOneMock.parseResults(buffer1)).thenReturn(result1); this.geoclientMock.callgeo(buffer1, null); Map<String, Object> actualResult = this.function_oneWorkArea.call(params); assertEquals("1", actualResult.get("one")); }