Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling and checking of values in Birth Message #3697

Merged
merged 15 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 137 additions & 120 deletions qa/common/src/main/java/org/eclipse/kapua/qa/common/BasicSteps.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
*******************************************************************************/
package org.eclipse.kapua.qa.common;

import io.cucumber.java.Scenario;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.commons.model.id.KapuaEid;
import org.eclipse.kapua.commons.util.RandomUtils;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.account.Account;
import org.junit.Assert;

import io.cucumber.java.Scenario;

import java.math.BigInteger;
import java.text.DateFormat;
import java.text.ParseException;
Expand Down Expand Up @@ -127,11 +126,11 @@ public void verifyException(Exception ex) throws Exception {
if (!exceptionExpected ||
(!exceptionName.isEmpty() && !ex.getClass().toGenericString().contains(exceptionName)) ||
(!exceptionMessage.isEmpty() && !exceptionMessage.trim().contentEquals("*") && !ex.getMessage().contains(exceptionMessage))) {
scenario.log("An unexpected exception was raised!");
scenario.log("An unexpected exception was raised: " + ex.getClass().getSimpleName() + " with message: " + ex.getMessage());
throw (ex);
}

scenario.log("Exception raised as expected: " + ex.getClass().getCanonicalName() + ", " + ex.getMessage());
scenario.log("Exception raised as expected: " + ex.getClass().getSimpleName() + " with message: " + ex.getMessage());
stepData.put("ExceptionCaught", true);
stepData.put("Exception", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*******************************************************************************/
package org.eclipse.kapua.qa.common.cucumber;

import java.math.BigInteger;

import org.eclipse.kapua.commons.model.id.KapuaEid;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.device.registry.DeviceStatus;

import java.math.BigInteger;

/**
* Data object used in Gherkin to input Device parameters.
* The data setters intentionally use only cucumber-friendly data types and
Expand All @@ -29,6 +29,8 @@ public class CucDevice {
KapuaId kScopeId;
Integer groupId;
KapuaId kGroupId;
Integer lastEventId;
KapuaId klastEventId;
Integer connectionId;
KapuaId kConnectionId;
Integer preferredUserId;
Expand All @@ -38,6 +40,7 @@ public class CucDevice {
String status;
DeviceStatus kStatus;
String modelId;
String modelName;
String serialNumber;
String imei;
String imsi;
Expand All @@ -48,20 +51,55 @@ public class CucDevice {
String jvmVersion;
String osgiFrameworkVersion;
String applicationFrameworkVersion;
String connectionInterface;
String connectionIp;
String applicationIdentifiers;
String acceptEncoding;

public CucDevice(Integer scopeId, Integer groupId, Integer connectionId, Integer preferredUserId, String clientId, String displayName, String status, String modelId,
String serialNumber, String imei, String imsi, String iccid, String biosVersion, String firmwareVersion, String osVersion, String jvmVersion, String osgiFrameworkVersion,
String applicationFrameworkVersion, String applicationIdentifiers, String acceptEncoding) {
String customAttribute1;
String customAttribute2;
String customAttribute3;
String customAttribute4;
String customAttribute5;

public CucDevice(Integer scopeId,
Integer groupId,
Integer connectionId,
Integer lastEventId,
Integer preferredUserId,
String clientId,
String displayName,
String status,
String modelId,
String modelName,
String serialNumber,
String imei,
String imsi,
String iccid,
String biosVersion,
String firmwareVersion,
String osVersion,
String jvmVersion,
String osgiFrameworkVersion,
String applicationFrameworkVersion,
String connectionInterface,
String connectionIp,
String applicationIdentifiers,
String acceptEncoding,
String customAttribute1,
String customAttribute2,
String customAttribute3,
String customAttribute4,
String customAttribute5) {
this.scopeId = scopeId;
this.groupId = groupId;
this.connectionId = connectionId;
this.lastEventId = lastEventId;
this.preferredUserId = preferredUserId;
this.clientId = clientId;
this.displayName = displayName;
this.status = status;
this.modelId = modelId;
this.modelName = modelName;
this.serialNumber = serialNumber;
this.imei = imei;
this.imsi = imsi;
Expand All @@ -72,8 +110,16 @@ public CucDevice(Integer scopeId, Integer groupId, Integer connectionId, Integer
this.jvmVersion = jvmVersion;
this.osgiFrameworkVersion = osgiFrameworkVersion;
this.applicationFrameworkVersion = applicationFrameworkVersion;
this.connectionInterface = connectionInterface;
this.connectionIp = connectionIp;
this.applicationIdentifiers = applicationIdentifiers;
this.acceptEncoding = acceptEncoding;
this.customAttribute1 = customAttribute1;
this.customAttribute2 = customAttribute2;
this.customAttribute3 = customAttribute3;
this.customAttribute4 = customAttribute4;
this.customAttribute5 = customAttribute5;

setStatus(this.status);
}

Expand All @@ -90,6 +136,10 @@ public void parse() {
kConnectionId = new KapuaEid(BigInteger.valueOf(connectionId));
}

if (lastEventId != null) {
klastEventId = new KapuaEid(BigInteger.valueOf(lastEventId));
}

if (preferredUserId != null) {
kPreferredUserId = new KapuaEid(BigInteger.valueOf(preferredUserId));
}
Expand Down Expand Up @@ -144,6 +194,14 @@ public void setConnectionId(KapuaId connectionId) {
kConnectionId = connectionId;
}

public KapuaId getLastEventId() {
return klastEventId;
}

public void setLastEventId(KapuaId lastEventId) {
this.klastEventId = lastEventId;
}

public KapuaId getPreferredUserId() {
return kPreferredUserId;
}
Expand Down Expand Up @@ -176,6 +234,14 @@ public void setModelId(String modelId) {
this.modelId = modelId;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public String getSerialNumber() {
return serialNumber;
}
Expand Down Expand Up @@ -256,6 +322,22 @@ public void setApplicationFrameworkVersion(String applicationFrameworkVersion) {
this.applicationFrameworkVersion = applicationFrameworkVersion;
}

public String getConnectionInterface() {
return connectionInterface;
}

public void setConnectionInterface(String connectionInterface) {
this.connectionInterface = connectionInterface;
}

public String getConnectionIp() {
return connectionIp;
}

public void setConnectionIp(String connectionIp) {
this.connectionIp = connectionIp;
}

public String getApplicationIdentifiers() {
return applicationIdentifiers;
}
Expand All @@ -271,4 +353,44 @@ public String getAcceptEncoding() {
public void setAcceptEncoding(String acceptEncoding) {
this.acceptEncoding = acceptEncoding;
}

public String getCustomAttribute1() {
return customAttribute1;
}

public void setCustomAttribute1(String customAttribute1) {
this.customAttribute1 = customAttribute1;
}

public String getCustomAttribute2() {
return customAttribute2;
}

public void setCustomAttribute2(String customAttribute2) {
this.customAttribute2 = customAttribute2;
}

public String getCustomAttribute3() {
return customAttribute3;
}

public void setCustomAttribute3(String customAttribute3) {
this.customAttribute3 = customAttribute3;
}

public String getCustomAttribute4() {
return customAttribute4;
}

public void setCustomAttribute4(String customAttribute4) {
this.customAttribute4 = customAttribute4;
}

public String getCustomAttribute5() {
return customAttribute5;
}

public void setCustomAttribute5(String customAttribute5) {
this.customAttribute5 = customAttribute5;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.qa.common.cucumber;

import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty;

/**
* Cuc {@link DeviceExtendedProperty} implementation
*
* @since 2.0.0
*/
public class CucDeviceExtendedProperty {

private String groupName;
private String name;
private String value;

public CucDeviceExtendedProperty(String groupName, String name, String value) {
this.groupName = groupName;
this.name = name;
this.value = value;
}

public String getGroupName() {
return groupName;
}

public void setGroupName(String groupName) {
this.groupName = groupName;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getValue() {
return this.value;
}

public void setValue(String value) {
this.value = value;
}
}
Loading