Skip to content

Commit

Permalink
Merge pull request #177 from enbohm/fix_build_props
Browse files Browse the repository at this point in the history
Updating build prop and fixing classes
  • Loading branch information
enbohm committed May 6, 2024
2 parents 056d4fd + 687e8e1 commit 535cb2b
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 46 deletions.
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/se/enbohms/halo/HaloMain.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/se/enbohms/halo/HaloScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import se.enbohms.halo.service.HaloService;
import se.enbohms.halo.service.TimeService;

@ApplicationScoped
public class HaloScheduler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package se.enbohms.halo.restclients;
package se.enbohms.halo.restclient;

import io.quarkus.runtime.annotations.RegisterForReflection;
import se.enbohms.halo.PrivateVisibilityStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package se.enbohms.halo.restclients;
package se.enbohms.halo.restclient;

import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package se.enbohms.halo.restclients;
package se.enbohms.halo.restclient;

import io.quarkus.runtime.annotations.RegisterForReflection;
import se.enbohms.halo.PrivateVisibilityStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package se.enbohms.halo.restclients;
package se.enbohms.halo.restclient;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package se.enbohms.halo;
package se.enbohms.halo.service;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.jboss.logging.Logger;
import se.enbohms.halo.restclients.HaloLoginPayload;
import se.enbohms.halo.restclients.HaloRestClient;
import se.enbohms.halo.restclients.HaloSettingsPayload;
import se.enbohms.halo.restclient.HaloLoginPayload;
import se.enbohms.halo.restclient.HaloRestClient;
import se.enbohms.halo.restclient.HaloSettingsPayload;

@ApplicationScoped
public class HaloService {
Expand All @@ -36,25 +35,25 @@ public void init() {

public void turnLightOn() {
var payload = new HaloSettingsPayload(wallboxId, "Medium", "false");
sendPutRequest(getAuthToken(), payload);
sendPutRequest(getToken(), payload);
LOG.info("TURNING ON LED");
}

public void turnLightOff() {
var payload = new HaloSettingsPayload(wallboxId, "OFF", "false");
sendPutRequest(getAuthToken(), payload);
sendPutRequest(getToken(), payload);
LOG.info("TURNING OFF LED");
}

private void sendPutRequest(HaloAuthResponse authResponse, HaloSettingsPayload payload) {
private void sendPutRequest(HaloTokenResponse tokenResponse, HaloSettingsPayload payload) {
var putResponse = haloRestClient
.changeSettings("Bearer " + authResponse.token(), wallboxId, payload);
.changeSettings("Bearer " + tokenResponse.token(), wallboxId, payload);
LOG.info("PUT status code " + putResponse.getStatus());
LOG.info("PUT response body " + putResponse.readEntity(String.class));
}

private HaloAuthResponse getAuthToken() {
private HaloTokenResponse getToken() {
var response = haloRestClient.getAuthToken(apiKey, new HaloLoginPayload(userName, pwd));
return response.readEntity(HaloAuthResponse.class);
return response.readEntity(HaloTokenResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package se.enbohms.halo;
package se.enbohms.halo.service;


import io.quarkus.runtime.annotations.RegisterForReflection;

import jakarta.json.bind.annotation.JsonbCreator;
import jakarta.json.bind.annotation.JsonbVisibility;
import se.enbohms.halo.PrivateVisibilityStrategy;

@RegisterForReflection
@JsonbVisibility(value = PrivateVisibilityStrategy.class)
public record HaloAuthResponse(String token) {
public record HaloTokenResponse(String token) {
@JsonbCreator
public HaloAuthResponse {
public HaloTokenResponse {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package se.enbohms.halo;
package se.enbohms.halo.service;

import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
Expand All @@ -13,7 +12,7 @@

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.jboss.logging.Logger;
import se.enbohms.halo.restclients.SunsetTimeClient;
import se.enbohms.halo.restclient.SunsetTimeClient;

@ApplicationScoped
public class TimeService {
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
quarkus.package.type=uber-jar
quarkus.http.port=8081
quarkus.native.native-image-xmx=6G

quarkus.container-image.group=enbohm
quarkus.container-image.name=halo-wallbox-scheduler
quarkus.container-image.tag=latest
quarkus.native.additional-build-args=--report-unsupported-elements-at-runtime

halo.apikey=ADD_A_KEY
halo.username=andreas@enbohms.se
halo.pwd=ADD_A_PWD
Expand Down
1 change: 1 addition & 0 deletions src/test/java/se/enbohms/halo/TimeServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import se.enbohms.halo.service.TimeService;

@QuarkusTest
@QuarkusTestResource(WiremockTimeServiceEndpoint.class)
Expand Down

0 comments on commit 535cb2b

Please sign in to comment.