]> git.basschouten.com Git - openhab-addons.git/blob
da6443613e5c086cc7f2c511e7b38d83c142c6a3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mielecloud.internal.config.servlet;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.mielecloud.internal.util.AbstractConfigFlowTest;
20 import org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants;
21 import org.openhab.binding.mielecloud.internal.util.Website;
22
23 /**
24  * @author Björn Lange - Initial Contribution
25  */
26 @NonNullByDefault
27 public class PairAccountServletTest extends AbstractConfigFlowTest {
28     private static final String CLIENT_ID_INPUT_NAME = "clientId";
29     private static final String CLIENT_SECRET_INPUT_NAME = "clientSecret";
30
31     @Test
32     public void whenPairAccountIsInvokedWithClientIdParameterThenTheParameterIsPlacedInTheInputBox() throws Exception {
33         // when:
34         Website pairAccountSite = getCrawler()
35                 .doGetRelative("/mielecloud/pair?" + PairAccountServlet.CLIENT_ID_PARAMETER_NAME + "="
36                         + MieleCloudBindingIntegrationTestConstants.CLIENT_ID);
37
38         // then:
39         assertEquals(MieleCloudBindingIntegrationTestConstants.CLIENT_ID,
40                 pairAccountSite.getValueOfInput(CLIENT_ID_INPUT_NAME));
41         assertEquals("", pairAccountSite.getValueOfInput(CLIENT_SECRET_INPUT_NAME));
42     }
43
44     @Test
45     public void whenPairAccountIsInvokedWithClientSecretParameterThenTheParameterIsPlacedInTheInputBox()
46             throws Exception {
47         // when:
48         Website pairAccountSite = getCrawler()
49                 .doGetRelative("/mielecloud/pair?" + PairAccountServlet.CLIENT_SECRET_PARAMETER_NAME + "="
50                         + MieleCloudBindingIntegrationTestConstants.CLIENT_SECRET);
51
52         // then:
53         assertEquals("", pairAccountSite.getValueOfInput(CLIENT_ID_INPUT_NAME));
54         assertEquals(MieleCloudBindingIntegrationTestConstants.CLIENT_SECRET,
55                 pairAccountSite.getValueOfInput(CLIENT_SECRET_INPUT_NAME));
56     }
57 }