1414
1515import static com .github .tomakehurst .wiremock .client .WireMock .*;
1616import static org .awaitility .Awaitility .await ;
17- import static org .mockito .ArgumentMatchers .eq ;
1817import static org .mockito .Mockito .when ;
1918
2019import java .io .IOException ;
2120import java .nio .charset .StandardCharsets ;
21+ import java .util .Map ;
2222
2323import org .eclipse .jetty .client .HttpClient ;
2424import org .junit .jupiter .api .AfterEach ;
2727import org .junit .jupiter .api .extension .ExtendWith ;
2828import org .mockito .Mock ;
2929import org .mockito .junit .jupiter .MockitoExtension ;
30- import org .openhab .binding .sensibo .internal .config .SensiboAccountConfiguration ;
3130import org .openhab .core .config .core .Configuration ;
3231import org .openhab .core .thing .Bridge ;
3332import org .openhab .core .thing .ThingUID ;
@@ -46,7 +45,7 @@ public class SensiboAccountHandlerTest {
4645 private HttpClient httpClient ;
4746
4847 private @ Mock Configuration configuration ;
49- private @ Mock Bridge sensiboAccountMock ;
48+ private @ Mock Bridge bridgeMock ;
5049
5150 @ BeforeEach
5251 public void setUp () throws Exception {
@@ -89,10 +88,6 @@ public void testInitialize_Issue18018_Partial_Setup() throws IOException {
8988 }
9089
9190 private void testInitialize (String podsResponse , int numExpectedPods ) throws IOException {
92- // Setup account
93- final SensiboAccountConfiguration accountConfig = new SensiboAccountConfiguration ();
94- accountConfig .apiKey = "APIKEY" ;
95- when (configuration .as (eq (SensiboAccountConfiguration .class ))).thenReturn (accountConfig );
9691
9792 // Setup initial response
9893 final String getPodsResponse = new String (getClass ().getResourceAsStream (podsResponse ).readAllBytes (),
@@ -101,10 +96,12 @@ private void testInitialize(String podsResponse, int numExpectedPods) throws IOE
10196 .withHeader ("Accept-Encoding" , equalTo ("gzip" ))
10297 .willReturn (aResponse ().withStatus (200 ).withBody (getPodsResponse )));
10398
104- when (sensiboAccountMock .getConfiguration ()).thenReturn (configuration );
105- when (sensiboAccountMock .getUID ()).thenReturn (new ThingUID ("sensibo:account:thinguid" ));
99+ // Setup account
100+ when (configuration .getProperties ()).thenReturn (Map .of ("apiKey" , "APIKEY" ));
101+ when (bridgeMock .getConfiguration ()).thenReturn (configuration );
102+ when (bridgeMock .getUID ()).thenReturn (new ThingUID ("sensibo:account:thinguid" ));
106103
107- final SensiboAccountHandler handler = new SensiboAccountHandler (sensiboAccountMock , httpClient );
104+ final SensiboAccountHandler handler = new SensiboAccountHandler (bridgeMock , httpClient );
108105 handler .initialize ();
109106
110107 // Async, poll for status
0 commit comments