Skip to content

Commit

Permalink
[ONECTA] Rerun Spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Drent <[email protected]>
Signed-off-by: Alexander Drent <[email protected]>
  • Loading branch information
adr001db committed May 9, 2024
1 parent 13f75f2 commit 7561f45
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 104 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
package org.openhab.binding.onecta.internal.api;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.mockito.Mockito.*;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.onecta.internal.api.dto.commands.CommandFloat;
import org.openhab.binding.onecta.internal.api.dto.commands.CommandString;
import org.openhab.binding.onecta.internal.exception.DaikinCommunicationException;

public class OnectaPropertiesTest {

final String UNITID = "1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6";
final Enums.ManagementPoint MANAGEMENTPOINTTYPE = Enums.ManagementPoint.CLIMATECONTROL;

@Test
public void startScanTest() {
public void startScanTest() {

assertEquals(
"https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6",
Expand All @@ -40,82 +33,55 @@ public void startScanTest() {
"https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6/management-points/climateControl/characteristics/targetTemperature",
OnectaProperties.getTargetTemperaturUrl(UNITID, MANAGEMENTPOINTTYPE.getValue()));

assertEquals(
20f,
OnectaProperties.getTargetTemperaturCommand(20f).value);
assertEquals(
null,
OnectaProperties.getTargetTemperaturCommand(20f).path);
assertEquals(20f, OnectaProperties.getTargetTemperaturCommand(20f).value);
assertEquals(null, OnectaProperties.getTargetTemperaturCommand(20f).path);

assertEquals(
"dry",
OnectaProperties.getOperationModeCommand(Enums.OperationMode.DEHUMIDIFIER).value);
assertEquals(
null,
OnectaProperties.getOperationModeCommand(Enums.OperationMode.DEHUMIDIFIER).path);
assertEquals("dry", OnectaProperties.getOperationModeCommand(Enums.OperationMode.DEHUMIDIFIER).value);
assertEquals(null, OnectaProperties.getOperationModeCommand(Enums.OperationMode.DEHUMIDIFIER).path);

assertEquals(
"https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6/management-points/climateControl/characteristics/temperatureControl",
OnectaProperties.getTemperatureControlUrl(UNITID, MANAGEMENTPOINTTYPE.getValue()));

assertEquals(
20f,
OnectaProperties.getTemperatureRoomControlCommand(20f,Enums.OperationMode.COLD).value);
assertEquals(
"/operationModes/cooling/setpoints/roomTemperature",
OnectaProperties.getTemperatureRoomControlCommand(20f,Enums.OperationMode.COLD).path);
assertEquals(20f, OnectaProperties.getTemperatureRoomControlCommand(20f, Enums.OperationMode.COLD).value);
assertEquals("/operationModes/cooling/setpoints/roomTemperature",
OnectaProperties.getTemperatureRoomControlCommand(20f, Enums.OperationMode.COLD).path);

assertEquals(
20f,
OnectaProperties.getSetpointLeavingWaterOffsetCommand(20f,Enums.OperationMode.COLD).value);
assertEquals(
"/operationModes/cooling/setpoints/leavingWaterOffset",
OnectaProperties.getSetpointLeavingWaterOffsetCommand(20f,Enums.OperationMode.COLD).path);
assertEquals(20f, OnectaProperties.getSetpointLeavingWaterOffsetCommand(20f, Enums.OperationMode.COLD).value);
assertEquals("/operationModes/cooling/setpoints/leavingWaterOffset",
OnectaProperties.getSetpointLeavingWaterOffsetCommand(20f, Enums.OperationMode.COLD).path);

assertEquals(
20f,
OnectaProperties.getSetpointLeavingWaterTemperatureCommand(20f,Enums.OperationMode.HEAT).value);
assertEquals(
"/operationModes/heating/setpoints/leavingWaterTemperature",
OnectaProperties.getSetpointLeavingWaterTemperatureCommand(20f,Enums.OperationMode.HEAT).path);
assertEquals(20f,
OnectaProperties.getSetpointLeavingWaterTemperatureCommand(20f, Enums.OperationMode.HEAT).value);
assertEquals("/operationModes/heating/setpoints/leavingWaterTemperature",
OnectaProperties.getSetpointLeavingWaterTemperatureCommand(20f, Enums.OperationMode.HEAT).path);

assertEquals(
20f,
OnectaProperties.getTemperatureHotWaterControlCommand(20f,Enums.OperationMode.AUTO).value);
assertEquals(
"/operationModes/auto/setpoints/domesticHotWaterTemperature",
OnectaProperties.getTemperatureHotWaterControlCommand(20f,Enums.OperationMode.AUTO).path);
assertEquals(20f, OnectaProperties.getTemperatureHotWaterControlCommand(20f, Enums.OperationMode.AUTO).value);
assertEquals("/operationModes/auto/setpoints/domesticHotWaterTemperature",
OnectaProperties.getTemperatureHotWaterControlCommand(20f, Enums.OperationMode.AUTO).path);

assertEquals(
"https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6/management-points/climateControl/characteristics/fanControl",
OnectaProperties.getTFanControlUrl(UNITID, MANAGEMENTPOINTTYPE.getValue()));

assertEquals(
"fixed",
assertEquals("fixed",
OnectaProperties.getTFanSpeedCurrentCommand(Enums.OperationMode.FAN, Enums.FanSpeed.LEVEL_1).value);
assertEquals(
"/operationModes/fanOnly/fanSpeed/currentMode",
assertEquals("/operationModes/fanOnly/fanSpeed/currentMode",
OnectaProperties.getTFanSpeedCurrentCommand(Enums.OperationMode.FAN, Enums.FanSpeed.LEVEL_1).path);

assertEquals(
1,
assertEquals(1,
OnectaProperties.getTFanSpeedFixedCommand(Enums.OperationMode.FAN, Enums.FanSpeed.LEVEL_1).value);
assertEquals(
"/operationModes/fanOnly/fanSpeed/modes/fixed",
assertEquals("/operationModes/fanOnly/fanSpeed/modes/fixed",
OnectaProperties.getTFanSpeedFixedCommand(Enums.OperationMode.FAN, Enums.FanSpeed.LEVEL_1).path);

assertEquals(
"stop",
OnectaProperties.getTFanDirectionHorCommand(Enums.OperationMode.FAN, Enums.FanMovementHor.STOPPED).value);
assertEquals(
"/operationModes/fanOnly/fanDirection/horizontal/currentMode",
OnectaProperties.getTFanDirectionHorCommand(Enums.OperationMode.FAN, Enums.FanMovementHor.STOPPED).path);
assertEquals("stop", OnectaProperties.getTFanDirectionHorCommand(Enums.OperationMode.FAN,
Enums.FanMovementHor.STOPPED).value);
assertEquals("/operationModes/fanOnly/fanDirection/horizontal/currentMode", OnectaProperties
.getTFanDirectionHorCommand(Enums.OperationMode.FAN, Enums.FanMovementHor.STOPPED).path);

assertEquals(
"swing",
assertEquals("swing",
OnectaProperties.getTFanDirectionVerCommand(Enums.OperationMode.FAN, Enums.FanMovementVer.SWING).value);
assertEquals(
"/operationModes/fanOnly/fanDirection/vertical/currentMode",
assertEquals("/operationModes/fanOnly/fanDirection/vertical/currentMode",
OnectaProperties.getTFanDirectionVerCommand(Enums.OperationMode.FAN, Enums.FanMovementVer.SWING).path);

assertEquals(
Expand All @@ -130,18 +96,10 @@ public void startScanTest() {
"https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices/1ce8c13f-5271-4343-ac9f-a1b2c3d4e5f6/management-points/climateControl/characteristics/demandControl",
OnectaProperties.getTDemandControlUrl(UNITID, MANAGEMENTPOINTTYPE.getValue()));

assertEquals(
"scheduled",
OnectaProperties.getTDemandControlCommand(Enums.DemandControl.SCHEDULED).value);
assertEquals(
"/currentMode",
OnectaProperties.getTDemandControlCommand(Enums.DemandControl.SCHEDULED).path);
assertEquals("scheduled", OnectaProperties.getTDemandControlCommand(Enums.DemandControl.SCHEDULED).value);
assertEquals("/currentMode", OnectaProperties.getTDemandControlCommand(Enums.DemandControl.SCHEDULED).path);

assertEquals(
12,
OnectaProperties.getTDemandControlFixedValueCommand(12).value);
assertEquals(
"/modes/fixed",
OnectaProperties.getTDemandControlFixedValueCommand(12).path);
assertEquals(12, OnectaProperties.getTDemandControlFixedValueCommand(12).value);
assertEquals("/modes/fixed", OnectaProperties.getTDemandControlFixedValueCommand(12).path);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.openhab.binding.onecta.internal.api.dto;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.onecta.internal.api.Enums;
import org.openhab.binding.onecta.internal.api.dto.commands.*;
import org.openhab.binding.onecta.internal.exception.DaikinCommunicationException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class CommandsTest {

Expand All @@ -22,40 +23,23 @@ public void setUp() {
@Test
public void startScanTest() throws DaikinCommunicationException, JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
assertEquals(
"{\"value\":25.5,\"path\":null}",
mapper.writeValueAsString(new CommandFloat(25.5f)));
assertEquals(
"{\"value\":25.5,\"path\":\"Sample context\"}",
assertEquals("{\"value\":25.5,\"path\":null}", mapper.writeValueAsString(new CommandFloat(25.5f)));
assertEquals("{\"value\":25.5,\"path\":\"Sample context\"}",
mapper.writeValueAsString(new CommandFloat(25.5f, "Sample context")));

assertEquals(
"{\"value\":25,\"path\":null}",
mapper.writeValueAsString(new CommandInteger(25)));
assertEquals(
"{\"value\":25,\"path\":\"Sample context\"}",
assertEquals("{\"value\":25,\"path\":null}", mapper.writeValueAsString(new CommandInteger(25)));
assertEquals("{\"value\":25,\"path\":\"Sample context\"}",
mapper.writeValueAsString(new CommandInteger(25, "Sample context")));

assertEquals(
"{\"value\":\"test\",\"path\":null}",
mapper.writeValueAsString(new CommandString("test")));
assertEquals(
"{\"value\":\"test\",\"path\":\"Sample context\"}",
assertEquals("{\"value\":\"test\",\"path\":null}", mapper.writeValueAsString(new CommandString("test")));
assertEquals("{\"value\":\"test\",\"path\":\"Sample context\"}",
mapper.writeValueAsString(new CommandString("test", "Sample context")));

assertEquals(
"{\"value\":\"off\",\"path\":null}",
mapper.writeValueAsString(new CommandOnOf(Enums.OnOff.OFF)));
assertEquals(
"{\"value\":\"on\",\"path\":\"Sample context\"}",
assertEquals("{\"value\":\"off\",\"path\":null}", mapper.writeValueAsString(new CommandOnOf(Enums.OnOff.OFF)));
assertEquals("{\"value\":\"on\",\"path\":\"Sample context\"}",
mapper.writeValueAsString(new CommandOnOf(Enums.OnOff.ON, "Sample context")));

assertEquals(
"{\"value\":false}",
mapper.writeValueAsString(new CommandTrueFalse(Enums.OnOff.OFF)));
assertEquals(
"{\"value\":true}",
mapper.writeValueAsString(new CommandTrueFalse(Enums.OnOff.ON)));

assertEquals("{\"value\":false}", mapper.writeValueAsString(new CommandTrueFalse(Enums.OnOff.OFF)));
assertEquals("{\"value\":true}", mapper.writeValueAsString(new CommandTrueFalse(Enums.OnOff.ON)));
}
}

0 comments on commit 7561f45

Please sign in to comment.