1717
1818import static org .hamcrest .CoreMatchers .*;
1919import static org .junit .Assert .assertThat ;
20+ import static org .mockito .Mockito .when ;
2021
2122import org .junit .Ignore ;
2223import org .junit .Test ;
2324import org .junit .runner .RunWith ;
2425import org .mockito .Mock ;
26+ import org .mockito .invocation .InvocationOnMock ;
2527import org .mockito .junit .MockitoJUnitRunner ;
28+ import org .mockito .stubbing .Answer ;
2629import org .openhab .core .items .GenericItem ;
2730import org .openhab .core .items .GroupFunction ;
31+ import org .openhab .core .items .Item ;
2832import org .openhab .core .items .ItemBuilderFactory ;
2933import org .openhab .core .items .TestNumberItem ;
3034import org .openhab .core .library .types .StringType ;
35+ import org .openhab .core .types .State ;
3136
3237/**
3338 * @author Stefan Triller - Initial contribution
@@ -38,6 +43,9 @@ public class ItemDTOMapperTest {
3843 @ Mock
3944 private ItemBuilderFactory factory ;
4045
46+ @ Mock
47+ private GroupFunction function ;
48+
4149 @ Test
4250 public void testMapFunctionWithNumberItemAndCountFunction () {
4351 // testing Group:Number:Count(".*hello.*")
@@ -47,6 +55,9 @@ public void testMapFunctionWithNumberItemAndCountFunction() {
4755 gFuncDTO .name = "COUNT" ;
4856 gFuncDTO .params = new String [] { ".*hello.*" };
4957
58+ when (factory .newFunctionBuilder (item1 , gFuncDTO )).thenReturn (function );
59+ when (function .getParameters ()).thenReturn (new State [] {new StringType ()});
60+
5061 // FIXME This gonna fail
5162 GroupFunction gFunc = ItemDTOMapper .mapFunction (item1 , gFuncDTO , factory );
5263
0 commit comments