renamed HomeboxEntity to HomeboxConnectionEntity
This commit is contained in:
+3
-3
@@ -11,15 +11,15 @@ import lombok.Setter;
|
|||||||
@DiscriminatorValue("HOMEBOX")
|
@DiscriminatorValue("HOMEBOX")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class HomeboxEntity extends ConnectionEntity {
|
public class HomeboxConnectionEntity extends ConnectionEntity {
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
private String attachmentToken;
|
private String attachmentToken;
|
||||||
private Instant expiresAt;
|
private Instant expiresAt;
|
||||||
|
|
||||||
public static HomeboxEntity from(ConnectionRequest request, ConnectionResponse response) {
|
public static HomeboxConnectionEntity from(ConnectionRequest request, ConnectionResponse response) {
|
||||||
|
|
||||||
HomeboxEntity he = new HomeboxEntity();
|
HomeboxConnectionEntity he = new HomeboxConnectionEntity();
|
||||||
|
|
||||||
he.setAppUrl(request.appUrl());
|
he.setAppUrl(request.appUrl());
|
||||||
he.setUsername(request.username());
|
he.setUsername(request.username());
|
||||||
@@ -82,13 +82,13 @@ public class HomeboxConnectionProvider implements ConnectionProvider {
|
|||||||
@Override
|
@Override
|
||||||
public ConnectionEntity connectionToEntity(ConnectionRequest request,
|
public ConnectionEntity connectionToEntity(ConnectionRequest request,
|
||||||
ConnectionResponse response) {
|
ConnectionResponse response) {
|
||||||
return HomeboxEntity.from(request, response);
|
return HomeboxConnectionEntity.from(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateToRepository(ConnectionEntity existing, ConnectionResponse response) {
|
public void updateToRepository(ConnectionEntity existing, ConnectionResponse response) {
|
||||||
|
|
||||||
if (existing instanceof HomeboxEntity hbE) {
|
if (existing instanceof HomeboxConnectionEntity hbE) {
|
||||||
|
|
||||||
hbE.setToken(response.token());
|
hbE.setToken(response.token());
|
||||||
hbE.setExpiresAt(response.expiresAt());
|
hbE.setExpiresAt(response.expiresAt());
|
||||||
@@ -100,7 +100,7 @@ public class HomeboxConnectionProvider implements ConnectionProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instant getTokenExpiry(ConnectionEntity entity) {
|
public Instant getTokenExpiry(ConnectionEntity entity) {
|
||||||
return (entity instanceof HomeboxEntity he) ? he.getExpiresAt() : null;
|
return (entity instanceof HomeboxConnectionEntity he) ? he.getExpiresAt() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private record HomeboxLoginResponse(String token, String attachmentToken, Instant expiresAt) {
|
private record HomeboxLoginResponse(String token, String attachmentToken, Instant expiresAt) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springframework.web.client.RestClient;
|
|||||||
|
|
||||||
import com.vaessl.app.connection.ConnectionEntity;
|
import com.vaessl.app.connection.ConnectionEntity;
|
||||||
import com.vaessl.app.connection.ConnectionRepository;
|
import com.vaessl.app.connection.ConnectionRepository;
|
||||||
import com.vaessl.app.connection.HomeboxEntity;
|
import com.vaessl.app.connection.HomeboxConnectionEntity;
|
||||||
import com.vaessl.app.exception.ConnectionNotFoundException;
|
import com.vaessl.app.exception.ConnectionNotFoundException;
|
||||||
import com.vaessl.app.exception.RemoteApiException;
|
import com.vaessl.app.exception.RemoteApiException;
|
||||||
import com.vaessl.app.shared.ServiceItem;
|
import com.vaessl.app.shared.ServiceItem;
|
||||||
@@ -43,7 +43,7 @@ public class HomeboxSearchProvider implements SearchProvider {
|
|||||||
ConnectionEntity entity =
|
ConnectionEntity entity =
|
||||||
cRepository.findByAppUrlAndUsername(request.appUrl(), request.username());
|
cRepository.findByAppUrlAndUsername(request.appUrl(), request.username());
|
||||||
|
|
||||||
if (!(entity instanceof HomeboxEntity hbEntity)) {
|
if (!(entity instanceof HomeboxConnectionEntity hbEntity)) {
|
||||||
throw new ConnectionNotFoundException();
|
throw new ConnectionNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class HomeboxIntegrationTest {
|
|||||||
assertThat(dbEntry.getAppUrl()).isEqualTo(request.appUrl());
|
assertThat(dbEntry.getAppUrl()).isEqualTo(request.appUrl());
|
||||||
assertThat(dbEntry.getUsername()).isEqualTo(request.username());
|
assertThat(dbEntry.getUsername()).isEqualTo(request.username());
|
||||||
|
|
||||||
if (dbEntry instanceof HomeboxEntity hbE) {
|
if (dbEntry instanceof HomeboxConnectionEntity hbE) {
|
||||||
assertThat(hbE.getToken()).isEqualTo("fake-jwt-token");
|
assertThat(hbE.getToken()).isEqualTo("fake-jwt-token");
|
||||||
assertThat(hbE.getAttachmentToken()).isEqualTo("fake-attach");
|
assertThat(hbE.getAttachmentToken()).isEqualTo("fake-attach");
|
||||||
assertThat(hbE.getExpiresAt().toString())
|
assertThat(hbE.getExpiresAt().toString())
|
||||||
|
|||||||
Reference in New Issue
Block a user