diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/CommonsConfigurationModule.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/CommonsConfigurationModule.java deleted file mode 100644 index f97b4f23f9b..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/CommonsConfigurationModule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.commons.configuration; - -import org.eclipse.kapua.commons.core.AbstractKapuaModule; -import org.eclipse.kapua.service.config.ServiceConfigurationFactory; - -public class CommonsConfigurationModule extends AbstractKapuaModule { - @Override - protected void configureModule() { - bind(ServiceConfigurationFactory.class).to(ServiceConfigurationFactoryImpl.class); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImpl.java deleted file mode 100644 index 4358ab8198e..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.commons.configuration; - -import java.util.Map; - -import org.eclipse.kapua.service.config.ServiceComponentConfiguration; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; - -/** - * Service component configuration entity implementation. - * - * @since 1.0 - */ -public class ServiceComponentConfigurationImpl implements ServiceComponentConfiguration { - - private String id; - private String name; - private TocdImpl definition; - private Map properties; - - /** - * Constructor - */ - public ServiceComponentConfigurationImpl() { - } - - /** - * Constructor - * - * @param id - */ - public ServiceComponentConfigurationImpl(String id) { - this.id = id; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setId(String id) { - this.id = id; - } - - @Override - public String getName() { - return name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public void setDefinition(KapuaTocd definition) { - this.definition = (TocdImpl) definition; - } - - @Override - public KapuaTocd getDefinition() { - return definition; - } - - @Override - public Map getProperties() { - return properties; - } - - @Override - public void setProperties(Map properties) { - this.properties = properties; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImpl.java deleted file mode 100644 index 2be35298a32..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.commons.configuration; - -import org.eclipse.kapua.service.config.ServiceComponentConfiguration; -import org.eclipse.kapua.service.config.ServiceConfiguration; -import org.eclipse.kapua.service.config.ServiceConfigurationFactory; - -import javax.inject.Singleton; - -/** - * Service configuration entity service factory implementation. - * - * @since 1.0 - */ -@Singleton -public class ServiceConfigurationFactoryImpl implements ServiceConfigurationFactory { - - @Override - public ServiceComponentConfiguration newComponentConfigurationInstance(String componentConfigurationId) { - return new ServiceComponentConfigurationImpl(componentConfigurationId); - } - - @Override - public ServiceConfiguration newConfigurationInstance() { - return new ServiceConfigurationImpl(); - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImpl.java deleted file mode 100644 index c2a82883382..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.commons.configuration; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.kapua.service.config.ServiceComponentConfiguration; -import org.eclipse.kapua.service.config.ServiceConfiguration; - -/** - * Service configuration entity implementation. - * - * @since 1.0 - */ -public class ServiceConfigurationImpl implements ServiceConfiguration { - - private static final long serialVersionUID = -2167999497954676423L; - - private List configurations; - - public ServiceConfigurationImpl() { - configurations = new ArrayList<>(); - } - - @Override - public List getComponentConfigurations() { - return configurations; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ValueTokenizer.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ValueTokenizer.java index afde37a28c5..0658873c578 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ValueTokenizer.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ValueTokenizer.java @@ -13,20 +13,19 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import org.eclipse.kapua.model.config.metatype.KapuaTad; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** - * The implementation of this class is inspired from the org.eclipse.equinox.metatype.impl.ValueTokenizer class - * in the Eclipse Equinox project. + * The implementation of this class is inspired from the org.eclipse.equinox.metatype.impl.ValueTokenizer class in the Eclipse Equinox project. * * @since 1.0 */ @@ -215,7 +214,7 @@ else if (values.size() > cardinality) { boolean rangeError = false; Object minVal = null; Object maxVal = null; - TscalarImpl adScalarType = TscalarImpl.fromValue(ad.getType().value()); + KapuaTscalar adScalarType = KapuaTscalar.fromValue(ad.getType().value()); switch (adScalarType) { case PASSWORD: case STRING: diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/CommonsMetatypeModule.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/CommonsMetatypeModule.java deleted file mode 100644 index 7768fa46364..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/CommonsMetatypeModule.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.commons.configuration.metatype; - -import org.eclipse.kapua.commons.core.AbstractKapuaModule; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; - -public class CommonsMetatypeModule extends AbstractKapuaModule { - @Override - protected void configureModule() { - bind(KapuaMetatypeFactory.class).to(KapuaMetatypeFactoryImpl.class); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImpl.java deleted file mode 100644 index 2062cc53a83..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; -import org.eclipse.kapua.model.config.metatype.KapuaTobject; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.KapuaTscalar; - -import javax.inject.Singleton; - -/** - * Kapua metatype objects factory service implementation. - * - * @since 1.0 - */ -@Singleton -public class KapuaMetatypeFactoryImpl implements KapuaMetatypeFactory { - - @Override - public KapuaTocd newKapuaTocd() { - return new TocdImpl(); - } - - @Override - public KapuaTad newKapuaTad() { - return new TadImpl(); - } - - @Override - public KapuaTscalar newKapuaTscalar(String type) { - return TscalarImpl.fromValue(type); - } - - @Override - public KapuaToption newKapuaToption() { - return new ToptionImpl(); - } - - @Override - public KapuaTicon newKapuaTicon() { - return new TiconImpl(); - } - - public KapuaTmetadata newKapuaTmetadata() { - return new TmetadataImpl(); - } - - public KapuaTdesignate newKapuaTdesignate() { - return new TdesignateImpl(); - } - - public KapuaTobject newKapuaTobject() { - return new TobjectImpl(); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImpl.java deleted file mode 100644 index 7ebdaa7b2a2..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - -/** - * ObjectFactory allows you to programmatically construct new instances of the Java representation for XML content.
- * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding of schema type definitions, element declarations and model groups. Factory - * methods for each of these are provided in this class. - * - * @since 1.0 - */ -@XmlRegistry -public class ObjectFactoryImpl { - - private static final QName _MetaData_QNAME = new QName("http://www.osgi.org/xmlns/metatype/v1.2.0", "MetaData"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes. - */ - public ObjectFactoryImpl() { - } - - /** - * Create an instance of {@link TiconImpl } - */ - public TiconImpl createTicon() { - return new TiconImpl(); - } - - /** - * Create an instance of {@link TattributeImpl } - */ - public TattributeImpl createTattribute() { - return new TattributeImpl(); - } - - /** - * Create an instance of {@link TmetadataImpl } - */ - public TmetadataImpl createTmetadata() { - return new TmetadataImpl(); - } - - /** - * Create an instance of {@link TdesignateImpl } - */ - public TdesignateImpl createTdesignate() { - return new TdesignateImpl(); - } - - /** - * Create an instance of {@link TadImpl } - */ - public TadImpl createTad() { - return new TadImpl(); - } - - /** - * Create an instance of {@link TobjectImpl } - */ - public TobjectImpl createTobject() { - return new TobjectImpl(); - } - - /** - * Create an instance of {@link TocdImpl } - */ - public TocdImpl createTocd() { - return new TocdImpl(); - } - - /** - * Create an instance of {@link ToptionImpl } - */ - public ToptionImpl createToption() { - return new ToptionImpl(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link TmetadataImpl }{@code >}} - */ - @XmlElementDecl(namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0", name = "MetaData") - public JAXBElement createMetaData(TmetadataImpl value) { - return new JAXBElement<>(_MetaData_QNAME, TmetadataImpl.class, null, value); - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/PasswordPropertyAdapter.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/PasswordPropertyAdapter.java index dfbc1bae967..4de5860e87d 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/PasswordPropertyAdapter.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/PasswordPropertyAdapter.java @@ -12,15 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration.metatype; -import com.google.common.base.Strings; +import java.util.Arrays; +import java.util.stream.Collectors; + import org.eclipse.kapua.commons.crypto.CryptoUtil; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.model.xml.XmlPropertyAdapted; import org.eclipse.kapua.model.xml.adapters.ClassBasedXmlPropertyAdapterBase; -import java.util.Arrays; -import java.util.stream.Collectors; +import com.google.common.base.Strings; public class PasswordPropertyAdapter extends ClassBasedXmlPropertyAdapterBase { + private final CryptoUtil cryptoUtil; public PasswordPropertyAdapter(CryptoUtil cryptoUtil) { @@ -56,8 +59,10 @@ public Password unmarshallValue(String value) { /** * Unmarshalls the given value according to {@link XmlPropertyAdapted#isEncrypted()}. * - * @param value The value to unmarshall. - * @param isEncrypted The {@link XmlPropertyAdapted#isEncrypted()}. + * @param value + * The value to unmarshall. + * @param isEncrypted + * The {@link XmlPropertyAdapted#isEncrypted()}. * @return The unmarshalled {@link Password} * @since 2.1.0 */ diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TadImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TadImpl.java deleted file mode 100644 index 4697b30f65d..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TadImpl.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.KapuaTscalar; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tad complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- * - *

- * <complexType name="Tad">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Option" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Toption" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="description" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="type" use="required" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tscalar" />
- *       <attribute name="cardinality" type="{http://www.w3.org/2001/XMLSchema}int" default="0" />
- *       <attribute name="min" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="max" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="default" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="required" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ - -public class TadImpl implements KapuaTad { - - protected List option; - protected List any; - protected String name; - protected String description; - protected String id; - protected TscalarImpl type; - protected Integer cardinality; - protected String min; - protected String max; - protected String defaultValue; - protected Boolean required; - private Map otherAttributes = new HashMap<>(); - - /** - * Gets the value of the option property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the option property. - *

- *

- * For example, to add a new item, do as follows: - *

- * - *

-     * getOption().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link ToptionImpl } - */ - public List getOption() { - if (option == null) { - option = new ArrayList<>(); - } - return new ArrayList<>(this.option); - } - - /** - * Add an option to the internal list - * - * @param option - */ - public void addOption(KapuaToption option) { - if (this.option == null) { - this.option = new ArrayList<>(); - } - - this.option.add((ToptionImpl) option); - } - - @Override - public void setOption(List option) { - this.option = new ArrayList<>(); - for (KapuaToption singleOption : option) { - this.option.add((ToptionImpl) singleOption); - } - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

- * - *

-     * getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - @Override - public void setAny(List any) { - this.any = any; - } - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the description property. - * - * @return possible object is - * {@link String } - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setDescription(String value) { - this.description = value; - } - - /** - * Gets the value of the id property. - * - * @return possible object is - * {@link String } - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the type property. - * - * @return possible object is - * {@link TscalarImpl } - */ - public TscalarImpl getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link TscalarImpl } - */ - public void setType(KapuaTscalar value) { - this.type = (TscalarImpl) value; - } - - /** - * Gets the value of the cardinality property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getCardinality() { - if (cardinality == null) { - return 0; - } else { - return cardinality; - } - } - - /** - * Sets the value of the cardinality property. - * - * @param value - * allowed object is - * {@link Integer } - */ - public void setCardinality(Integer value) { - this.cardinality = value; - } - - /** - * Gets the value of the min property. - * - * @return possible object is - * {@link String } - */ - public String getMin() { - return min; - } - - /** - * Sets the value of the min property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setMin(String value) { - this.min = value; - } - - /** - * Gets the value of the max property. - * - * @return possible object is - * {@link String } - */ - public String getMax() { - return max; - } - - /** - * Sets the value of the max property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setMax(String value) { - this.max = value; - } - - /** - * Gets the value of the default property. - * - * @return possible object is - * {@link String } - */ - public String getDefault() { - return defaultValue; - } - - /** - * Sets the value of the default property. - * - * @param value - * allowed object is - * {@link String } - */ - public void setDefault(String value) { - this.defaultValue = value; - } - - /** - * Gets the value of the required property. - * - * @return possible object is - * {@link Boolean } - */ - public Boolean isRequired() { - if (required == null) { - return true; - } else { - return required; - } - } - - /** - * Sets the value of the required property. - * - * @param value - * allowed object is - * {@link Boolean } - */ - public void setRequired(Boolean value) { - this.required = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - public void putOtherAttribute(QName key, String value) { - getOtherAttributes().put(key, - value); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImpl.java deleted file mode 100644 index 310e029b27f..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImpl.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTattribute; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tattribute complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Tattribute">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Value" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="adref" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="content" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -@XmlRootElement(name = "Attribute", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "Tattribute", propOrder = { - "value", - "any" -}) -public class TattributeImpl implements KapuaTattribute { - - @XmlElement(name = "Value", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - protected List value; - @XmlAnyElement(lax = true) - protected List any; - @XmlAttribute(name = "adref", required = true) - protected String adref; - @XmlAttribute(name = "content") - protected String content; - @XmlAnyAttribute - private Map otherAttributes = new HashMap(); - - /** - * Gets the value of the value property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the value property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getValue().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link String } - */ - public List getValue() { - if (value == null) { - value = new ArrayList(); - } - return this.value; - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - /** - * Gets the value of the adref property. - * - * @return possible object is - * {@link String } - */ - public String getAdref() { - return adref; - } - - /** - * Sets the value of the adref property. - * - * @param value allowed object is - * {@link String } - */ - public void setAdref(String value) { - this.adref = value; - } - - /** - * Gets the value of the content property. - * - * @return possible object is - * {@link String } - */ - public String getContent() { - return content; - } - - /** - * Sets the value of the content property. - * - * @param value allowed object is - * {@link String } - */ - public void setContent(String value) { - this.content = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImpl.java deleted file mode 100644 index d24d0b471c6..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImpl.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; -import org.eclipse.kapua.model.config.metatype.KapuaTobject; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tdesignate complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Tdesignate">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Object" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tobject"/>
- *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="pid" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="factoryPid" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="bundle" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="optional" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- *       <attribute name="merge" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class TdesignateImpl implements KapuaTdesignate { - - protected TobjectImpl object; - protected List any; - protected String pid; - protected String factoryPid; - protected String bundle; - protected Boolean optional; - protected Boolean merge; - private Map otherAttributes = new HashMap(); - - /** - * Gets the value of the object property. - * - * @return possible object is - * {@link TobjectImpl } - */ - public KapuaTobject getObject() { - return object; - } - - /** - * Sets the value of the object property. - * - * @param value allowed object is - * {@link TobjectImpl } - */ - public void setObject(KapuaTobject value) { - this.object = (TobjectImpl) value; - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - public void setAny(List any) { - this.any = any; - } - - /** - * Gets the value of the pid property. - * - * @return possible object is - * {@link String } - */ - public String getPid() { - return pid; - } - - /** - * Sets the value of the pid property. - * - * @param value allowed object is - * {@link String } - */ - public void setPid(String value) { - this.pid = value; - } - - /** - * Gets the value of the factoryPid property. - * - * @return possible object is - * {@link String } - */ - public String getFactoryPid() { - return factoryPid; - } - - /** - * Sets the value of the factoryPid property. - * - * @param value allowed object is - * {@link String } - */ - public void setFactoryPid(String value) { - this.factoryPid = value; - } - - /** - * Gets the value of the bundle property. - * - * @return possible object is - * {@link String } - */ - public String getBundle() { - return bundle; - } - - /** - * Sets the value of the bundle property. - * - * @param value allowed object is - * {@link String } - */ - public void setBundle(String value) { - this.bundle = value; - } - - /** - * Gets the value of the optional property. - * - * @return possible object is - * {@link Boolean } - */ - public Boolean isOptional() { - if (optional == null) { - return false; - } else { - return optional; - } - } - - /** - * Sets the value of the optional property. - * - * @param value allowed object is - * {@link Boolean } - */ - public void setOptional(Boolean value) { - this.optional = value; - } - - /** - * Gets the value of the merge property. - * - * @return possible object is - * {@link Boolean } - */ - public Boolean isMerge() { - if (merge == null) { - return false; - } else { - return merge; - } - } - - /** - * Sets the value of the merge property. - * - * @param value allowed object is - * {@link Boolean } - */ - public void setMerge(Boolean value) { - this.merge = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - public void setOtherAttributes(Map otherAttributes) { - this.otherAttributes = otherAttributes; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TiconImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TiconImpl.java deleted file mode 100644 index e10d230b9cb..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TiconImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.w3c.dom.Element; - -/** - *

- * Java class for Ticon complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Ticon">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="resource" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="size" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class TiconImpl implements KapuaTicon { - - protected List any; - protected String resource; - protected BigInteger size; - private Map otherAttributes = new HashMap<>(); - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

- *

-     * getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList<>(); - } - return this.any; - } - - /** - * Gets the value of the resource property. - * - * @return possible object is - * {@link String } - */ - public String getResource() { - return resource; - } - - /** - * Sets the value of the resource property. - * - * @param value allowed object is - * {@link String } - */ - public void setResource(String value) { - this.resource = value; - } - - /** - * Gets the value of the size property. - * - * @return possible object is - * {@link BigInteger } - */ - public BigInteger getSize() { - return size; - } - - /** - * Sets the value of the size property. - * - * @param value allowed object is - * {@link BigInteger } - */ - public void setSize(BigInteger value) { - this.size = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImpl.java deleted file mode 100644 index f776da91e58..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; -import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tmetadata complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Tmetadata">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="OCD" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tocd" maxOccurs="unbounded" minOccurs="0"/>
- *         <element name="Designate" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tdesignate" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="localization" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class TmetadataImpl implements KapuaTmetadata { - - protected List ocd; - protected List designate; - protected List any; - protected String localization; - private Map otherAttributes = new HashMap(); - - /** - * Gets the value of the ocd property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ocd property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getOCD().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link TocdImpl } - */ - @Override - public List getOCD() { - if (ocd == null) { - ocd = new ArrayList<>(); - } - return new ArrayList<>(this.ocd); - } - - public void setOCD(List ocd) { - this.ocd = ocd; - } - - /** - * Gets the value of the designate property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the designate property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getDesignate().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link TdesignateImpl } - */ - public List getDesignate() { - if (designate == null) { - designate = new ArrayList<>(); - } - return new ArrayList<>(this.designate); - } - - public void setDesignate(List designate) { - this.designate = designate; - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - public void setAny(List any) { - this.any = any; - } - - /** - * Gets the value of the localization property. - * - * @return possible object is - * {@link String } - */ - public String getLocalization() { - return localization; - } - - /** - * Sets the value of the localization property. - * - * @param value allowed object is - * {@link String } - */ - public void setLocalization(String value) { - this.localization = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - public void setOtherAttributes(Map otherAttributes) { - this.otherAttributes = otherAttributes; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImpl.java deleted file mode 100644 index 85ba1b967b5..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTattribute; -import org.eclipse.kapua.model.config.metatype.KapuaTobject; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tobject complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Tobject">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Attribute" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tattribute" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="ocdref" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class TobjectImpl implements KapuaTobject { - - protected List attribute; - protected List any; - protected String ocdref; - private Map otherAttributes = new HashMap(); - - /** - * Gets the value of the attribute property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the attribute property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getAttribute().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link TattributeImpl } - */ - public List getAttribute() { - if (attribute == null) { - attribute = new ArrayList(); - } - return new ArrayList(this.attribute); - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - /** - * Gets the value of the ocdref property. - * - * @return possible object is - * {@link String } - */ - public String getOcdref() { - return ocdref; - } - - /** - * Sets the value of the ocdref property. - * - * @param value allowed object is - * {@link String } - */ - public void setOcdref(String value) { - this.ocdref = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TocdImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TocdImpl.java deleted file mode 100644 index 8b81ee4f8c8..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TocdImpl.java +++ /dev/null @@ -1,290 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.w3c.dom.Element; - -/** - *

- * Java class for Tocd complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Tocd">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="AD" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Tad" maxOccurs="unbounded"/>
- *         <element name="Icon" type="{http://www.osgi.org/xmlns/metatype/v1.2.0}Ticon" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="description" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class TocdImpl implements KapuaTocd { - - protected List ad; - protected List icon; - protected List any; - protected String name; - protected String description; - protected String id; - private Map otherAttributes = new HashMap<>(); - - /** - * Gets the value of the ad property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ad property. - *

- *

- * For example, to add a new item, do as follows: - *

- *

-     * getAD().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link TadImpl } - */ - public List getAD() { - if (ad == null) { - ad = new ArrayList<>(); - } - return this.ad; - } - - @Override - public void setAD(List ad) { - this.ad = ad; - } - - /** - * Add Tad to the internal list - * - * @param ad - */ - public void addAD(KapuaTad ad) { - if (this.ad == null) { - this.ad = new ArrayList<>(); - } - - this.ad.add(ad); - } - - /** - * Gets the value of the icon property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the icon property. - *

- *

- * For example, to add a new item, do as follows: - *

- *

-     * getIcon().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link TiconImpl } - */ - public List getIcon() { - if (icon == null) { - icon = new ArrayList<>(); - } - return this.icon; - } - - @Override - public void setIcon(List icon) { - this.icon = icon; - } - - /** - * Add icon to the internal list - * - * @param icon - */ - public void addIcon(KapuaTicon icon) { - if (this.icon == null) { - this.icon = new ArrayList<>(); - } - this.icon.add((TiconImpl) icon); - } - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

- *

-     * getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList<>(); - } - return this.any; - } - - @Override - public void setAny(List any) { - this.any = any; - } - - /** - * Add a generic object to the internal list - * - * @param object - */ - public void addAny(Object object) { - getAny().add(object); - } - - /** - * Gets the value of the name property. - * - * @return possible object is - * {@link String } - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is - * {@link String } - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the description property. - * - * @return possible object is - * {@link String } - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value allowed object is - * {@link String } - */ - public void setDescription(String value) { - this.description = value; - } - - /** - * Gets the value of the id property. - * - * @return possible object is - * {@link String } - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value allowed object is - * {@link String } - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - /** - * Insert a generic value for the provided QName - * - * @param key - * @param value - */ - public void putOtherAttribute(QName key, String value) { - getOtherAttributes().put(key, - value); - } - - @Override - public void setOtherAttributes(Map otherAttributes) { - this.otherAttributes = otherAttributes; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImpl.java deleted file mode 100644 index 7d779d0072a..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImpl.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.w3c.dom.Element; - -/** - *

- * Java class for Toption complex type. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- * <complexType name="Toption">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="label" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * @since 1.0 - */ -public class ToptionImpl implements KapuaToption { - - protected List any; - protected String label; - protected String value; - private Map otherAttributes = new HashMap(); - - /** - * Gets the value of the any property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - *

- *

- * For example, to add a new item, do as follows: - *

- *

-     * getAny().add(newItem);
-     * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * {@link Object } - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; - } - - /** - * Gets the value of the label property. - * - * @return possible object is - * {@link String } - */ - public String getLabel() { - return label; - } - - /** - * Sets the value of the label property. - * - * @param value allowed object is - * {@link String } - */ - public void setLabel(String value) { - this.label = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is - * {@link String } - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is - * {@link String } - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - *

- *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * @return always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TscalarImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TscalarImpl.java deleted file mode 100644 index 8925f9b39cb..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/TscalarImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * 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.commons.configuration.metatype; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.eclipse.kapua.model.config.metatype.KapuaTscalar; - -/** - *

- * Java class for Tscalar. - *

- *

- * The following schema fragment specifies the expected content contained within this class. - *

- *

- *

- * <simpleType name="Tscalar">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="String"/>
- *     <enumeration value="Long"/>
- *     <enumeration value="Double"/>
- *     <enumeration value="Float"/>
- *     <enumeration value="Integer"/>
- *     <enumeration value="Byte"/>
- *     <enumeration value="Char"/>
- *     <enumeration value="Boolean"/>
- *     <enumeration value="Short"/>
- *     <enumeration value="Password"/>
- *   </restriction>
- * </simpleType>
- * 
- * - * @since 1.0 - */ -@XmlEnum -@XmlType(name = "Tscalar") -@XmlRootElement(name = "OCD", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") -@XmlAccessorType(XmlAccessType.PROPERTY) -public enum TscalarImpl implements KapuaTscalar { - @XmlEnumValue("String") - STRING("String"), - @XmlEnumValue("Long") - LONG("Long"), - @XmlEnumValue("Double") - DOUBLE("Double"), - @XmlEnumValue("Float") - FLOAT("Float"), - @XmlEnumValue("Integer") - INTEGER("Integer"), - @XmlEnumValue("Byte") - BYTE("Byte"), - @XmlEnumValue("Char") - CHAR("Char"), - @XmlEnumValue("Boolean") - BOOLEAN("Boolean"), - @XmlEnumValue("Short") - SHORT("Short"), - @XmlEnumValue("Password") - PASSWORD("Password"); - private final String value; - - /** - * Constructor - * - * @param v - */ - TscalarImpl(String v) { - value = v; - } - - @Override - public String value() { - return value; - } - - /** - * Convert a String value to a {@link TscalarImpl} - * - * @param v - * @return - */ - public static TscalarImpl fromValue(String v) { - for (TscalarImpl c : TscalarImpl.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/util/StringUtil.java b/commons/src/main/java/org/eclipse/kapua/commons/util/StringUtil.java index d5f03229d8b..58ab61d4af6 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/util/StringUtil.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/util/StringUtil.java @@ -12,14 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.commons.util; -import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.Password; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; - import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.eclipse.kapua.KapuaException; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; +import org.eclipse.kapua.model.config.metatype.Password; /** * Utilities to manipulate string @@ -66,81 +65,84 @@ public static String[] splitValues(String strValues) { for (int i = 0; i < strValues.length(); i++) { char c1 = strValues.charAt(i); switch (c1) { - case DELIMITER: - // When the delimiter is encountered, add the extracted - // token to the result and prepare the buffer to receive the - // next token. - values.add(buffer.toString()); - buffer.delete(0, buffer.length()); - break; - case ESCAPE: - // When the escape is encountered, add the immediately - // following character to the token, unless the end of the - // input has been reached. Note this will result in loop - // counter 'i' being incremented twice, once here and once - // at the end of the loop. - if (i + 1 < strValues.length()) { - buffer.append(strValues.charAt(++i)); + case DELIMITER: + // When the delimiter is encountered, add the extracted + // token to the result and prepare the buffer to receive the + // next token. + values.add(buffer.toString()); + buffer.delete(0, buffer.length()); + break; + case ESCAPE: + // When the escape is encountered, add the immediately + // following character to the token, unless the end of the + // input has been reached. Note this will result in loop + // counter 'i' being incremented twice, once here and once + // at the end of the loop. + if (i + 1 < strValues.length()) { + buffer.append(strValues.charAt(++i)); + } + // If the ESCAPE character occurs as the last character + // of the string, ignore it. + break; + default: + // For all other characters, add them to the current token + // unless dealing with unescaped whitespace at the beginning + // or end. We know the whitespace is unescaped because it + // would have been handled in the ESCAPE case otherwise. + if (Character.isWhitespace(c1)) { + // Ignore unescaped whitespace at the beginning of the + // token. + if (buffer.length() == 0) { + continue; } - // If the ESCAPE character occurs as the last character - // of the string, ignore it. - break; - default: - // For all other characters, add them to the current token - // unless dealing with unescaped whitespace at the beginning - // or end. We know the whitespace is unescaped because it - // would have been handled in the ESCAPE case otherwise. - if (Character.isWhitespace(c1)) { - // Ignore unescaped whitespace at the beginning of the - // token. - if (buffer.length() == 0) { - continue; - } - // If the whitespace is not at the beginning, look - // forward, starting with the next character, to see if - // it's in the middle or at the end. Unescaped - // whitespace in the middle is okay. - for (int j = i + 1; j < strValues.length(); j++) { - // Keep looping until the end of the string is - // reached or a non-whitespace character other than - // the escape is seen. - char c2 = strValues.charAt(j); - if (!Character.isWhitespace(c2)) { - // If the current character is not the DELIMITER, all whitespace - // characters are significant and should be added to the token. - // Otherwise, they're at the end and should be ignored. But watch - // out for an escape character at the end of the input. Ignore it - // and any previous insignificant whitespace if it exists. - if (c2 == ESCAPE && j + 1 >= strValues.length()) { - continue; - } - if (c2 != DELIMITER) { - buffer.append(strValues.substring(i, j)); - } - // Let loop counter i catch up with the inner loop but keep in - // mind it will still be incremented at the end of the outer loop. - i = j - 1; - break; + // If the whitespace is not at the beginning, look + // forward, starting with the next character, to see if + // it's in the middle or at the end. Unescaped + // whitespace in the middle is okay. + for (int j = i + 1; j < strValues.length(); j++) { + // Keep looping until the end of the string is + // reached or a non-whitespace character other than + // the escape is seen. + char c2 = strValues.charAt(j); + if (!Character.isWhitespace(c2)) { + // If the current character is not the DELIMITER, all whitespace + // characters are significant and should be added to the token. + // Otherwise, they're at the end and should be ignored. But watch + // out for an escape character at the end of the input. Ignore it + // and any previous insignificant whitespace if it exists. + if (c2 == ESCAPE && j + 1 >= strValues.length()) { + continue; + } + if (c2 != DELIMITER) { + buffer.append(strValues.substring(i, j)); } + // Let loop counter i catch up with the inner loop but keep in + // mind it will still be incremented at the end of the outer loop. + i = j - 1; + break; } - } else { - // For non-whitespace characters. - buffer.append(c1); } + } else { + // For non-whitespace characters. + buffer.append(c1); + } } } // Don't forget to add the last token. values.add(buffer.toString()); - return values.toArray(new String[]{}); + return values.toArray(new String[] {}); } /** * Convert the string to the appropriate Object based on type * - * @param type allowed values are {@link TscalarImpl} - * @param string the input value - * @return the output value - * @throws KapuaException when something goes wrong + * @param type + * allowed values are {@link KapuaTscalar} + * @param string + * the input value + * @return the output value + * @throws KapuaException + * when something goes wrong */ public static Object stringToValue(String type, String string) throws KapuaException { if (string == null) { @@ -151,45 +153,45 @@ public static Object stringToValue(String type, String string) throws KapuaExcep throw KapuaException.internalError("Invalid type"); } - TscalarImpl scalarType = TscalarImpl.fromValue(type); + KapuaTscalar scalarType = KapuaTscalar.fromValue(type); - if (TscalarImpl.STRING.equals(scalarType)) { + if (KapuaTscalar.STRING.equals(scalarType)) { return string; } - if (TscalarImpl.BOOLEAN.equals(scalarType)) { + if (KapuaTscalar.BOOLEAN.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Boolean.valueOf(string); } - if (TscalarImpl.BYTE.equals(scalarType)) { + if (KapuaTscalar.BYTE.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Byte.valueOf(string); } - if (TscalarImpl.CHAR.equals(scalarType)) { + if (KapuaTscalar.CHAR.equals(scalarType)) { return string.toCharArray()[0]; } - if (TscalarImpl.DOUBLE.equals(scalarType)) { + if (KapuaTscalar.DOUBLE.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Double.valueOf(string); } - if (TscalarImpl.FLOAT.equals(scalarType)) { + if (KapuaTscalar.FLOAT.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Float.valueOf(string); } - if (TscalarImpl.INTEGER.equals(scalarType)) { + if (KapuaTscalar.INTEGER.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Integer.valueOf(string); } - if (TscalarImpl.LONG.equals(scalarType)) { + if (KapuaTscalar.LONG.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Long.valueOf(string); } - if (TscalarImpl.SHORT.equals(scalarType)) { + if (KapuaTscalar.SHORT.equals(scalarType)) { return StringUtils.isEmpty(string) ? null : Short.valueOf(string); } - if (TscalarImpl.PASSWORD.equals(scalarType)) { + if (KapuaTscalar.PASSWORD.equals(scalarType)) { return new Password(string); } @@ -197,8 +199,7 @@ public static Object stringToValue(String type, String string) throws KapuaExcep } /** - * Convert the value to a String.
- * It supports also arrays such as Integer[], Boolean[], ... Password[]). For the arrays the converted String will be a comma separated concatenation. + * Convert the value to a String.
It supports also arrays such as Integer[], Boolean[], ... Password[]). For the arrays the converted String will be a comma separated concatenation. * * @param value * @return @@ -352,8 +353,7 @@ public static String valueToString(Object value) { } /** - * Escape the String
- * Escaped values are '\' ',' and ' ' + * Escape the String
Escaped values are '\' ',' and ' ' * * @param s * @return diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationTest.java similarity index 91% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationTest.java index 96e86bbe024..012f6f69261 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationTest.java @@ -12,31 +12,30 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.config.ServiceComponentConfiguration; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.HashMap; -import java.util.Map; - - @Category(JUnitTests.class) -public class ServiceComponentConfigurationImplTest { +public class ServiceComponentConfigurationTest { - ServiceComponentConfigurationImpl serviceComponentConfiguration; + ServiceComponentConfiguration serviceComponentConfiguration; @Before public void createInstanceOfClass() { - serviceComponentConfiguration = new ServiceComponentConfigurationImpl(); + serviceComponentConfiguration = new ServiceComponentConfiguration(); } @Test public void createInstanceWithSecondConstructorTest() { - ServiceComponentConfigurationImpl componentConfiguration = new ServiceComponentConfigurationImpl("12"); + ServiceComponentConfiguration componentConfiguration = new ServiceComponentConfiguration("12"); Assert.assertEquals(componentConfiguration.getId(), "12"); } @@ -112,7 +111,7 @@ public void setDefinitionToNullTest() { @Test public void setDefinitionToRegularValueTest() { - KapuaTocd tocd = new TocdImpl(); + KapuaTocd tocd = new KapuaTocd(); serviceComponentConfiguration.setDefinition(tocd); Assert.assertEquals(serviceComponentConfiguration.getDefinition(), tocd); } @@ -129,7 +128,7 @@ public void setPropertiesToRegularValueTest() { properties.put("property1", 10); properties.put("property2", "string"); properties.put("property3", 'c'); - properties.put("property4", (double)10); + properties.put("property4", (double) 10); serviceComponentConfiguration.setProperties(properties); Assert.assertEquals(properties, serviceComponentConfiguration.getProperties()); } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImplTest.java deleted file mode 100644 index a54dc50a106..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImplTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.commons.configuration; - -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.eclipse.kapua.service.config.ServiceComponentConfiguration; -import org.eclipse.kapua.service.config.ServiceConfiguration; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - - -@Category(JUnitTests.class) -public class ServiceConfigurationFactoryImplTest { - - @Test - public void newComponentConfigurationInstanceWithStringTest() { - ServiceConfigurationFactoryImpl configurationFactory = new ServiceConfigurationFactoryImpl(); - ServiceComponentConfiguration componentConfiguration = configurationFactory.newComponentConfigurationInstance("testInstance"); - Assert.assertEquals(componentConfiguration.getId(), "testInstance"); - } - - @Test - public void newComponentConfigurationInstanceWithNumberTest() { - ServiceConfigurationFactoryImpl configurationFactory = new ServiceConfigurationFactoryImpl(); - ServiceComponentConfiguration componentConfiguration = configurationFactory.newComponentConfigurationInstance("1"); - Assert.assertEquals(componentConfiguration.getId(), "1"); - } - - @Test - public void newComponentConfigurationInstanceWithSymbolTest() { - ServiceConfigurationFactoryImpl configurationFactory = new ServiceConfigurationFactoryImpl(); - ServiceComponentConfiguration componentConfiguration = configurationFactory.newComponentConfigurationInstance("@"); - Assert.assertEquals(componentConfiguration.getId(), "@"); - } - - @Test - public void newConfigurationInstanceTest() { - ServiceConfigurationFactoryImpl configurationFactory = new ServiceConfigurationFactoryImpl(); - ServiceConfiguration configuration = configurationFactory.newConfigurationInstance(); - Assert.assertNotNull(configuration); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImplTest.java deleted file mode 100644 index 02d6ddff21e..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationImplTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.commons.configuration; - -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class ServiceConfigurationImplTest { - - ServiceConfigurationImpl configuration; - - @Before - public void createNewClass() { - configuration = new ServiceConfigurationImpl(); - } - - @Test - public void getComponentConfigurationsTest() { - Assert.assertNotNull(configuration.getComponentConfigurations()); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/StringUtilTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/StringUtilTest.java index 6a918294d72..bb445dfdc9a 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/StringUtilTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/configuration/StringUtilTest.java @@ -13,8 +13,8 @@ package org.eclipse.kapua.commons.configuration; import org.assertj.core.api.Assertions; -import org.eclipse.kapua.commons.configuration.metatype.Password; import org.eclipse.kapua.commons.util.StringUtil; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -25,7 +25,7 @@ public class StringUtilTest { @Test public void shouldConvertPasswordsArrayToString() { // Given - Password[] passwords = new Password[]{new Password("foo")}; + Password[] passwords = new Password[] { new Password("foo") }; // When String passwordsString = StringUtil.valueToString(passwords); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ValueTokenizerTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ValueTokenizerTest.java index 09d902b4e16..091bb0c85c9 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ValueTokenizerTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ValueTokenizerTest.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; -import org.eclipse.kapua.commons.configuration.metatype.TadImpl; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; +import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaToption; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) public class ValueTokenizerTest { @@ -37,7 +36,7 @@ public void valueTokenizerNullStringTest() throws Exception { public void valueTokenizerNotNullTest() throws Exception { try { Assert.assertNotNull(new ValueTokenizer("valueTokenizerConstructor")); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("No exception expected"); } } @@ -48,7 +47,7 @@ public void valueTokenizerDelimeterTest() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123,aaa,rrr"); try { Assert.assertEquals("a123,aaa,rrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Failed to delimit input string"); } } @@ -58,7 +57,7 @@ public void valueTokenizerEscapeTest() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123\\aaa\\rrr"); try { Assert.assertEquals("a123aaarrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Failed to load escape string"); } } @@ -68,7 +67,7 @@ public void valueTokenizerEscapeAtEndTest() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123aaarrr\\"); try { Assert.assertEquals("a123aaarrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Failed to load escape string"); } } @@ -79,7 +78,7 @@ public void valueTokenizerEscapeAtBeginningTest() throws Exception { try { valueTokenizer.getValuesAsString(); Assert.assertEquals("a123aaarrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Failed to load escape string"); } } @@ -89,7 +88,7 @@ public void valueTokenizerSpaceAtBeginningTest() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer(" a123aaarrr"); try { Assert.assertEquals("a123aaarrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Cannot load string whit white space at the beginning"); } } @@ -99,7 +98,7 @@ public void valueTokenizerSpaceAtTheEndTest() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123aaarrr "); try { Assert.assertEquals("a123aaarrr", valueTokenizer.getValuesAsString()); - } catch (Exception ex){ + } catch (Exception ex) { Assert.fail("Cannot load string whit white space at the end"); } } @@ -128,7 +127,7 @@ public void valueTokenizerValueAStringSpaceMiddleTest() throws Exception { @Test public void valueTokenizerValuesAsArrayWithDelimeter() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a,123,aaa,rrr"); - String [] expectedValues = new String[]{"a", "123", "aaa", "rrr"}; + String[] expectedValues = new String[] { "a", "123", "aaa", "rrr" }; try { Assert.assertArrayEquals(expectedValues, valueTokenizer.getValuesAsArray()); } catch (Exception ex) { @@ -139,7 +138,7 @@ public void valueTokenizerValuesAsArrayWithDelimeter() throws Exception { @Test public void valueTokenizerValuesAsArrayWithEscape() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123\\aaarr\\r"); - String [] expectedValues = new String[]{"a123aaarrr"}; + String[] expectedValues = new String[] { "a123aaarrr" }; try { Assert.assertArrayEquals(expectedValues, valueTokenizer.getValuesAsArray()); } catch (Exception ex) { @@ -160,9 +159,9 @@ public void valueTokenizerValuesAsArrayWithNullString() throws Exception { @Test public void valueTokenizerValueAsArrayDelimiterAndEscape() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a12\\3,a\\,aa,r\\rr,"); - String [] expectedValues = new String[] {"a123", "a,aa", "rrr", ""}; + String[] expectedValues = new String[] { "a123", "a,aa", "rrr", "" }; try { - Assert.assertArrayEquals(expectedValues,valueTokenizer.getValuesAsArray()); + Assert.assertArrayEquals(expectedValues, valueTokenizer.getValuesAsArray()); } catch (Exception ex) { Assert.fail("Arrays are not equal"); } @@ -171,19 +170,19 @@ public void valueTokenizerValueAsArrayDelimiterAndEscape() throws Exception { @Test public void valueTokenizerValueAsArray() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer(" a123, aaa, rrr"); - String [] expectedValues = new String[] {"a123", "aaa", "rrr"}; + String[] expectedValues = new String[] { "a123", "aaa", "rrr" }; try { - Assert.assertArrayEquals(expectedValues,valueTokenizer.getValuesAsArray()); + Assert.assertArrayEquals(expectedValues, valueTokenizer.getValuesAsArray()); } catch (Exception ex) { Assert.fail("Arrays are not equal"); } } - //test for method ...getValues(); + //test for method ...getValues(); @Test public void valueTokenizerGetValuesWithDelimeter() throws Exception { ValueTokenizer valueTokenizer = new ValueTokenizer("a123,aaarrr"); - String [] expectedValues = new String[] {"a123", "aaarrr"}; + String[] expectedValues = new String[] { "a123", "aaarrr" }; try { Assert.assertArrayEquals(expectedValues, valueTokenizer.getValues().toArray()); } catch (Exception ex) { @@ -207,7 +206,7 @@ public void validateWithNullValueTokenizerTest() { @Test public void validateZeroCardinalityTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(0); String message = valueTokenizer.validate(tad); Assert.assertEquals("Cardinality violation: \"asdf,qwer\" has 2 value(s) but must have between 1 and 1 value(s).", message); @@ -216,7 +215,7 @@ public void validateZeroCardinalityTest() { @Test public void validateOneCardinalityTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(1); String message = valueTokenizer.validate(tad); Assert.assertEquals("Cardinality violation: \"asdf,qwer\" has 2 value(s) but must have between 0 and 1 value(s).", message); @@ -225,7 +224,7 @@ public void validateOneCardinalityTest() { @Test public void validateEmptyStringZeroCardinalityTest() { ValueTokenizer valueTokenizer = new ValueTokenizer(""); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(0); String message = valueTokenizer.validate(tad); Assert.assertEquals("Internal error: null", message); @@ -234,7 +233,7 @@ public void validateEmptyStringZeroCardinalityTest() { @Test public void validateEmptyStringNonZeroCardinalityTest() { ValueTokenizer valueTokenizer = new ValueTokenizer(""); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(2); String message = valueTokenizer.validate(tad); Assert.assertEquals("Internal error: null", message); @@ -243,7 +242,7 @@ public void validateEmptyStringNonZeroCardinalityTest() { @Test public void validateNegativeCardinalityTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(-1); String message = valueTokenizer.validate(tad); Assert.assertEquals("Cardinality violation: \"asdf,qwer\" has 2 value(s) but must have between 0 and 1 value(s).", message); @@ -252,7 +251,7 @@ public void validateNegativeCardinalityTest() { @Test public void validateWithoutTypeTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); String message = valueTokenizer.validate(tad); Assert.assertEquals("Internal error: null", message); @@ -261,9 +260,9 @@ public void validateWithoutTypeTest() { @Test public void validateWithBooleanTypeTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BOOLEAN); + tad.setType(KapuaTscalar.BOOLEAN); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -271,9 +270,9 @@ public void validateWithBooleanTypeTest() { @Test public void validateWithStringTypeWithoutRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.STRING); + tad.setType(KapuaTscalar.STRING); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -281,9 +280,9 @@ public void validateWithStringTypeWithoutRestrictionsTest() { @Test public void validateWithStringTypeWithMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.STRING); + tad.setType(KapuaTscalar.STRING); tad.setMax("2"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value asdf is out of range", message); @@ -293,9 +292,9 @@ public void validateWithStringTypeWithMaxRestrictionTest() { /* @Test public void validateWithStringTypeWithMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("asdf, qwer"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.STRING); + tad.setType(KapuaTscalar.STRING); tad.setMin("10"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value asdf is out of range", message); @@ -304,9 +303,9 @@ public void validateWithStringTypeWithMinRestrictionTest() { @Test public void validateWithIntegerTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -314,9 +313,9 @@ public void validateWithIntegerTypeWithoutRestrictionTest() { @Test public void validateMinAndMaxIntegerRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -326,9 +325,9 @@ public void validateMinAndMaxIntegerRestrictionTest() { @Test public void validateCornerCasesIntegerRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -338,9 +337,9 @@ public void validateCornerCasesIntegerRestrictionsTest() { @Test public void validateEqualMinAndMaxIntegerRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -350,9 +349,9 @@ public void validateEqualMinAndMaxIntegerRestrictionTest() { @Test public void validateMixedMinAndMaxIntegerRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -362,9 +361,9 @@ public void validateMixedMinAndMaxIntegerRestrictionTest() { @Test public void validateWithIntegerTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -373,9 +372,9 @@ public void validateWithIntegerTypeWitMaxRestrictionTest() { @Test public void validateWithIntegerTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.INTEGER); + tad.setType(KapuaTscalar.INTEGER); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -384,9 +383,9 @@ public void validateWithIntegerTypeWitMinRestrictionTest() { @Test public void validateWithLongTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -394,9 +393,9 @@ public void validateWithLongTypeWithoutRestrictionTest() { @Test public void validateWithLongTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -405,9 +404,9 @@ public void validateWithLongTypeWitMaxRestrictionTest() { @Test public void validateWithLongTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -416,9 +415,9 @@ public void validateWithLongTypeWitMinRestrictionTest() { @Test public void validateMinAndMaxLongRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -428,9 +427,9 @@ public void validateMinAndMaxLongRestrictionTest() { @Test public void validateCornerCasesLongRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -440,9 +439,9 @@ public void validateCornerCasesLongRestrictionsTest() { @Test public void validateEqualMinAndMaxLongRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -452,9 +451,9 @@ public void validateEqualMinAndMaxLongRestrictionTest() { @Test public void validateMixedMinAndMaxLongRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.LONG); + tad.setType(KapuaTscalar.LONG); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -464,9 +463,9 @@ public void validateMixedMinAndMaxLongRestrictionTest() { @Test public void validateWithDoubleTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -474,9 +473,9 @@ public void validateWithDoubleTypeWithoutRestrictionTest() { @Test public void validateWithDoubleTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -485,9 +484,9 @@ public void validateWithDoubleTypeWitMaxRestrictionTest() { @Test public void validateWithDoubleTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -496,9 +495,9 @@ public void validateWithDoubleTypeWitMinRestrictionTest() { @Test public void validateMinAndMaxDoubleRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -508,9 +507,9 @@ public void validateMinAndMaxDoubleRestrictionTest() { @Test public void validateCornerCasesDoubleRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -520,9 +519,9 @@ public void validateCornerCasesDoubleRestrictionsTest() { @Test public void validateEqualMinAndMaxDoubleRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -532,9 +531,9 @@ public void validateEqualMinAndMaxDoubleRestrictionTest() { @Test public void validateMixedMinAndMaxDoubleRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.DOUBLE); + tad.setType(KapuaTscalar.DOUBLE); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -544,9 +543,9 @@ public void validateMixedMinAndMaxDoubleRestrictionTest() { @Test public void validateWithCharTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("a, z"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.CHAR); + tad.setType(KapuaTscalar.CHAR); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -554,9 +553,9 @@ public void validateWithCharTypeWithoutRestrictionTest() { @Test public void validateWithCharTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("a, z"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.CHAR); + tad.setType(KapuaTscalar.CHAR); tad.setMax("b"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value z is out of range", message); @@ -565,9 +564,9 @@ public void validateWithCharTypeWitMaxRestrictionTest() { @Test public void validateWithCharTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("a, z"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.CHAR); + tad.setType(KapuaTscalar.CHAR); tad.setMin("b"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value a is out of range", message); @@ -576,9 +575,9 @@ public void validateWithCharTypeWitMinRestrictionTest() { @Test public void validateWithFloatTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -586,9 +585,9 @@ public void validateWithFloatTypeWithoutRestrictionTest() { @Test public void validateWithFloatTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -597,9 +596,9 @@ public void validateWithFloatTypeWitMaxRestrictionTest() { @Test public void validateWithFloatTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -608,9 +607,9 @@ public void validateWithFloatTypeWitMinRestrictionTest() { @Test public void validateMinAndMaxFloatRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -620,9 +619,9 @@ public void validateMinAndMaxFloatRestrictionTest() { @Test public void validateCornerCasesFloatRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -632,9 +631,9 @@ public void validateCornerCasesFloatRestrictionsTest() { @Test public void validateEqualMinAndMaxFloatRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -644,9 +643,9 @@ public void validateEqualMinAndMaxFloatRestrictionTest() { @Test public void validateMixedMinAndMaxFloatRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -656,9 +655,9 @@ public void validateMixedMinAndMaxFloatRestrictionTest() { @Test public void validateWithShortTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -666,9 +665,9 @@ public void validateWithShortTypeWithoutRestrictionTest() { @Test public void validateWithShortTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -677,9 +676,9 @@ public void validateWithShortTypeWitMaxRestrictionTest() { @Test public void validateWithShortTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -688,9 +687,9 @@ public void validateWithShortTypeWitMinRestrictionTest() { @Test public void validateMinAndMaxShortRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -700,9 +699,9 @@ public void validateMinAndMaxShortRestrictionTest() { @Test public void validateCornerCasesShortRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -712,9 +711,9 @@ public void validateCornerCasesShortRestrictionsTest() { @Test public void validateEqualMinAndMaxShortRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -724,9 +723,9 @@ public void validateEqualMinAndMaxShortRestrictionTest() { @Test public void validateMixedMinAndMaxShortRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.SHORT); + tad.setType(KapuaTscalar.SHORT); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -736,9 +735,9 @@ public void validateMixedMinAndMaxShortRestrictionTest() { @Test public void validateWithByteTypeWithoutRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); String message = valueTokenizer.validate(tad); Assert.assertEquals("", message); } @@ -746,9 +745,9 @@ public void validateWithByteTypeWithoutRestrictionTest() { @Test public void validateWithByteTypeWitMaxRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMax("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 99 is out of range", message); @@ -757,9 +756,9 @@ public void validateWithByteTypeWitMaxRestrictionTest() { @Test public void validateWithByteTypeWitMinRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMin("50"); String message = valueTokenizer.validate(tad); Assert.assertEquals("Value 12 is out of range", message); @@ -768,9 +767,9 @@ public void validateWithByteTypeWitMinRestrictionTest() { @Test public void validateMinAndMaxByteRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -780,9 +779,9 @@ public void validateMinAndMaxByteRestrictionTest() { @Test public void validateCornerCasesByteRestrictionsTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 100"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMin("10"); tad.setMax("100"); String message = valueTokenizer.validate(tad); @@ -792,9 +791,9 @@ public void validateCornerCasesByteRestrictionsTest() { @Test public void validateEqualMinAndMaxByteRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("10, 10"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMin("10"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -804,9 +803,9 @@ public void validateEqualMinAndMaxByteRestrictionTest() { @Test public void validateMixedMinAndMaxByteRestrictionTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("21"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.BYTE); + tad.setType(KapuaTscalar.BYTE); tad.setMin("100"); tad.setMax("10"); String message = valueTokenizer.validate(tad); @@ -816,9 +815,9 @@ public void validateMixedMinAndMaxByteRestrictionTest() { @Test public void validateTest() { ValueTokenizer valueTokenizer = new ValueTokenizer("12, 99"); - TadImpl tad = new TadImpl(); + KapuaTad tad = new KapuaTad(); tad.setCardinality(10); - tad.setType(TscalarImpl.FLOAT); + tad.setType(KapuaTscalar.FLOAT); KapuaToption option = null; tad.addOption(option); String message = valueTokenizer.validate(tad); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImplTest.java deleted file mode 100644 index 450970be709..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/KapuaMetatypeFactoryImplTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.commons.configuration.metatype; - -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class KapuaMetatypeFactoryImplTest { - - @Test - public void testKapuaTocd() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTocd()); - } - - @Test - public void testkapuaTad() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTad()); - } - - @Test - public void testKapuaTscalar() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTscalar("String")); - } - - @Test - public void testNewKapuaToption() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaToption()); - } - - @Test - public void testNewKapuaTicon() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTicon()); - } - - @Test - public void testNewKapuaTmetadata() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTmetadata()); - } - - @Test - public void testNewKapuaTdesignate() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTdesignate()); - } - - @Test - public void testNewKapuaTobject() { - KapuaMetatypeFactoryImpl factory = new KapuaMetatypeFactoryImpl(); - Assert.assertNotNull(factory.newKapuaTobject()); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImplTest.java deleted file mode 100644 index b4871efdfde..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ObjectFactoryImplTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.commons.configuration.metatype; - -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class ObjectFactoryImplTest { - - @Test - public void testCreateTicon() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTicon()); - } - - @Test - public void testCreateTattribute() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTattribute()); - } - - @Test - public void testCreateTmetadata() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTmetadata()); - } - - @Test - public void testCreateTdesignate() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTdesignate()); - } - - @Test - public void testCreateTad() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTad()); - } - - @Test - public void testCreateTobject() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTobject()); - } - - @Test - public void testCreateTocd() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createTocd()); - } - - @Test - public void testCreateToption() { - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createToption()); - } - - @Test - public void testCreateMetaData() { - TmetadataImpl value = new TmetadataImpl(); - ObjectFactoryImpl factoryImpl = new ObjectFactoryImpl(); - Assert.assertNotNull(factoryImpl.createMetaData(value)); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TadImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TadImplTest.java deleted file mode 100644 index 74097380ff6..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TadImplTest.java +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.commons.configuration.metatype; - -import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import javax.xml.namespace.QName; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -@Category(JUnitTests.class) -public class TadImplTest { - - @Before - public void createInstanceOfClasses() { - - tadImpl = new TadImpl(); - toption = new ToptionImpl(); - toption2 = new ToptionImpl(); - } - - TadImpl tadImpl; - ToptionImpl toption; - ToptionImpl toption2; - - @Test - public void getOptionToNullTest() { - tadImpl.getOption(); - Assert.assertTrue(tadImpl.getOption().isEmpty()); - } - - @Test - public void setAndGetOptionRegularTest() { - List option = new ArrayList<>(); - option.add(toption); - tadImpl.setOption(option); - Assert.assertEquals("tadImpl.option", option, tadImpl.getOption()); - } - - @Test - public void addAndGetOptionTest() { - List options = new ArrayList<>(); - options.add(toption); - options.add(toption2); - - tadImpl.addOption(toption); - tadImpl.addOption(toption2); - - Assert.assertEquals("tadImpl.option", options, tadImpl.getOption()); - } - - @Test - public void getAnyTest() { - Assert.assertTrue(tadImpl.getAny().isEmpty()); - } - - @Test - public void setAndGetAnyTest() { - List options = new ArrayList<>(); - options.add(toption); - options.add(toption2); - options.add(null); - tadImpl.setAny(options); - Assert.assertEquals("tadImpl.option", options, tadImpl.getAny()); - } - - @Test - public void setAndGetNameToNullTest() { - tadImpl.setName(null); - Assert.assertNull(tadImpl.getName()); - } - - @Test - public void setAndGetNameTest() { - String[] permittedValues = {"", "regularName", "49", "regular Name", "regular name with spaces", "!@#$%&*()_+/->,<", "NAME", "name123"}; - for (String value : permittedValues) { - tadImpl.setName(value); - Assert.assertTrue(tadImpl.getName().contains(value)); - } - } - - @Test - public void setAndGetDescriptionToNullTest() { - tadImpl.setDescription(null); - Assert.assertNull(tadImpl.getDescription()); - } - - @Test - public void setAndGetDescriptionTest() { - String[] permittedValues = {"", "regularDescription", "49", "regular Description", "regular description with spaces", "!@#$%&*()_+/->,<", "DESCRIPTION", "description123"}; - for (String value : permittedValues) { - tadImpl.setDescription(value); - Assert.assertTrue(tadImpl.getDescription().contains(value)); - } - } - - @Test - public void setAndGetIdToNullTest() { - tadImpl.setId(null); - Assert.assertNull(tadImpl.getId()); - } - - @Test - public void setAndGetIdTest() { - String[] permittedValues = {"", "regularId", "49", "regular Id", "regular id with spaces", "!@#$%&*()_+/->,<", "ID", "id123"}; - for (String value : permittedValues) { - tadImpl.setId(value); - Assert.assertTrue(tadImpl.getId().contains(value)); - } - } - - @Test - public void setAndGetTypeStringTest() { - tadImpl.setType(TscalarImpl.STRING); - Assert.assertEquals("tadImpl.type", TscalarImpl.STRING, tadImpl.getType()); - } - - @Test - public void setAndGetTypeLongTest() { - tadImpl.setType(TscalarImpl.LONG); - Assert.assertEquals("tadImpl.type", TscalarImpl.LONG, tadImpl.getType()); - } - - @Test - public void setAndGetTypeDoubleTest() { - tadImpl.setType(TscalarImpl.DOUBLE); - Assert.assertEquals("tadImpl.type", TscalarImpl.DOUBLE, tadImpl.getType()); - } - - @Test - public void setAndGetTypeFloatTest() { - tadImpl.setType(TscalarImpl.FLOAT); - Assert.assertEquals("tadImpl.type", TscalarImpl.FLOAT, tadImpl.getType()); - } - - @Test - public void setAndGetTypeIntegerTest() { - tadImpl.setType(TscalarImpl.INTEGER); - Assert.assertEquals("tadImpl.type", TscalarImpl.INTEGER, tadImpl.getType()); - } - - @Test - public void setAndGetTypeByteTest() { - tadImpl.setType(TscalarImpl.BYTE); - Assert.assertEquals("tadImpl.type", TscalarImpl.BYTE, tadImpl.getType()); - } - - @Test - public void setAndGetTypeCharTest() { - tadImpl.setType(TscalarImpl.CHAR); - Assert.assertEquals("tadImpl.type", TscalarImpl.CHAR, tadImpl.getType()); - } - - @Test - public void setAndGetTypeBooleanTest() { - tadImpl.setType(TscalarImpl.BOOLEAN); - Assert.assertEquals("tadImpl.type", TscalarImpl.BOOLEAN, tadImpl.getType()); - } - - @Test - public void setAndGetTypeShortTest() { - tadImpl.setType(TscalarImpl.SHORT); - Assert.assertEquals("tadImpl.type", TscalarImpl.SHORT, tadImpl.getType()); - } - - @Test - public void setAndGetTypePasswordTest() { - tadImpl.setType(TscalarImpl.PASSWORD); - Assert.assertEquals("tadImpl.type", TscalarImpl.PASSWORD, tadImpl.getType()); - } - - @Test - public void setAndGetCardinalityToNullTest() { - tadImpl.setCardinality(null); - Assert.assertEquals("tadImpl.cardinality", 0, (int) tadImpl.getCardinality()); - } - - @Test - public void setAndGetCardinalityRegularTest() { - int[] permittedValues = {1, 10, 100, 500, -2147483648, 2147483647, 0}; - for (int value : permittedValues) { - tadImpl.setCardinality(value); - Assert.assertEquals("tadImpl.cardinality", Integer.valueOf(value), tadImpl.getCardinality()); - } - } - - @Test - public void setAndGetMinToNullTest() { - tadImpl.setMin(null); - Assert.assertNull(tadImpl.getMin()); - } - - @Test - public void setAndGetMinTest() { - String[] permittedValues = {"", "regularMin", "49", "regular Min", "regular min with spaces", "!@#$%&*()_+/->,<", "MIN", "min123"}; - for (String value : permittedValues) { - tadImpl.setMin(value); - Assert.assertTrue(tadImpl.getMin().contains(value)); - } - } - - @Test - public void setAndGetMaxToNullTest() { - tadImpl.setMax(null); - Assert.assertNull(tadImpl.getMax()); - } - - @Test - public void setAndGetMaxTest() { - String[] permittedValues = {"", "regularMax", "49", "regular Max", "regular max with spaces", "!@#$%&*()_+/->,<", "MAX", "max123"}; - for (String value : permittedValues) { - tadImpl.setMax(value); - Assert.assertTrue(tadImpl.getMax().contains(value)); - } - } - - @Test - public void setAndGetDefaultToNullTest() { - tadImpl.setDefault(null); - Assert.assertNull(tadImpl.getDefault()); - } - - @Test - public void setAndGetDefaultTest() { - String[] permittedValues = {"", "regularDefault", "49", "regular Default", "regular default with spaces", "!@#$%&*()_+/->,<", "DEFAULT", "default123"}; - for (String value : permittedValues) { - tadImpl.setDefault(value); - Assert.assertTrue(tadImpl.getDefault().contains(value)); - } - } - - @Test - public void setIsRequiredToNullTest() { - tadImpl.setRequired(null); - Assert.assertTrue(tadImpl.isRequired()); - } - - @Test - public void setAndIsRequiredTest() { - boolean[] permittedValues = {false, true}; - for (boolean value : permittedValues) { - tadImpl.setRequired(value); - Assert.assertEquals("tadImpl.value", value, tadImpl.isRequired()); - } - } - - @Test - public void putAndGetOtherAttributeTest() { - Map expectedValues = new HashMap<>(); - - expectedValues.put(QName.valueOf("1"), "a"); - expectedValues.put(QName.valueOf("2"), "b"); - expectedValues.put(QName.valueOf("3"), "c"); - - tadImpl.putOtherAttribute(QName.valueOf("1"),"a"); - tadImpl.putOtherAttribute(QName.valueOf("2"),"b"); - tadImpl.putOtherAttribute(QName.valueOf("3"),"c"); - - Assert.assertEquals("tadImpl.attributes", expectedValues, tadImpl.getOtherAttributes()); - } - - @Test - public void getOtherAttributeTest() { - Assert.assertTrue(tadImpl.getOtherAttributes().isEmpty()); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TocdImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TocdImplTest.java deleted file mode 100644 index b2e3d458373..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TocdImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.commons.configuration.metatype; - -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import javax.xml.namespace.QName; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -@Category(JUnitTests.class) -public class TocdImplTest { - - @Before - public void createInstanceOfClasses() { - - tocdImpl = new TocdImpl(); - tadImpl = new TadImpl(); - tadImpl2 = new TadImpl(); - tadImpl3 = new TadImpl(); - ticon = new TiconImpl(); - ticon2 = new TiconImpl(); - } - - TocdImpl tocdImpl; - TadImpl tadImpl; - TadImpl tadImpl2; - TadImpl tadImpl3; - TiconImpl ticon; - TiconImpl ticon2; - - @Test - public void getADTest() { - Assert.assertTrue(tocdImpl.getAD().isEmpty()); - } - - @Test - public void setAndGetADTest() { - List expectedValues = new ArrayList<>(); - expectedValues.add(tadImpl); - tocdImpl.setAD(expectedValues); - Assert.assertEquals("tocdImpl.ad", expectedValues, tocdImpl.getAD()); - } - - @Test - public void addAndGetADTest() { - tocdImpl.addAD(tadImpl3); - tocdImpl.addAD(tadImpl2); - tocdImpl.getAD(); - Assert.assertTrue(tocdImpl.getAD().contains(tadImpl3) && tocdImpl.getAD().contains(tadImpl2)); - } - - @Test - public void getIconTest(){ - Assert.assertTrue(tocdImpl.getIcon().isEmpty()); - } - - @Test - public void setAndGetIconTest() { - List listOfObj = new ArrayList<>(); - listOfObj.add(ticon); - tocdImpl.setIcon(listOfObj); - Assert.assertEquals("tocdImpl.icon", listOfObj, tocdImpl.getIcon()); - } - - @Test - public void addAndGetIconTest() { - tocdImpl.addIcon(ticon); - tocdImpl.addIcon(ticon2); - tocdImpl.getIcon(); - Assert.assertTrue(tocdImpl.getIcon().contains(ticon) && tocdImpl.getIcon().contains(ticon2)); - } - - @Test - public void getAnyTest() { - Assert.assertTrue(tocdImpl.getAny().isEmpty()); - } - - @Test - public void setAndGetAnyTest() { - List options = new ArrayList<>(); - options.add(ticon); - options.add(ticon2); - tocdImpl.setAny(options); - Assert.assertEquals("tocdImpl.any", options, tocdImpl.getAny()); - } - - @Test - public void addAndGetAnyTest() { - tocdImpl.addAny(ticon); - tocdImpl.addAny(ticon2); - Assert.assertTrue(tocdImpl.getAny().contains(ticon) && tocdImpl.getAny().contains(ticon2)); - } - - @Test - public void setAndGetNameToNullTest() { - tocdImpl.setName(null); - Assert.assertNull(tocdImpl.getName()); - } - - @Test - public void setAndGetNameTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularName", "regular Name", "49", "regularName49", "REGULAR", "246465494135646120009090049684646496468456468496846464968496844"}; - for (String value : permittedValues) { - tocdImpl.setName(value); - Assert.assertTrue(tocdImpl.getName().contains(value)); - } - } - - @Test - public void setAndGetDescriptionToNullTest() { - tocdImpl.setDescription(null); - Assert.assertNull(tocdImpl.getDescription()); - } - - @Test - public void setAndGetDescriptionTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regular Description", "49", "regularDescription49", "DESCRIPTION", "246465494135646120009090049684646496468456468496846464968496844"}; - for (String value : permittedValues) { - tocdImpl.setDescription(value); - Assert.assertTrue(tocdImpl.getDescription().contains(value)); - } - } - - @Test - public void setAndGetIdToNullTest() { - tocdImpl.setId(null); - Assert.assertNull(tocdImpl.getId()); - } - - @Test - public void setAndGetIdTest() { - String[] permittedValues = {"", "regularId", "49", "regular Id", "regular id with spaces", "!@#$%&*()_+/->,<", "ID", "id123"}; - for (String value : permittedValues) { - tocdImpl.setId(value); - Assert.assertTrue(tocdImpl.getId().contains(value)); - } - } - - @Test - public void putAndGetOtherAttributeTest() { - Map expectedValues = new HashMap<>(); - - expectedValues.put(QName.valueOf("1"), "a"); - expectedValues.put(QName.valueOf("2"), "b"); - expectedValues.put(QName.valueOf("3"), "c"); - - tocdImpl.putOtherAttribute(QName.valueOf("1"),"a"); - tocdImpl.putOtherAttribute(QName.valueOf("2"),"b"); - tocdImpl.putOtherAttribute(QName.valueOf("3"),"c"); - - Assert.assertEquals("tocdImpl.otherAttributes", expectedValues, tocdImpl.getOtherAttributes()); - } - - @Test - public void getOtherAttributeTest() { - Assert.assertTrue(tocdImpl.getOtherAttributes().isEmpty()); - } - - @Test - public void testSetAndGetOtherAttribute() { - Map values = new HashMap<>(); - - values.put(QName.valueOf("1"), "a"); - values.put(QName.valueOf("2"), "b"); - values.put(QName.valueOf("3"), "c"); - - tocdImpl.setOtherAttributes(values); - Assert.assertEquals("tocdImpl.otherAttributes", values, tocdImpl.getOtherAttributes()); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/util/StringUtilTest.java b/commons/src/test/java/org/eclipse/kapua/commons/util/StringUtilTest.java index 30240825907..2f588029b87 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/util/StringUtilTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/util/StringUtilTest.java @@ -14,13 +14,12 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; -import org.eclipse.kapua.commons.configuration.metatype.Password; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) public class StringUtilTest { @@ -31,13 +30,15 @@ public void splitValuesNullTest() { @Test public void splitValuesTest() { - String[] delimiterStrings = {"string ,aa", "s,tring", ",string", "string,", "string,,", ",,string", "str,in,g", ",str,in,g,"}; - String[] escapeStrings = {"\\str \\ing", "\\string \\", "\\str ing", "s\\\\tring", " strin\\g", "st\\ring", "\\", "str\\ing", "stri\\ng", "strin\\g", "string\\", "\\\\"}; - String[] regularStrings = {"ss sss s", "string", "", "s tring", "s tri ng", "!@#$%^&*()_/.'|<>?|:1234567890"}; + String[] delimiterStrings = { "string ,aa", "s,tring", ",string", "string,", "string,,", ",,string", "str,in,g", ",str,in,g," }; + String[] escapeStrings = { "\\str \\ing", "\\string \\", "\\str ing", "s\\\\tring", " strin\\g", "st\\ring", "\\", "str\\ing", "stri\\ng", "strin\\g", "string\\", "\\\\" }; + String[] regularStrings = { "ss sss s", "string", "", "s tring", "s tri ng", "!@#$%^&*()_/.'|<>?|:1234567890" }; - String[][] expectedDelimiterStrings = {{"string", "aa"}, {"s", "tring"}, {"", "string"}, {"string", ""}, {"string", "", ""}, {"", "", "string"}, {"str", "in", "g"}, {"", "str", "in", "g", ""}}; - String[][] expectedEscapeStrings = {{"str ing"}, {"string"}, {"str ing"}, {"s\\tring"}, {"string"}, {"string"}, {""}, {"string"}, {"string"}, {"string"}, {"string"}, {"\\"}}; - String[][] expectedRegularStrings = {{"ss sss s"}, {"string"}, {""}, {"s tring"}, {"s tri ng"}, {"!@#$%^&*()_/.'|<>?|:1234567890"}}; + String[][] expectedDelimiterStrings = { { "string", "aa" }, { "s", "tring" }, { "", "string" }, { "string", "" }, { "string", "", "" }, { "", "", "string" }, { "str", "in", "g" }, + { "", "str", "in", "g", "" } }; + String[][] expectedEscapeStrings = { { "str ing" }, { "string" }, { "str ing" }, { "s\\tring" }, { "string" }, { "string" }, { "" }, { "string" }, { "string" }, { "string" }, { "string" }, + { "\\" } }; + String[][] expectedRegularStrings = { { "ss sss s" }, { "string" }, { "" }, { "s tring" }, { "s tri ng" }, { "!@#$%^&*()_/.'|<>?|:1234567890" } }; for (int i = 0; i < delimiterStrings.length; i++) { Assert.assertArrayEquals("Expected and actual values should be the same.", expectedDelimiterStrings[i], StringUtil.splitValues(delimiterStrings[i])); @@ -91,8 +92,8 @@ public void stringToValueIncorrectTypeTest() { @Test public void stringToValueStringTypeTest() throws Exception { - String[] stringArray = new String[]{"a", "ab", "abc", "string", "String", "STRING", "!#$%&'()=?*QWERTYUIOPŠĐASDFGHJKLČĆŽZXCVBNM;:_>Z⁄@‹›€°·‚Test±}{∏Ø’”ÆæÒÔÓÌ~«¿ˇÈ¯Ñ◊"}; - String[] type = new String[]{"sTring", "strinG", "string", "STRING"}; + String[] stringArray = new String[] { "a", "ab", "abc", "string", "String", "STRING", "!#$%&'()=?*QWERTYUIOPŠĐASDFGHJKLČĆŽZXCVBNM;:_>Z⁄@‹›€°·‚Test±}{∏Ø’”ÆæÒÔÓÌ~«¿ˇÈ¯Ñ◊" }; + String[] type = new String[] { "sTring", "strinG", "string", "STRING" }; // Positive tests for (int k = 0; k < stringArray.length; k++) { @@ -118,10 +119,10 @@ public void stringToValueStringTypeTest() throws Exception { @Test public void stringToValueBooleanTypeTest() throws Exception { - String booleanNegativeType[] = new String[]{"bOolean", "booleaN", "BOOLEAN"}; + String booleanNegativeType[] = new String[] { "bOolean", "booleaN", "BOOLEAN" }; - String booleanTrueValues[] = new String[]{"true", "True", "tRue", "truE", "TRUE"}; - String booleanFalseValues[] = new String[]{"false", "False", "faLse", "fals", "FALSE"}; + String booleanTrueValues[] = new String[] { "true", "True", "tRue", "truE", "TRUE" }; + String booleanFalseValues[] = new String[] { "false", "False", "faLse", "fals", "FALSE" }; // boolean.True positive tests for (int i = 0; i < booleanTrueValues.length; i++) { @@ -173,9 +174,9 @@ public void stringToValueBooleanTypeTest() throws Exception { @Test public void stringToValueByteTypeTest() throws Exception { - String[] byteTypeInvalidValues = new String[]{"bYte", "bytE", "BYTE"}; + String[] byteTypeInvalidValues = new String[] { "bYte", "bytE", "BYTE" }; String byteTypeValidValues = "Byte"; - Byte[] byteValues = new Byte[]{-128, 127, 0}; + Byte[] byteValues = new Byte[] { -128, 127, 0 }; // Byte positive tests for (int i = 0; i < byteValues.length; i++) { @@ -200,8 +201,8 @@ public void stringToValueByteTypeTest() throws Exception { @Test public void stringToValueCharTypeTest() throws Exception { - Character[] characterArray = new Character[]{'!', '#', '$', '%', '&', '(', ')', '=', '?', '*', '/', '1', '2', '3', '4', 'A', 'B', 'C', 'a', 'b', 'c'}; - String[] charInvalidType = new String[]{"cHar", "chaR", "Character", "cHaracter", "CHARACTER", "CHAR"}; + Character[] characterArray = new Character[] { '!', '#', '$', '%', '&', '(', ')', '=', '?', '*', '/', '1', '2', '3', '4', 'A', 'B', 'C', 'a', 'b', 'c' }; + String[] charInvalidType = new String[] { "cHar", "chaR", "Character", "cHaracter", "CHARACTER", "CHAR" }; String charValidType = "Char"; // Character positive tests @@ -228,8 +229,8 @@ public void stringToValueCharTypeTest() throws Exception { @Test public void stringToValueDoubleTypeTest() throws Exception { String doubleValidType = "Double"; - String[] doubleInvalidType = new String[]{"dOuble", "doublE", "DOUBLE"}; - Double[] doubleValues = new Double[]{-1.781273812737812731273129312, 1.781273812737812731273129312, 0.0}; + String[] doubleInvalidType = new String[] { "dOuble", "doublE", "DOUBLE" }; + Double[] doubleValues = new Double[] { -1.781273812737812731273129312, 1.781273812737812731273129312, 0.0 }; // Double positive tests for (int i = 0; i < doubleValues.length; i++) { @@ -255,8 +256,8 @@ public void stringToValueDoubleTypeTest() throws Exception { @Test public void stringToValueFloatTypeTest() throws Exception { String floatValidType = "Float"; - String[] floatinvalidType = new String[]{"fLoat", "floaT", "FLOAT"}; - Float[] floatValues = new Float[]{-1.7811233F, 1.7811233F, 0F}; + String[] floatinvalidType = new String[] { "fLoat", "floaT", "FLOAT" }; + Float[] floatValues = new Float[] { -1.7811233F, 1.7811233F, 0F }; // Float positive tests for (int i = 0; i < floatValues.length; i++) { @@ -282,8 +283,8 @@ public void stringToValueFloatTypeTest() throws Exception { @Test public void stringToValueIntegerTypeTest() throws Exception { String integerValidType = "Integer"; - String[] integerInvalidType = new String[]{"iNteger", "integeR", "INTEGER"}; - Integer[] integerValues = new Integer[]{-2147483648, 2147483647, 0}; + String[] integerInvalidType = new String[] { "iNteger", "integeR", "INTEGER" }; + Integer[] integerValues = new Integer[] { -2147483648, 2147483647, 0 }; // Float positive tests for (int i = 0; i < integerValues.length; i++) { @@ -309,8 +310,8 @@ public void stringToValueIntegerTypeTest() throws Exception { @Test public void stringToValueLongTypeTest() throws Exception { String longValidType = "Long"; - String[] longInvalidType = new String[]{"lOng", "lonG", "LONG"}; - Long[] longValues = new Long[]{-922337203685477600L, 922337203685477600L, 0L}; + String[] longInvalidType = new String[] { "lOng", "lonG", "LONG" }; + Long[] longValues = new Long[] { -922337203685477600L, 922337203685477600L, 0L }; // Long positive tests for (int i = 0; i < longValues.length; i++) { @@ -336,8 +337,8 @@ public void stringToValueLongTypeTest() throws Exception { @Test public void stringToValueShortTypeTest() throws Exception { String shortValidType = "Short"; - String[] shortInvalidType = new String[]{"sHort", "shorT", "SHORT"}; - Short[] shortValues = new Short[]{-32768, 32767, 0}; + String[] shortInvalidType = new String[] { "sHort", "shorT", "SHORT" }; + Short[] shortValues = new Short[] { -32768, 32767, 0 }; // Short positive tests for (int i = 0; i < shortValues.length; i++) { @@ -363,17 +364,18 @@ public void stringToValueShortTypeTest() throws Exception { @Test public void stringToValuePasswordTypeTest() throws Exception { String passwordValidType = "Password"; - String[] passwordInvalidType = new String[]{"pAssword", "passworD", "PASSWORD"}; + String[] passwordInvalidType = new String[] { "pAssword", "passworD", "PASSWORD" }; Password password1 = new Password("a"); Password password2 = new Password("aaaaaaaaaaaaaaaaaaaa"); Password password3 = new Password("⁄@‹›€°·‚Short}{∏ÆæÒ”"); - Object[] passwordValues = new Object[]{password1, password2, password3}; + Object[] passwordValues = new Object[] { password1, password2, password3 }; // Password [] passwordValues = new Password[]{"a", "aaaaaaaaaaaaaaaaaaaa", "⁄@‹›€°·‚Short}{∏ÆæÒ”"}; // Password positive tests for (int i = 0; i < passwordValues.length; i++) { try { - Assert.assertEquals("Expected and actual values should be the same.", String.valueOf(passwordValues[i]), StringUtil.stringToValue(passwordValidType, String.valueOf(passwordValues[i])).toString()); + Assert.assertEquals("Expected and actual values should be the same.", String.valueOf(passwordValues[i]), + StringUtil.stringToValue(passwordValidType, String.valueOf(passwordValues[i])).toString()); } catch (Exception e) { Assert.fail("No exception expected for" + passwordValues[i]); } @@ -398,7 +400,8 @@ public void valueToStringNullTest() { @Test public void valueToStringTypeStringTest() { - String[] stringValues = new String[]{"", "s", "string", "STRING", "abcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweq"}; + String[] stringValues = new String[] { "", "s", "string", "STRING", + "abcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweqabcdefgrtqyweuqywueuqeuuqweq" }; for (int i = 0; i < stringValues.length; i++) { try { @@ -411,7 +414,7 @@ public void valueToStringTypeStringTest() { @Test public void valueToStringTypeLongTest() { - Long[] longValues = new Long[]{0L, 922337203685477600L, -922337203685477600L}; + Long[] longValues = new Long[] { 0L, 922337203685477600L, -922337203685477600L }; for (int i = 0; i < longValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", longValues[i].toString(), StringUtil.valueToString(longValues[i])); @@ -423,7 +426,7 @@ public void valueToStringTypeLongTest() { @Test public void valueToStringTypeDoubleTest() { - Double[] doubleValues = new Double[]{0.0, 1.781273812737812731273129312, -1.781273812737812731273129312}; + Double[] doubleValues = new Double[] { 0.0, 1.781273812737812731273129312, -1.781273812737812731273129312 }; for (int i = 0; i < doubleValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", doubleValues[i].toString(), StringUtil.valueToString(doubleValues[i])); @@ -435,7 +438,7 @@ public void valueToStringTypeDoubleTest() { @Test public void valueToStringTypeFloatTest() { - Float[] floatValues = new Float[]{0F, 1.781123312321311231F, -1.7811233323123F}; + Float[] floatValues = new Float[] { 0F, 1.781123312321311231F, -1.7811233323123F }; for (int i = 0; i < floatValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", floatValues[i].toString(), StringUtil.valueToString(floatValues[i])); @@ -447,7 +450,7 @@ public void valueToStringTypeFloatTest() { @Test public void valueToStringTypeIntegerTest() { - Integer[] integerValues = new Integer[]{2147483647, -2147483647, 0}; + Integer[] integerValues = new Integer[] { 2147483647, -2147483647, 0 }; for (int i = 0; i < integerValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", integerValues[i].toString(), StringUtil.valueToString(integerValues[i])); @@ -459,7 +462,7 @@ public void valueToStringTypeIntegerTest() { @Test public void valueToStringTypeByteTest() { - Byte[] byteValues = new Byte[]{-128, 127, 0}; + Byte[] byteValues = new Byte[] { -128, 127, 0 }; for (int i = 0; i < byteValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", byteValues[i].toString(), StringUtil.valueToString(byteValues[i])); @@ -471,7 +474,7 @@ public void valueToStringTypeByteTest() { @Test public void valueToStringTypeCharacterTest() { - Character[] characterValues = new Character[]{'a', '1', '@'}; + Character[] characterValues = new Character[] { 'a', '1', '@' }; for (int i = 0; i < characterValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", characterValues[i].toString(), StringUtil.valueToString(characterValues[i])); @@ -483,7 +486,7 @@ public void valueToStringTypeCharacterTest() { @Test public void valueToStringTypeBooleanTest() { - Boolean[] booleanValues = new Boolean[]{Boolean.TRUE, Boolean.FALSE}; + Boolean[] booleanValues = new Boolean[] { Boolean.TRUE, Boolean.FALSE }; for (int i = 0; i < booleanValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", booleanValues[i].toString(), StringUtil.valueToString(booleanValues[i])); @@ -495,7 +498,7 @@ public void valueToStringTypeBooleanTest() { @Test public void valueToStringTypeShortTest() { - Short[] shortValues = new Short[]{-32768, 32767, 0}; + Short[] shortValues = new Short[] { -32768, 32767, 0 }; for (int i = 0; i < shortValues.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", shortValues[i].toString(), StringUtil.valueToString(shortValues[i])); @@ -510,7 +513,7 @@ public void valueToStringTypePassword() { Password password1 = new Password("abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPRQSTUVXYZ"); Password password2 = new Password("01234567890"); Password password3 = new Password("!#$%&'()=?*/+-.,<>;:_⁄@‹›€°·‚Password±}{∏¿ˇÈ~"); - Password[] passwordValue = new Password[]{password1, password2, password3}; + Password[] passwordValue = new Password[] { password1, password2, password3 }; for (int i = 0; i < passwordValue.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", passwordValue[i].toString(), StringUtil.valueToString(passwordValue[i])); @@ -522,63 +525,63 @@ public void valueToStringTypePassword() { @Test public void valueToStringTypeStringArrayTest() { - String[] stringArray = new String[]{null, "string", "string2", "string3"}; + String[] stringArray = new String[] { null, "string", "string2", "string3" }; String resultString = "string,string2,string3"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(stringArray)); } @Test public void valueToStringTypeLongArrayTest() { - Long[] longArray = new Long[]{null, 0L, 1L, 12L, 123L, 1234L, 12345L, 123456L, 1234567L, 922337203685477600L, -1L, -12L, -123L, -1234L, -12345L, -922337203685477600L}; + Long[] longArray = new Long[] { null, 0L, 1L, 12L, 123L, 1234L, 12345L, 123456L, 1234567L, 922337203685477600L, -1L, -12L, -123L, -1234L, -12345L, -922337203685477600L }; String resultString = "0,1,12,123,1234,12345,123456,1234567,922337203685477600,-1,-12,-123,-1234,-12345,-922337203685477600"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(longArray)); } @Test public void valueToStringTypeDoubleArrayTest() { - Double[] doubleArray = new Double[]{null, 0.0, 1.1, 1.23, 1.234, 1.2345, 1.23456, 1.234567, 1.7812738127378127}; + Double[] doubleArray = new Double[] { null, 0.0, 1.1, 1.23, 1.234, 1.2345, 1.23456, 1.234567, 1.7812738127378127 }; String resultString = "0.0,1.1,1.23,1.234,1.2345,1.23456,1.234567,1.7812738127378127"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(doubleArray)); } @Test public void valueToStringTypeFloatArrayTest() { - Float[] floatArray = new Float[]{null, 0.0F, 1.0F, 1.2F, 12.34F, 123.45F, 1234.56F, 12345.6789F, 1.7811233F, -0.0F, -1.23F, -12345.12345F}; + Float[] floatArray = new Float[] { null, 0.0F, 1.0F, 1.2F, 12.34F, 123.45F, 1234.56F, 12345.6789F, 1.7811233F, -0.0F, -1.23F, -12345.12345F }; String resultString = "0.0,1.0,1.2,12.34,123.45,1234.56,12345.679,1.7811233,-0.0,-1.23,-12345.123"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(floatArray)); } @Test public void valueToStringTypeIntegerArrayTest() { - Integer[] integerArray = new Integer[]{null, 0, 1, 123, 12345, 12345, 32678, -0, -1, -12, -1234, -12345, -32676}; + Integer[] integerArray = new Integer[] { null, 0, 1, 123, 12345, 12345, 32678, -0, -1, -12, -1234, -12345, -32676 }; String resultString = "0,1,123,12345,12345,32678,0,-1,-12,-1234,-12345,-32676"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(integerArray)); } @Test public void valueToStringTypeByteArrayTest() { - Byte[] byteArray = new Byte[]{null, 0, 1, 12, 123, 127, -0, -1, -12, -123, -128}; + Byte[] byteArray = new Byte[] { null, 0, 1, 12, 123, 127, -0, -1, -12, -123, -128 }; String resultString = "0,1,12,123,127,0,-1,-12,-123,-128"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(byteArray)); } @Test public void valueToStringTypeCharacterArrayTest() { - Character[] characterArray = new Character[]{null, 'a', 'A', 'z', 'Z', '@', '!'}; + Character[] characterArray = new Character[] { null, 'a', 'A', 'z', 'Z', '@', '!' }; String resultString = "a,A,z,Z,@,!"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(characterArray)); } @Test public void valueToStringTypeBooleanArrayTest() { - Boolean[] booleanArray = new Boolean[]{null, Boolean.FALSE, Boolean.TRUE}; + Boolean[] booleanArray = new Boolean[] { null, Boolean.FALSE, Boolean.TRUE }; String resultString = "false,true"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(booleanArray)); } @Test public void valueToStringTypeShortArrayTest() { - Short[] shortArray = new Short[]{null, 0, 1, 12, 123, 1234, 32767, -32768, -1234, -123, -12, -1, -0}; + Short[] shortArray = new Short[] { null, 0, 1, 12, 123, 1234, 32767, -32768, -1234, -123, -12, -1, -0 }; String resultString = "0,1,12,123,1234,32767,-32768,-1234,-123,-12,-1,0"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(shortArray)); } @@ -588,7 +591,7 @@ public void valueToStringTypePasswordArrayTest() { Password password1 = new Password("abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPRQSTUVXYZ"); Password password2 = new Password("01234567890"); Password password3 = new Password("!#$%&'()=?*/+-.<>;:_⁄@‹›€°·‚Password±}{∏¿ˇÈ~"); - Password[] passwordArray = new Password[]{null, password1, password2, password3}; + Password[] passwordArray = new Password[] { null, password1, password2, password3 }; String resultString = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPRQSTUVXYZ,01234567890,!#$%&'()=?*/+-.<>;:_⁄@‹›€°·‚Password±}{∏¿ˇÈ~"; Assert.assertEquals("Expected and actual values should be the same.", resultString, StringUtil.valueToString(passwordArray)); } @@ -617,8 +620,8 @@ public void escapeStringNullTest() { @Test public void unescapeStringTest() { - String[] stringArray = new String[]{" string", "string ", " str ing", "str ing ", "str ing", "str\\ ing", "str\\\\\\,ing", " str\\ \\, ing "}; - String[] resultString = new String[]{"string", "string", "str ing", "str ing", "str ing", "str ing", "str,ing", "str , ing"}; + String[] stringArray = new String[] { " string", "string ", " str ing", "str ing ", "str ing", "str\\ ing", "str\\\\\\,ing", " str\\ \\, ing " }; + String[] resultString = new String[] { "string", "string", "str ing", "str ing", "str ing", "str ing", "str,ing", "str , ing" }; for (int i = 0; i < stringArray.length; i++) { try { Assert.assertEquals("Expected and actual values should be the same.", resultString[i], StringUtil.unescapeString(stringArray[i])); diff --git a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java index 36184b8f23e..8f56d5e7f48 100644 --- a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java +++ b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java @@ -12,12 +12,26 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.account.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.common.collect.Sets; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.concurrent.Callable; + +import javax.xml.namespace.QName; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.imaging.ImageFormat; import org.apache.commons.imaging.ImageFormats; @@ -38,13 +52,13 @@ import org.eclipse.kapua.app.console.module.api.shared.model.GwtGroupedNVPair; import org.eclipse.kapua.app.console.module.api.shared.model.GwtXSRFToken; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; -import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; import org.eclipse.kapua.commons.util.ThrowingRunnable; import org.eclipse.kapua.locator.KapuaLocator; +import org.eclipse.kapua.model.config.metatype.EmptyTocd; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTicon; import org.eclipse.kapua.model.config.metatype.KapuaTocd; @@ -77,24 +91,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; +import com.google.common.collect.Sets; /** * The server side implementation of the RPC service. @@ -207,7 +209,7 @@ public ListLoadResult getAccountInfo(String scopeIdString, Str try { final Account account = ACCOUNT_SERVICE.find(scopeId, accountId); -//TODO: #LAYER_VIOLATION - user lookup should not be done here + //TODO: #LAYER_VIOLATION - user lookup should not be done here UserListResult userListResult = KapuaSecurityUtils.doPrivileged(new Callable() { @Override @@ -490,7 +492,7 @@ public List findServiceConfigurations(String scopeId) throws strValues.add(v.toString()); } } - gwtParam.setValues(strValues.toArray(new String[]{})); + gwtParam.setValues(strValues.toArray(new String[] {})); } } } diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementServiceImpl.java index 241de57aeaa..5c7e51a348a 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementServiceImpl.java @@ -12,8 +12,28 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLConnection; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.imaging.ImageFormat; import org.apache.commons.imaging.ImageFormats; @@ -42,13 +62,13 @@ import org.eclipse.kapua.app.console.module.device.shared.model.management.packages.GwtPackageOperation; import org.eclipse.kapua.app.console.module.device.shared.model.management.packages.GwtPackageUninstallRequest; import org.eclipse.kapua.app.console.module.device.shared.service.GwtDeviceManagementService; -import org.eclipse.kapua.commons.configuration.metatype.Password; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTicon; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.bundle.DeviceBundle; import org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService; @@ -83,26 +103,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.StringTokenizer; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; /** * The server side implementation of the Device RPC service. @@ -372,7 +374,7 @@ public int compare(DeviceComponentConfiguration arg0, DeviceComponentConfigurati strValues.add(v.toString()); } } - gwtParam.setValues(strValues.toArray(new String[]{})); + gwtParam.setValues(strValues.toArray(new String[] {})); } } } @@ -462,7 +464,8 @@ public GwtDeviceConfigurationStoreSettings getApplicationSettings(String scopeId deviceConfigurationStoreSettings = DEVICE_CONFIGURATION_STORE_SERVICE.getApplicationSettings(scopeId, deviceId); gwtDeviceConfigurationStoreSettings = new GwtDeviceConfigurationStoreSettings(); - gwtDeviceConfigurationStoreSettings.setStoreEnablementPolicy(GwtDeviceConfigurationStoreSettings.GwtDeviceConfigurationStoreEnablementPolicy.valueOf(deviceConfigurationStoreSettings.getEnablementPolicy().name())); + gwtDeviceConfigurationStoreSettings.setStoreEnablementPolicy( + GwtDeviceConfigurationStoreSettings.GwtDeviceConfigurationStoreEnablementPolicy.valueOf(deviceConfigurationStoreSettings.getEnablementPolicy().name())); return gwtDeviceConfigurationStoreSettings; } catch (Throwable t) { throw KapuaExceptionHandler.buildExceptionFromError(t); @@ -470,7 +473,8 @@ public GwtDeviceConfigurationStoreSettings getApplicationSettings(String scopeId } @Override - public void setApplicationSettings(GwtXSRFToken xsrfToken, String scopeIdString, String deviceIdString, GwtDeviceConfigurationStoreSettings gwtDeviceConfigurationStoreSettings) throws GwtKapuaException { + public void setApplicationSettings(GwtXSRFToken xsrfToken, String scopeIdString, String deviceIdString, GwtDeviceConfigurationStoreSettings gwtDeviceConfigurationStoreSettings) + throws GwtKapuaException { checkXSRFToken(xsrfToken); try { @@ -677,36 +681,36 @@ private Object getObjectValue(GwtConfigParameter gwtConfigParam, String strValue if (strValue != null) { GwtConfigParameterType gwtType = gwtConfigParam.getType(); switch (gwtType) { - case LONG: - objValue = Long.parseLong(strValue); - break; - case DOUBLE: - objValue = Double.parseDouble(strValue); - break; - case FLOAT: - objValue = Float.parseFloat(strValue); - break; - case INTEGER: - objValue = Integer.parseInt(strValue); - break; - case SHORT: - objValue = Short.parseShort(strValue); - break; - case BYTE: - objValue = Byte.parseByte(strValue); - break; - case BOOLEAN: - objValue = Boolean.parseBoolean(strValue); - break; - case PASSWORD: - objValue = new Password(strValue); - break; - case CHAR: - objValue = strValue.charAt(0); - break; - case STRING: - objValue = strValue; - break; + case LONG: + objValue = Long.parseLong(strValue); + break; + case DOUBLE: + objValue = Double.parseDouble(strValue); + break; + case FLOAT: + objValue = Float.parseFloat(strValue); + break; + case INTEGER: + objValue = Integer.parseInt(strValue); + break; + case SHORT: + objValue = Short.parseShort(strValue); + break; + case BYTE: + objValue = Byte.parseByte(strValue); + break; + case BOOLEAN: + objValue = Boolean.parseBoolean(strValue); + break; + case PASSWORD: + objValue = new Password(strValue); + break; + case CHAR: + objValue = strValue.charAt(0); + break; + case STRING: + objValue = strValue; + break; } } return objValue; @@ -716,79 +720,76 @@ private Object[] getObjectValue(GwtConfigParameter gwtConfigParam, String[] defa List values = new ArrayList(); GwtConfigParameterType type = gwtConfigParam.getType(); switch (type) { - case BOOLEAN: - for (String value : defaultValues) { - values.add(Boolean.valueOf(value)); - } - return values.toArray(); + case BOOLEAN: + for (String value : defaultValues) { + values.add(Boolean.valueOf(value)); + } + return values.toArray(); - case BYTE: - for (String value : defaultValues) { - values.add(Byte.valueOf(value)); - } - return values.toArray(); + case BYTE: + for (String value : defaultValues) { + values.add(Byte.valueOf(value)); + } + return values.toArray(); - case CHAR: - for (String value : defaultValues) { - values.add(value.charAt(0)); - } - return values.toArray(); + case CHAR: + for (String value : defaultValues) { + values.add(value.charAt(0)); + } + return values.toArray(); - case DOUBLE: - for (String value : defaultValues) { - values.add(Double.valueOf(value)); - } - return values.toArray(); + case DOUBLE: + for (String value : defaultValues) { + values.add(Double.valueOf(value)); + } + return values.toArray(); - case FLOAT: - for (String value : defaultValues) { - values.add(Float.valueOf(value)); - } - return values.toArray(); + case FLOAT: + for (String value : defaultValues) { + values.add(Float.valueOf(value)); + } + return values.toArray(); - case INTEGER: - for (String value : defaultValues) { - values.add(Integer.valueOf(value)); - } - return values.toArray(); + case INTEGER: + for (String value : defaultValues) { + values.add(Integer.valueOf(value)); + } + return values.toArray(); - case LONG: - for (String value : defaultValues) { - values.add(Long.valueOf(value)); - } - return values.toArray(); + case LONG: + for (String value : defaultValues) { + values.add(Long.valueOf(value)); + } + return values.toArray(); - case SHORT: - for (String value : defaultValues) { - values.add(Short.valueOf(value)); - } - return values.toArray(); + case SHORT: + for (String value : defaultValues) { + values.add(Short.valueOf(value)); + } + return values.toArray(); - case PASSWORD: - for (String value : defaultValues) { - values.add(new Password(value)); - } - return values.toArray(); + case PASSWORD: + for (String value : defaultValues) { + values.add(new Password(value)); + } + return values.toArray(); - case STRING: - default: - return defaultValues; + case STRING: + default: + return defaultValues; } } /** - * Checks the source of the icon. - * The component config icon can be one of the well known icon (i.e. MqttDataTransport icon) - * as well as an icon loaded from external source with an HTTP link. + * Checks the source of the icon. The component config icon can be one of the well known icon (i.e. MqttDataTransport icon) as well as an icon loaded from external source with an HTTP link. *

- * We need to filter HTTP link to protect the console page and also to have content always served from - * EC console. Otherwise browsers can alert the user that content is served from domain different from - * *.everyware-cloud.com and over insicure connection. + * We need to filter HTTP link to protect the console page and also to have content always served from EC console. Otherwise browsers can alert the user that content is served from domain + * different from *.everyware-cloud.com and over insicure connection. *

- * To avoid this we will download the image locally on the server temporary directory and give back the page - * a token URL to get the file. + * To avoid this we will download the image locally on the server temporary directory and give back the page a token URL to get the file. * - * @param icon The icon from the OCD of the component configuration. + * @param icon + * The icon from the OCD of the component configuration. */ private void checkIconResource(KapuaTicon icon) { ConsoleSetting config = ConsoleSetting.getInstance(); diff --git a/console/web/src/main/java/org/eclipse/kapua/app/console/ConsoleJAXBContextProvider.java b/console/web/src/main/java/org/eclipse/kapua/app/console/ConsoleJAXBContextProvider.java index 0bdd7251e84..507ec9735e3 100644 --- a/console/web/src/main/java/org/eclipse/kapua/app/console/ConsoleJAXBContextProvider.java +++ b/console/web/src/main/java/org/eclipse/kapua/app/console/ConsoleJAXBContextProvider.java @@ -12,8 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; + import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.rest.model.IsJobRunningResponse; import org.eclipse.kapua.commons.rest.model.errors.CleanJobDataExceptionInfo; import org.eclipse.kapua.commons.rest.model.errors.ExceptionInfo; @@ -43,7 +47,6 @@ import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundle; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundles; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration; @@ -102,10 +105,6 @@ import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.MarshallerProperties; -import javax.xml.bind.JAXBContext; -import java.util.HashMap; -import java.util.Map; - public class ConsoleJAXBContextProvider implements JAXBContextProvider { private JAXBContext context; @@ -117,7 +116,7 @@ public JAXBContext getJAXBContext() throws KapuaException { Map properties = new HashMap(1); properties.put(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true); - context = JAXBContextFactory.createContext(new Class[]{ + context = JAXBContextFactory.createContext(new Class[] { // REST API exception models ThrowableInfo.class, ExceptionInfo.class, @@ -204,8 +203,6 @@ public JAXBContext getJAXBContext() throws KapuaException { KapuaTicon.class, KapuaToption.class, KapuaTmetadata.class, - TscalarImpl.class, - MetatypeXmlRegistry.class, // Device Management Assets DeviceAssets.class, diff --git a/consumer/lifecycle-app/src/main/java/org/eclipse/kapua/consumer/lifecycle/LifecycleJAXBContextProvider.java b/consumer/lifecycle-app/src/main/java/org/eclipse/kapua/consumer/lifecycle/LifecycleJAXBContextProvider.java index 2594c9dba1a..90c25f1f136 100644 --- a/consumer/lifecycle-app/src/main/java/org/eclipse/kapua/consumer/lifecycle/LifecycleJAXBContextProvider.java +++ b/consumer/lifecycle-app/src/main/java/org/eclipse/kapua/consumer/lifecycle/LifecycleJAXBContextProvider.java @@ -18,7 +18,6 @@ import javax.xml.bind.JAXBContext; import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.rest.model.errors.CleanJobDataExceptionInfo; import org.eclipse.kapua.commons.rest.model.errors.JobAlreadyRunningExceptionInfo; import org.eclipse.kapua.commons.rest.model.errors.JobEngineExceptionInfo; @@ -47,7 +46,7 @@ import org.eclipse.kapua.model.config.metatype.KapuaTobject; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundle; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundles; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration; @@ -98,11 +97,10 @@ public JAXBContext getJAXBContext() throws KapuaException { KapuaTocd.class, KapuaTad.class, KapuaTicon.class, - TscalarImpl.class, + KapuaTscalar.class, KapuaToption.class, KapuaTdesignate.class, KapuaTobject.class, - MetatypeXmlRegistry.class, // Kapua Service Event ServiceEvent.class, diff --git a/consumer/telemetry-app/src/main/java/org/eclipse/kapua/consumer/telemetry/TelemetryJAXBContextProvider.java b/consumer/telemetry-app/src/main/java/org/eclipse/kapua/consumer/telemetry/TelemetryJAXBContextProvider.java index 4a5285ed66a..6189c5f0834 100644 --- a/consumer/telemetry-app/src/main/java/org/eclipse/kapua/consumer/telemetry/TelemetryJAXBContextProvider.java +++ b/consumer/telemetry-app/src/main/java/org/eclipse/kapua/consumer/telemetry/TelemetryJAXBContextProvider.java @@ -18,7 +18,6 @@ import javax.xml.bind.JAXBContext; import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; @@ -32,7 +31,7 @@ import org.eclipse.kapua.model.config.metatype.KapuaTobject; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.MarshallerProperties; import org.slf4j.Logger; @@ -56,11 +55,10 @@ public JAXBContext getJAXBContext() throws KapuaException { KapuaTocd.class, KapuaTad.class, KapuaTicon.class, - TscalarImpl.class, + KapuaTscalar.class, KapuaToption.class, KapuaTdesignate.class, KapuaTobject.class, - MetatypeXmlRegistry.class, // KapuaEvent ServiceEvent.class, diff --git a/qa/common/src/main/java/org/eclipse/kapua/qa/common/TestJAXBContextProvider.java b/qa/common/src/main/java/org/eclipse/kapua/qa/common/TestJAXBContextProvider.java index 7d176045afa..100dab7953a 100644 --- a/qa/common/src/main/java/org/eclipse/kapua/qa/common/TestJAXBContextProvider.java +++ b/qa/common/src/main/java/org/eclipse/kapua/qa/common/TestJAXBContextProvider.java @@ -12,8 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.qa.common; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; + import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.rest.model.errors.ExceptionInfo; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; @@ -32,7 +36,6 @@ import org.eclipse.kapua.model.config.metatype.KapuaTobject; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; import org.eclipse.kapua.service.authentication.token.AccessToken; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundle; import org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundles; @@ -93,13 +96,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.bind.JAXBContext; -import java.util.HashMap; -import java.util.Map; - /** - * JAXB context provided for proper (un)marshalling of interface annotated classes. - * This particular implementation is used only in unit and integration tests. + * JAXB context provided for proper (un)marshalling of interface annotated classes. This particular implementation is used only in unit and integration tests. *

* Application and interfaces have their own implementation of provider. */ @@ -112,16 +110,14 @@ public class TestJAXBContextProvider implements JAXBContextProvider { @Override public JAXBContext getJAXBContext() throws KapuaException { if (context == null) { - Class[] classes = new Class[]{ + Class[] classes = new Class[] { KapuaTmetadata.class, KapuaTocd.class, KapuaTad.class, KapuaTicon.class, - TscalarImpl.class, KapuaToption.class, KapuaTdesignate.class, KapuaTobject.class, - MetatypeXmlRegistry.class, ExceptionInfo.class, // KapuaEvent diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/KapuaTscalarAdapterTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/KapuaTscalarAdapterTest.java index 009ab32d4bb..d5638ca1ef5 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/KapuaTscalarAdapterTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/KapuaTscalarAdapterTest.java @@ -12,7 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.integration.misc; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.kapua.model.config.metatype.KapuaTscalarAdapter; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -20,22 +20,21 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) public class KapuaTscalarAdapterTest { KapuaTscalarAdapter kapuaTscalarAdapter; - TscalarImpl[] kapuaTscalar; + KapuaTscalar[] kapuaTscalar; String[] stringValue; String[] invalidStringValue; @Before public void initialize() { kapuaTscalarAdapter = new KapuaTscalarAdapter(); - kapuaTscalar = new TscalarImpl[]{TscalarImpl.STRING, TscalarImpl.LONG, TscalarImpl.DOUBLE, TscalarImpl.FLOAT, TscalarImpl.INTEGER, - TscalarImpl.BYTE, TscalarImpl.CHAR, TscalarImpl.BOOLEAN, TscalarImpl.SHORT, TscalarImpl.PASSWORD}; - stringValue = new String[]{"String", "Long", "Double", "Float", "Integer", "Byte", "Char", "Boolean", "Short", "Password"}; - invalidStringValue = new String[]{null, "Invalid Value"}; + kapuaTscalar = new KapuaTscalar[] { KapuaTscalar.STRING, KapuaTscalar.LONG, KapuaTscalar.DOUBLE, KapuaTscalar.FLOAT, KapuaTscalar.INTEGER, + KapuaTscalar.BYTE, KapuaTscalar.CHAR, KapuaTscalar.BOOLEAN, KapuaTscalar.SHORT, KapuaTscalar.PASSWORD }; + stringValue = new String[] { "String", "Long", "Double", "Float", "Integer", "Byte", "Char", "Boolean", "Short", "Password" }; + invalidStringValue = new String[] { null, "Invalid Value" }; } @Test @@ -53,7 +52,7 @@ public void marshalNullParameterTest() throws Exception { @Test public void unmarshalTest() throws Exception { - TscalarImpl[] expectedTscalars = kapuaTscalar; + KapuaTscalar[] expectedTscalars = kapuaTscalar; for (int i = 0; i < stringValue.length; i++) { Assert.assertEquals("Expected and actual values should be the same.", expectedTscalars[i], kapuaTscalarAdapter.unmarshal(stringValue[i])); } diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/MetatypeXmlRegistryTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/MetatypeXmlRegistryTest.java deleted file mode 100644 index 2de732a820d..00000000000 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/MetatypeXmlRegistryTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.integration.misc; - -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; -import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; -import org.eclipse.kapua.model.config.metatype.KapuaTobject; - -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class MetatypeXmlRegistryTest { - - MetatypeXmlRegistry metatypeXmlRegistry; - - @Before - public void createInstanceOfClass() { - metatypeXmlRegistry = new MetatypeXmlRegistry(); - } - - @Test - public void newKapuaTocdTest() { - Assert.assertThat("Instance of KapuaTocd expected.", metatypeXmlRegistry.newKapuaTocd(), IsInstanceOf.instanceOf(KapuaTocd.class)); - } - - @Test - public void newKapuaTadTest() { - Assert.assertThat("Instance of KapuaTad expected.", metatypeXmlRegistry.newKapuaTad(), IsInstanceOf.instanceOf(KapuaTad.class)); - } - - @Test - public void newKapuaTiconTest() { - Assert.assertThat("Instance of KapuaTicon expected.", metatypeXmlRegistry.newKapuaTicon(), IsInstanceOf.instanceOf(KapuaTicon.class)); - } - - @Test - public void newKapuaToptionTest() { - Assert.assertThat("Instance of KapuaToption expected.", metatypeXmlRegistry.newKapuaToption(), IsInstanceOf.instanceOf(KapuaToption.class)); - } - - @Test - public void newKapuaTmetadataTest() { - Assert.assertThat("Instance of KapuaTmetadata expected.", metatypeXmlRegistry.newKapuaTmetadata(), IsInstanceOf.instanceOf(KapuaTmetadata.class)); - } - - @Test - public void newKapuaTdesignateTest() { - Assert.assertThat("Instance of KapuaTdesignate expected.", metatypeXmlRegistry.newKapuaTdesignate(), IsInstanceOf.instanceOf(KapuaTdesignate.class)); - } - - @Test - public void newKapuaTobjectTest() { - Assert.assertThat("Instance of KapuaTobject expected.", metatypeXmlRegistry.newKapuaTobject(), IsInstanceOf.instanceOf(KapuaTobject.class)); - } -} diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/ServiceConfigurations.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/ServiceConfigurations.java index 4ffe9bab87b..54ea2bc9f1b 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/ServiceConfigurations.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/ServiceConfigurations.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; + import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -32,8 +33,8 @@ import org.eclipse.kapua.KapuaIllegalArgumentException; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; -import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; import org.eclipse.kapua.locator.KapuaLocator; +import org.eclipse.kapua.model.config.metatype.EmptyTocd; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.account.Account; @@ -41,7 +42,6 @@ import org.eclipse.kapua.service.config.KapuaConfigurableService; import org.eclipse.kapua.service.config.ServiceComponentConfiguration; import org.eclipse.kapua.service.config.ServiceConfiguration; -import org.eclipse.kapua.service.config.ServiceConfigurationFactory; @Path("{scopeId}/serviceConfigurations") public class ServiceConfigurations extends AbstractKapuaResource { @@ -50,19 +50,18 @@ public class ServiceConfigurations extends AbstractKapuaResource { public final KapuaLocator locator = KapuaLocator.getInstance(); @Inject public AccountService accountService; - @Inject - public ServiceConfigurationFactory serviceConfigurationFactory; @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ServiceConfiguration get(@PathParam("scopeId") ScopeId scopeId) throws KapuaException { - List configurableServices = locator.getServices().stream().filter(service -> service instanceof KapuaConfigurableService).map(kapuaService -> (KapuaConfigurableService) kapuaService).collect(Collectors.toList()); - ServiceConfiguration serviceConfiguration = serviceConfigurationFactory.newConfigurationInstance(); + List configurableServices = locator.getServices().stream().filter(service -> service instanceof KapuaConfigurableService) + .map(kapuaService -> (KapuaConfigurableService) kapuaService).collect(Collectors.toList()); + ServiceConfiguration serviceConfiguration = new ServiceConfiguration(); for (KapuaConfigurableService configurableService : configurableServices) { KapuaTocd metadata = configurableService.getConfigMetadata(scopeId); Map values = configurableService.getConfigValues(scopeId); if (metadata != null && !(metadata instanceof EmptyTocd)) { - ServiceComponentConfiguration serviceComponentConfiguration = serviceConfigurationFactory.newComponentConfigurationInstance(metadata.getId()); + ServiceComponentConfiguration serviceComponentConfiguration = new ServiceComponentConfiguration(metadata.getId()); serviceComponentConfiguration.setDefinition(metadata); serviceComponentConfiguration.setName(metadata.getName()); serviceComponentConfiguration.setProperties(values); @@ -75,8 +74,8 @@ public ServiceConfiguration get(@PathParam("scopeId") ScopeId scopeId) throws Ka } @PUT - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response update( @PathParam("scopeId") ScopeId scopeId, ServiceConfiguration serviceConfiguration @@ -89,7 +88,7 @@ public Response update( Class configurableServiceClass; try { configurableServiceClass = - (Class) Class.forName(serviceComponentConfiguration.getId()).asSubclass(KapuaService.class); + (Class) Class.forName(serviceComponentConfiguration.getId()).asSubclass(KapuaService.class); } catch (ClassNotFoundException e) { throw new KapuaIllegalArgumentException("serviceConfiguration.componentConfiguration.id", serviceComponentConfiguration.getId()); } @@ -103,7 +102,7 @@ public Response update( } @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Path("{serviceId}") public ServiceComponentConfiguration getComponent( @PathParam("scopeId") ScopeId scopeId, @@ -122,7 +121,7 @@ public ServiceComponentConfiguration getComponent( KapuaTocd metadata = configurableService.getConfigMetadata(scopeId); Map values = configurableService.getConfigValues(scopeId); if (metadata != null && !(metadata instanceof EmptyTocd)) { - ServiceComponentConfiguration serviceComponentConfiguration = serviceConfigurationFactory.newComponentConfigurationInstance(metadata.getId()); + ServiceComponentConfiguration serviceComponentConfiguration = new ServiceComponentConfiguration(metadata.getId()); serviceComponentConfiguration.setDefinition(metadata); serviceComponentConfiguration.setName(metadata.getName()); serviceComponentConfiguration.setProperties(values); @@ -132,8 +131,8 @@ public ServiceComponentConfiguration getComponent( } @PUT - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Path("{serviceId}") public Response updateComponent( @PathParam("scopeId") ScopeId scopeId, diff --git a/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java b/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java index 0203a1f1c31..2bcc3851d41 100644 --- a/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java +++ b/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java @@ -148,7 +148,6 @@ import org.eclipse.kapua.service.authorization.role.RoleXmlRegistry; import org.eclipse.kapua.service.config.ServiceComponentConfiguration; import org.eclipse.kapua.service.config.ServiceConfiguration; -import org.eclipse.kapua.service.config.ServiceConfigurationXmlRegistry; import org.eclipse.kapua.service.datastore.model.ChannelInfo; import org.eclipse.kapua.service.datastore.model.ChannelInfoListResult; import org.eclipse.kapua.service.datastore.model.ClientInfo; @@ -715,7 +714,6 @@ public JAXBContext getJAXBContext() throws KapuaException { EventStoreXmlRegistry.class, // Service Config - ServiceConfigurationXmlRegistry.class, ServiceConfiguration.class, ServiceComponentConfiguration.class, diff --git a/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java b/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java index 27e46090c29..f0aa2c493dd 100644 --- a/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java +++ b/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.UsedEntitiesCounterImpl; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -35,7 +34,6 @@ import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -106,8 +104,6 @@ protected void configure() { // Inject mocked Permission Factory final PermissionFactory mockPermissionFactory = Mockito.mock(PermissionFactory.class); bind(PermissionFactory.class).toInstance(mockPermissionFactory); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // Inject actual account related services // final AccountEntityManagerFactory entityManagerFactory = AccountEntityManagerFactory.getInstance(); // bind(AccountEntityManagerFactory.class).toInstance(entityManagerFactory); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocd.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/EmptyTocd.java similarity index 88% rename from commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocd.java rename to service/api/src/main/java/org/eclipse/kapua/model/config/metatype/EmptyTocd.java index 774c8460304..d403fafee0d 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocd.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/EmptyTocd.java @@ -10,18 +10,15 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; -import org.eclipse.kapua.model.config.metatype.KapuaTad; -import org.eclipse.kapua.model.config.metatype.KapuaTicon; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; - -import javax.xml.namespace.QName; import java.util.Collections; import java.util.List; import java.util.Map; -public class EmptyTocd implements KapuaTocd { +import javax.xml.namespace.QName; + +public class EmptyTocd extends KapuaTocd { private String id; private String name; diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaMetatypeFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaMetatypeFactory.java deleted file mode 100644 index b73b7828e78..00000000000 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaMetatypeFactory.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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.model.config.metatype; - -import org.eclipse.kapua.model.KapuaObjectFactory; - -/** - * Kapua metatype objects factory service definition.
- * This class provides, through locator and factory service, a factory for few objects types. - * - * @since 1.0 - */ -public interface KapuaMetatypeFactory extends KapuaObjectFactory { - - /** - * Returns a {@link KapuaTocd} instance - * - * @return - */ - KapuaTocd newKapuaTocd(); - - /** - * Returns a {@link KapuaTad} instance - * - * @return - */ - KapuaTad newKapuaTad(); - - /** - * Returns a {@link KapuaTscalar} instance - * - * @param type - * @return - */ - KapuaTscalar newKapuaTscalar(String type); - - /** - * Returns a {@link KapuaToption} instance - * - * @return - */ - KapuaToption newKapuaToption(); - - /** - * Returns a {@link KapuaTicon} instance - * - * @return - */ - KapuaTicon newKapuaTicon(); - - /** - * Returns a {@link KapuaTmetadata} instance - * - * @return - */ - KapuaTmetadata newKapuaTmetadata(); - - /** - * Returns a {@link KapuaTdesignate} instance - * - * @return - */ - KapuaTdesignate newKapuaTdesignate(); - - /** - * Returns a {@link KapuaTobject} instance - * - * @return - */ - KapuaTobject newKapuaTobject(); - -} diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTad.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTad.java index 907a6cf5ab9..097f0ac1d26 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTad.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTad.java @@ -12,18 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; /** *

@@ -61,16 +63,27 @@ @XmlType(name = "Tad", propOrder = { "option", "any" -}, factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTad") -public interface KapuaTad { +}) +public class KapuaTad { + + protected List option; + protected List any; + protected String name; + protected String description; + protected String id; + protected KapuaTscalar type; + protected Integer cardinality; + protected String min; + protected String max; + protected String defaultValue; + protected Boolean required; + private Map otherAttributes = new HashMap<>(); /** * Gets the value of the option property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the option property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the option property. *

* For example, to add a new item, do as follows: * @@ -80,17 +93,38 @@ public interface KapuaTad { *

*/ @XmlElement(name = "Option", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - List getOption(); + public List getOption() { + if (option == null) { + option = new ArrayList<>(); + } + return new ArrayList<>(this.option); + } - void setOption(List option); + /** + * Add an option to the internal list + * + * @param option + */ + public void addOption(KapuaToption option) { + if (this.option == null) { + this.option = new ArrayList<>(); + } + + this.option.add(option); + } + + public void setOption(List option) { + this.option = new ArrayList<>(); + for (KapuaToption singleOption : option) { + this.option.add(singleOption); + } + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -99,10 +133,16 @@ public interface KapuaTad { * *

*/ - @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } - void setAny(List any); + public void setAny(List any) { + this.any = any; + } /** * Gets the value of the name property. @@ -110,14 +150,19 @@ public interface KapuaTad { * @return possible object is {@link String} */ @XmlAttribute(name = "name") - String getName(); + public String getName() { + return name; + } /** * Sets the value of the name property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setName(String value); + public void setName(String value) { + this.name = value; + } /** * Gets the value of the description property. @@ -125,14 +170,19 @@ public interface KapuaTad { * @return possible object is {@link String } */ @XmlAttribute(name = "description") - String getDescription(); + public String getDescription() { + return description; + } /** * Sets the value of the description property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setDescription(String value); + public void setDescription(String value) { + this.description = value; + } /** * Gets the value of the id property. @@ -140,14 +190,19 @@ public interface KapuaTad { * @return possible object is {@link String} */ @XmlAttribute(name = "id", required = true) - String getId(); + public String getId() { + return id; + } /** * Sets the value of the id property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setId(String value); + public void setId(String value) { + this.id = value; + } /** * Gets the value of the type property. @@ -156,14 +211,19 @@ public interface KapuaTad { */ @XmlAttribute(name = "type", required = true) @XmlJavaTypeAdapter(KapuaTscalarAdapter.class) - KapuaTscalar getType(); + public KapuaTscalar getType() { + return type; + } /** * Sets the value of the type property. * - * @param value allowed object is {@link KapuaTscalar } + * @param value + * allowed object is {@link KapuaTscalar } */ - void setType(KapuaTscalar value); + public void setType(KapuaTscalar value) { + this.type = value; + } /** * Gets the value of the cardinality property. @@ -171,14 +231,23 @@ public interface KapuaTad { * @return possible object is {@link Integer } */ @XmlAttribute(name = "cardinality") - Integer getCardinality(); + public Integer getCardinality() { + if (cardinality == null) { + return 0; + } else { + return cardinality; + } + } /** * Sets the value of the cardinality property. * - * @param value allowed object is {@link Integer } + * @param value + * allowed object is {@link Integer } */ - void setCardinality(Integer value); + public void setCardinality(Integer value) { + this.cardinality = value; + } /** * Gets the value of the min property. @@ -186,14 +255,19 @@ public interface KapuaTad { * @return possible object is {@link String } */ @XmlAttribute(name = "min") - String getMin(); + public String getMin() { + return min; + } /** * Sets the value of the min property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setMin(String value); + public void setMin(String value) { + this.min = value; + } /** * Gets the value of the max property. @@ -201,14 +275,19 @@ public interface KapuaTad { * @return possible object is {@link String } */ @XmlAttribute(name = "max") - String getMax(); + public String getMax() { + return max; + } /** * Sets the value of the max property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setMax(String value); + public void setMax(String value) { + this.max = value; + } /** * Gets the value of the default property. @@ -216,14 +295,19 @@ public interface KapuaTad { * @return possible object is {@link String } */ @XmlAttribute(name = "default") - String getDefault(); + public String getDefault() { + return defaultValue; + } /** * Sets the value of the default property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setDefault(String value); + public void setDefault(String value) { + this.defaultValue = value; + } /** * Gets the value of the required property. @@ -231,27 +315,41 @@ public interface KapuaTad { * @return possible object is {@link Boolean } */ @XmlAttribute(name = "required") - Boolean isRequired(); + public Boolean isRequired() { + if (required == null) { + return true; + } else { + return required; + } + } /** * Sets the value of the required property. * - * @param value allowed object is {@link Boolean } + * @param value + * allowed object is {@link Boolean } */ - void setRequired(Boolean value); + public void setRequired(Boolean value) { + this.required = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } + + public void putOtherAttribute(QName key, String value) { + getOtherAttributes().put(key, + value); + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTattribute.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTattribute.java index 89f114d8564..2cab59a667d 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTattribute.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTattribute.java @@ -12,10 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; -import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.namespace.QName; + /** *

* Java class for Tattribute complex type. @@ -40,15 +51,30 @@ * * @since 1.0 */ -public interface KapuaTattribute { +@XmlRootElement(name = "Attribute", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Tattribute", propOrder = { + "value", + "any" +}) +public class KapuaTattribute { + + @XmlElement(name = "Value", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") + protected List value; + @XmlAnyElement(lax = true) + protected List any; + @XmlAttribute(name = "adref", required = true) + protected String adref; + @XmlAttribute(name = "content") + protected String content; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); /** * Gets the value of the value property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the value property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the value property. *

* For example, to add a new item, do as follows: * @@ -57,15 +83,18 @@ public interface KapuaTattribute { * *

*/ - List getValue(); + public List getValue() { + if (value == null) { + value = new ArrayList(); + } + return this.value; + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -74,46 +103,61 @@ public interface KapuaTattribute { * *

*/ - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } /** * Gets the value of the adref property. * * @return possible object is {@link String } */ - String getAdref(); + public String getAdref() { + return adref; + } /** * Sets the value of the adref property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setAdref(String value); + public void setAdref(String value) { + this.adref = value; + } /** * Gets the value of the content property. * * @return possible object is {@link String } */ - String getContent(); + public String getContent() { + return content; + } /** * Sets the value of the content property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setContent(String value); + public void setContent(String value) { + this.content = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignate.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignate.java index df2ecfbeca7..1f3bef877e4 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignate.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignate.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,8 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; /** *

@@ -60,8 +63,17 @@ "optional", "merge", "otherAttributes" -}, factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTdesignate") -public interface KapuaTdesignate { +}) +public class KapuaTdesignate { + + protected KapuaTobject object; + protected List any; + protected String pid; + protected String factoryPid; + protected String bundle; + protected Boolean optional; + protected Boolean merge; + private Map otherAttributes = new HashMap(); /** * Gets the value of the object property. @@ -69,22 +81,25 @@ public interface KapuaTdesignate { * @return possible object is {@link KapuaTobject } */ @XmlElement(name = "Object", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0", required = true) - KapuaTobject getObject(); + public KapuaTobject getObject() { + return object; + } /** * Sets the value of the object property. * - * @param value allowed object is {@link KapuaTobject } + * @param value + * allowed object is {@link KapuaTobject } */ - void setObject(KapuaTobject value); + public void setObject(KapuaTobject value) { + this.object = value; + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -94,9 +109,16 @@ public interface KapuaTdesignate { *

*/ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } - void setAny(List any); + public void setAny(List any) { + this.any = any; + } /** * Gets the value of the pid property. @@ -104,14 +126,19 @@ public interface KapuaTdesignate { * @return possible object is {@link String } */ @XmlAttribute(name = "pid") - String getPid(); + public String getPid() { + return pid; + } /** * Sets the value of the pid property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setPid(String value); + public void setPid(String value) { + this.pid = value; + } /** * Gets the value of the factoryPid property. @@ -119,14 +146,19 @@ public interface KapuaTdesignate { * @return possible object is {@link String } */ @XmlAttribute(name = "factoryPid") - String getFactoryPid(); + public String getFactoryPid() { + return factoryPid; + } /** * Sets the value of the factoryPid property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setFactoryPid(String value); + public void setFactoryPid(String value) { + this.factoryPid = value; + } /** * Gets the value of the bundle property. @@ -134,14 +166,19 @@ public interface KapuaTdesignate { * @return possible object is {@link String } */ @XmlAttribute(name = "bundle") - String getBundle(); + public String getBundle() { + return bundle; + } /** * Sets the value of the bundle property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setBundle(String value); + public void setBundle(String value) { + this.bundle = value; + } /** * Gets the value of the optional property. @@ -149,14 +186,23 @@ public interface KapuaTdesignate { * @return possible object is {@link Boolean } */ @XmlAttribute(name = "optional") - Boolean isOptional(); + public Boolean isOptional() { + if (optional == null) { + return false; + } else { + return optional; + } + } /** * Sets the value of the optional property. * - * @param value allowed object is {@link Boolean } + * @param value + * allowed object is {@link Boolean } */ - void setOptional(Boolean value); + public void setOptional(Boolean value) { + this.optional = value; + } /** * Gets the value of the merge property. @@ -164,29 +210,40 @@ public interface KapuaTdesignate { * @return possible object is {@link Boolean } */ @XmlAttribute(name = "merge") - Boolean isMerge(); + public Boolean isMerge() { + if (merge == null) { + return false; + } else { + return merge; + } + } /** * Sets the value of the merge property. * - * @param value allowed object is {@link Boolean } + * @param value + * allowed object is {@link Boolean } */ - void setMerge(Boolean value); + public void setMerge(Boolean value) { + this.merge = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } - void setOtherAttributes(Map otherAttributes); + public void setOtherAttributes(Map otherAttributes) { + this.otherAttributes = otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTicon.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTicon.java index 2e167445701..1fe2ad0ffcc 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTicon.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTicon.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,9 +27,6 @@ import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.math.BigInteger; -import java.util.List; -import java.util.Map; /** *

@@ -50,16 +53,19 @@ */ @XmlRootElement(name = "Icon", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(name = "Icon", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0", factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTicon") -public interface KapuaTicon { +@XmlType(name = "Icon", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") +public class KapuaTicon { + + protected List any; + protected String resource; + protected BigInteger size; + private Map otherAttributes = new HashMap<>(); /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -68,7 +74,12 @@ public interface KapuaTicon { * */ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList<>(); + } + return this.any; + } /** * Gets the value of the resource property. @@ -76,14 +87,19 @@ public interface KapuaTicon { * @return possible object is {@link String } */ @XmlAttribute(name = "resource", required = true) - String getResource(); + public String getResource() { + return resource; + } /** * Sets the value of the resource property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setResource(String value); + public void setResource(String value) { + this.resource = value; + } /** * Gets the value of the size property. @@ -92,27 +108,32 @@ public interface KapuaTicon { */ @XmlAttribute(name = "size", required = true) @XmlSchemaType(name = "positiveInteger") - BigInteger getSize(); + public BigInteger getSize() { + return size; + } /** * Sets the value of the size property. * - * @param value allowed object is {@link BigInteger } + * @param value + * allowed object is {@link BigInteger } */ - void setSize(BigInteger value); + public void setSize(BigInteger value) { + this.size = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadata.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadata.java index ee57799d1db..6ef6f8bcd15 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadata.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadata.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,8 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; /** *

@@ -54,16 +57,20 @@ "any", "localization", "otherAttributes" -}, factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTmetadata") -public interface KapuaTmetadata { +}) +public class KapuaTmetadata { + + protected List ocd; + protected List designate; + protected List any; + protected String localization; + private Map otherAttributes = new HashMap(); /** * Gets the value of the ocd property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ocd property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the ocd property. *

* For example, to add a new item, do as follows: *

@@ -71,17 +78,22 @@ public interface KapuaTmetadata {
      * 
*/ @XmlElement(name = "OCD", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - List getOCD(); + public List getOCD() { + if (ocd == null) { + ocd = new ArrayList<>(); + } + return new ArrayList<>(this.ocd); + } - void setOCD(List ocd); + public void setOCD(List ocd) { + this.ocd = ocd; + } /** * Gets the value of the designate property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the designate property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the designate property. *

* For example, to add a new item, do as follows: *

@@ -89,17 +101,22 @@ public interface KapuaTmetadata {
      * 
*/ @XmlElement(name = "Designate", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - List getDesignate(); + public List getDesignate() { + if (designate == null) { + designate = new ArrayList<>(); + } + return new ArrayList<>(this.designate); + } - void setDesignate(List designate); + public void setDesignate(List designate) { + this.designate = designate; + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: *

@@ -107,9 +124,16 @@ public interface KapuaTmetadata {
      * 
*/ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } - void setAny(List any); + public void setAny(List any) { + this.any = any; + } /** * Gets the value of the localization property. @@ -117,28 +141,35 @@ public interface KapuaTmetadata { * @return possible object is {@link String } */ @XmlAttribute(name = "localization") - String getLocalization(); + public String getLocalization() { + return localization; + } /** * Sets the value of the localization property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setLocalization(String value); + public void setLocalization(String value) { + this.localization = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } - void setOtherAttributes(Map otherAttributes); + public void setOtherAttributes(Map otherAttributes) { + this.otherAttributes = otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTobject.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTobject.java index 2b86ef6b5e3..316add12964 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTobject.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTobject.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,8 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; /** *

@@ -50,16 +53,19 @@ @XmlType(name = "Tobject", propOrder = { "attribute", "any" -}, factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTobject") -public interface KapuaTobject { +}) +public class KapuaTobject { + + protected List attribute; + protected List any; + protected String ocdref; + private Map otherAttributes = new HashMap(); /** * Gets the value of the attribute property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the attribute property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the attribute property. *

* For example, to add a new item, do as follows: * @@ -68,15 +74,18 @@ public interface KapuaTobject { * */ @XmlElement(name = "Attribute", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - List getAttribute(); + public List getAttribute() { + if (attribute == null) { + attribute = new ArrayList<>(); + } + return new ArrayList<>(this.attribute); + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -86,7 +95,12 @@ public interface KapuaTobject { *

*/ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } /** * Gets the value of the ocdref property. @@ -94,27 +108,32 @@ public interface KapuaTobject { * @return possible object is {@link String } */ @XmlAttribute(name = "ocdref", required = true) - String getOcdref(); + public String getOcdref() { + return ocdref; + } /** * Sets the value of the ocdref property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setOcdref(String value); + public void setOcdref(String value) { + this.ocdref = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTocd.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTocd.java index a45353d6040..908d912a5c0 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTocd.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTocd.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,8 +26,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; + +import org.w3c.dom.Element; /** *

@@ -52,35 +57,53 @@ */ @XmlRootElement(name = "OCD", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaTocd") -public interface KapuaTocd { +@XmlType +public class KapuaTocd { + + protected List ad; + protected List icon; + protected List any; + protected String name; + protected String description; + protected String id; + private Map otherAttributes = new HashMap<>(); /** * Gets the value of the ad property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ad property. + *

+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the ad property. + *

*

* For example, to add a new item, do as follows: - * + *

*

      * getAD().add(newItem);
      * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list {@link KapuaTad } */ @XmlElement(name = "AD", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0", required = true) - List getAD(); - void setAD(List icon); + public List getAD() { + if (ad == null) { + ad = new ArrayList<>(); + } + return this.ad; + } + + public void setAD(List ad) { + this.ad = ad; + } /** * Gets the value of the icon property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the icon property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the icon property. *

* For example, to add a new item, do as follows: * @@ -89,28 +112,77 @@ public interface KapuaTocd { * */ @XmlElement(name = "Icon", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") - List getIcon(); - void setIcon(List icon); + /** + * Gets the value of the icon property. + *

+ *

+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the icon property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+ *

+     * getIcon().add(newItem);
+     * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list {@link TiconImpl } + */ + public List getIcon() { + if (icon == null) { + icon = new ArrayList<>(); + } + return this.icon; + } + + public void setIcon(List icon) { + this.icon = icon; + } + + /** + * Add icon to the internal list + * + * @param icon + */ + public void addIcon(KapuaTicon icon) { + if (this.icon == null) { + this.icon = new ArrayList<>(); + } + this.icon.add(icon); + } /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + *

+ * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. + *

*

* For example, to add a new item, do as follows: - * + *

*

      * getAny().add(newItem);
      * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list {@link Element } {@link Object } */ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList<>(); + } + return this.any; + } - void setAny(List any); + public void setAny(List any) { + this.any = any; + } /** * Gets the value of the name property. @@ -118,14 +190,19 @@ public interface KapuaTocd { * @return possible object is {@link String } */ @XmlAttribute(name = "name", required = true) - String getName(); + public String getName() { + return name; + } /** * Sets the value of the name property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setName(String value); + public void setName(String value) { + this.name = value; + } /** * Gets the value of the description property. @@ -133,14 +210,19 @@ public interface KapuaTocd { * @return possible object is {@link String } */ @XmlAttribute(name = "description") - String getDescription(); + public String getDescription() { + return description; + } /** * Sets the value of the description property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setDescription(String value); + public void setDescription(String value) { + this.description = value; + } /** * Gets the value of the id property. @@ -148,29 +230,69 @@ public interface KapuaTocd { * @return possible object is {@link String } */ @XmlAttribute(name = "id", required = true) - String getId(); + public String getId() { + return id; + } /** * Sets the value of the id property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setId(String value); + public void setId(String value) { + this.id = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } - void setOtherAttributes(Map otherAttributes); + public void setOtherAttributes(Map otherAttributes) { + this.otherAttributes = otherAttributes; + } + + /** + * Insert a generic value for the provided QName + * + * @param key + * @param value + */ + public void putOtherAttribute(QName key, String value) { + getOtherAttributes().put(key, + value); + } + + /** + * Add Tad to the internal list + * + * @param ad + */ + public void addAD(KapuaTad ad) { + if (this.ad == null) { + this.ad = new ArrayList<>(); + } + + this.ad.add(ad); + } + + /** + * Add a generic object to the internal list + * + * @param object + */ + public void addAny(Object object) { + getAny().add(object); + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaToption.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaToption.java index 1e1dfa46b1d..f5753a019da 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaToption.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaToption.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -20,8 +25,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; -import java.util.List; -import java.util.Map; /** *

@@ -50,16 +53,19 @@ @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(name = "Toption", propOrder = { "any" -}, factoryClass = MetatypeXmlRegistry.class, factoryMethod = "newKapuaToption") -public interface KapuaToption { +}) +public class KapuaToption { + + protected List any; + protected String label; + protected String value; + private Map otherAttributes = new HashMap(); /** * Gets the value of the any property. *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is + * not a set method for the any property. *

* For example, to add a new item, do as follows: * @@ -68,7 +74,12 @@ public interface KapuaToption { * */ @XmlAnyElement(lax = true) - List getAny(); + public List getAny() { + if (any == null) { + any = new ArrayList(); + } + return this.any; + } /** * Gets the value of the label property. @@ -76,14 +87,19 @@ public interface KapuaToption { * @return possible object is {@link String } */ @XmlAttribute(name = "label", required = true) - String getLabel(); + public String getLabel() { + return label; + } /** * Sets the value of the label property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setLabel(String value); + public void setLabel(String value) { + this.label = value; + } /** * Gets the value of the value property. @@ -91,27 +107,32 @@ public interface KapuaToption { * @return possible object is {@link String } */ @XmlAttribute(name = "value", required = true) - String getValue(); + public String getValue() { + return value; + } /** * Sets the value of the value property. * - * @param value allowed object is {@link String } + * @param value + * allowed object is {@link String } */ - void setValue(String value); + public void setValue(String value) { + this.value = value; + } /** * Gets a map that contains attributes that aren't bound to any typed property on this class. *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. *

- * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter. * * @return always non-null */ @XmlAnyAttribute - Map getOtherAttributes(); + public Map getOtherAttributes() { + return otherAttributes; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalar.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalar.java index a45976db268..8e6d1b5b09b 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalar.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalar.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + /** *

* Java class for Tscalar complex type. @@ -37,12 +44,63 @@ * * @since 1.0 */ -public interface KapuaTscalar { +@XmlEnum +@XmlType(name = "Tscalar") +@XmlRootElement(name = "OCD", namespace = "http://www.osgi.org/xmlns/metatype/v1.2.0") +@XmlAccessorType(XmlAccessType.PROPERTY) +public enum KapuaTscalar { + @XmlEnumValue("String") + STRING("String"), + @XmlEnumValue("Long") + LONG("Long"), + @XmlEnumValue("Double") + DOUBLE("Double"), + @XmlEnumValue("Float") + FLOAT("Float"), + @XmlEnumValue("Integer") + INTEGER("Integer"), + @XmlEnumValue("Byte") + BYTE("Byte"), + @XmlEnumValue("Char") + CHAR("Char"), + @XmlEnumValue("Boolean") + BOOLEAN("Boolean"), + @XmlEnumValue("Short") + SHORT("Short"), + @XmlEnumValue("Password") + PASSWORD("Password"); + private final String value; + + /** + * Constructor + * + * @param v + */ + KapuaTscalar(String v) { + value = v; + } /** * Gets the value property. * * @return possible object is {@link String } with restricted values */ - String value(); + public String value() { + return value; + } + + /** + * Convert a String value to a {@link KapuaTscalar} + * + * @param v + * @return + */ + public static KapuaTscalar fromValue(String v) { + for (KapuaTscalar c : KapuaTscalar.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalarAdapter.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalarAdapter.java index cdffdd98311..ab553b457f2 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalarAdapter.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/KapuaTscalarAdapter.java @@ -12,14 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.model.config.metatype; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.adapters.XmlAdapter; public class KapuaTscalarAdapter extends XmlAdapter { - private final KapuaMetatypeFactory kapuaMetatypeFactory = KapuaLocator.getInstance().getFactory(KapuaMetatypeFactory.class); - @Override public String marshal(KapuaTscalar v) throws Exception { return v.value(); @@ -27,6 +23,6 @@ public String marshal(KapuaTscalar v) throws Exception { @Override public KapuaTscalar unmarshal(String v) throws Exception { - return kapuaMetatypeFactory.newKapuaTscalar(v); + return KapuaTscalar.fromValue(v); } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/MetatypeXmlRegistry.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/MetatypeXmlRegistry.java deleted file mode 100644 index e8d43cc9394..00000000000 --- a/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/MetatypeXmlRegistry.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.model.config.metatype; - -import org.eclipse.kapua.locator.KapuaLocator; - -/** - * Xml factory class.
- * This class provides, through locator and factory service, a factory for few objects types. - * - * @since 1.0 - */ -public class MetatypeXmlRegistry { - - /** - * Locator instance - */ - private final KapuaLocator locator = KapuaLocator.getInstance(); - - /** - * Meta type factory instance - */ - private final KapuaMetatypeFactory factory = locator.getFactory(KapuaMetatypeFactory.class); - - /** - * Returns a {@link KapuaTocd} instance - * - * @return - */ - public KapuaTocd newKapuaTocd() { - return factory.newKapuaTocd(); - } - - /** - * Returns a {@link KapuaTad} instance - * - * @return - */ - public KapuaTad newKapuaTad() { - return factory.newKapuaTad(); - } - - /** - * Returns a {@link KapuaTicon} instance - * - * @return - */ - public KapuaTicon newKapuaTicon() { - return factory.newKapuaTicon(); - } - - /** - * Returns a {@link KapuaToption} instance - * - * @return - */ - public KapuaToption newKapuaToption() { - return factory.newKapuaToption(); - } - - /** - * Returns a {@link KapuaTmetadata} instance - * - * @return - */ - public KapuaTmetadata newKapuaTmetadata() { - return factory.newKapuaTmetadata(); - } - - /** - * Returns a {@link KapuaTdesignate} instance - * - * @return - */ - public KapuaTdesignate newKapuaTdesignate() { - return factory.newKapuaTdesignate(); - } - - /** - * Returns a {@link KapuaTobject} instance - * - * @return - */ - public KapuaTobject newKapuaTobject() { - return factory.newKapuaTobject(); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/Password.java b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/Password.java similarity index 94% rename from commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/Password.java rename to service/api/src/main/java/org/eclipse/kapua/model/config/metatype/Password.java index 565e39f11c5..ce11be1ce71 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/metatype/Password.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/config/metatype/Password.java @@ -10,7 +10,7 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; /** * Contains password used by devices connecting to Kapua. diff --git a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceComponentConfiguration.java b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceComponentConfiguration.java index 517a2809a48..09757444ca0 100644 --- a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceComponentConfiguration.java +++ b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceComponentConfiguration.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.config; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -19,7 +21,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Map; import org.eclipse.kapua.model.config.metatype.KapuaTocd; @@ -35,8 +36,28 @@ "name", "definition", "properties" -}, factoryClass = ServiceConfigurationXmlRegistry.class, factoryMethod = "newComponentConfiguration") -public interface ServiceComponentConfiguration { +}) +public class ServiceComponentConfiguration { + + private String id; + private String name; + private KapuaTocd definition; + private Map properties; + + /** + * Constructor + */ + public ServiceComponentConfiguration() { + } + + /** + * Constructor + * + * @param id + */ + public ServiceComponentConfiguration(String id) { + this.id = id; + } /** * Get service configuration component identifier @@ -44,14 +65,18 @@ public interface ServiceComponentConfiguration { * @return */ @XmlElement(name = "id") - String getId(); + public String getId() { + return id; + } /** * Set service configuration component identifier * * @param id */ - void setId(String id); + public void setId(String id) { + this.id = id; + } /** * Get service configuration component name @@ -59,14 +84,18 @@ public interface ServiceComponentConfiguration { * @return */ @XmlAttribute(name = "name") - String getName(); + public String getName() { + return name; + } /** * Set service configuration component name * - * @param unescapedComponentName + * @param name */ - void setName(String unescapedComponentName); + public void setName(String name) { + this.name = name; + } /** * Get service configuration component definition @@ -74,14 +103,18 @@ public interface ServiceComponentConfiguration { * @return */ @XmlElement(name = "definition") - KapuaTocd getDefinition(); + public KapuaTocd getDefinition() { + return definition; + } /** * Set service configuration component definition * * @param definition */ - void setDefinition(KapuaTocd definition); + public void setDefinition(KapuaTocd definition) { + this.definition = definition; + } /** * Get service configuration component properties @@ -90,12 +123,16 @@ public interface ServiceComponentConfiguration { */ @XmlElement(name = "properties") @XmlJavaTypeAdapter(ServiceXmlConfigPropertiesAdapter.class) - Map getProperties(); + public Map getProperties() { + return properties; + } /** * Set service configuration component properties * * @param properties */ - void setProperties(Map properties); + public void setProperties(Map properties) { + this.properties = properties; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfiguration.java b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfiguration.java index 36211ee2f6c..93875165cb1 100644 --- a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfiguration.java +++ b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfiguration.java @@ -12,12 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.config; +import java.util.ArrayList; +import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.List; import org.eclipse.kapua.KapuaSerializable; @@ -28,8 +30,16 @@ */ @XmlRootElement(name = "serviceConfigurations") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ServiceConfigurationXmlRegistry.class, factoryMethod = "newConfiguration") -public interface ServiceConfiguration extends KapuaSerializable { +@XmlType +public class ServiceConfiguration implements KapuaSerializable { + + private static final long serialVersionUID = -2167999497954676423L; + + private List configurations; + + public ServiceConfiguration() { + configurations = new ArrayList<>(); + } /** * Get the service component configuration list @@ -37,5 +47,7 @@ public interface ServiceConfiguration extends KapuaSerializable { * @return */ @XmlElement(name = "configuration") - List getComponentConfigurations(); + public List getComponentConfigurations() { + return configurations; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationFactory.java b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationFactory.java deleted file mode 100644 index fd4e2ca9ef7..00000000000 --- a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.config; - -import org.eclipse.kapua.model.KapuaObjectFactory; - -/** - * Service configuration entity service factory definition. - * - * @since 1.0 - */ -public interface ServiceConfigurationFactory extends KapuaObjectFactory { - - /** - * Creates a new {@link ServiceComponentConfiguration} using the given component configuration identifier - * - * @return - */ - ServiceComponentConfiguration newComponentConfigurationInstance(String componentConfigurationId); - - /** - * Creates a new {@link ServiceConfiguration} - * - * @return - */ - ServiceConfiguration newConfigurationInstance(); -} diff --git a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationXmlRegistry.java b/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationXmlRegistry.java deleted file mode 100644 index a9fa15fd39e..00000000000 --- a/service/api/src/main/java/org/eclipse/kapua/service/config/ServiceConfigurationXmlRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.config; - -import org.eclipse.kapua.locator.KapuaLocator; - -import javax.xml.bind.annotation.XmlRegistry; - -/** - * {@link ServiceConfiguration} xml factory class - * - * @since 1.0 - */ -@XmlRegistry -public class ServiceConfigurationXmlRegistry { - - private final ServiceConfigurationFactory serviceConfigurationFactory = KapuaLocator.getInstance().getFactory(ServiceConfigurationFactory.class); - - /** - * Creates a new service configuration - * - * @return - */ - public ServiceConfiguration newConfiguration() { - return serviceConfigurationFactory.newConfigurationInstance(); - } - - /** - * Creates a new service component configuration - * - * @return - */ - public ServiceComponentConfiguration newComponentConfiguration() { - return serviceConfigurationFactory.newComponentConfigurationInstance(null); - } -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocdTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/EmptyTocdTest.java similarity index 85% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocdTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/EmptyTocdTest.java index 17474cce689..ca901683cf5 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/EmptyTocdTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/EmptyTocdTest.java @@ -10,7 +10,10 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; + +import java.util.Arrays; +import java.util.List; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,10 +21,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Arrays; -import java.util.List; - - @Category(JUnitTests.class) public class EmptyTocdTest { @@ -55,7 +54,7 @@ public void setNameToNullTest() { @Test public void setAndGetNameTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularName", "regular Name", "49", "regularName49", "REGULAR", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularName", "regular Name", "49", "regularName49", "REGULAR", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { emptyTocd.setName(value); Assert.assertTrue(emptyTocd.getName().contains(value)); @@ -70,7 +69,7 @@ public void setAndGetIdToNullValueTest() { @Test public void setAndGetIdTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regular Id", "49", "regularId49", "ID", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regular Id", "49", "regularId49", "ID", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { emptyTocd.setId(value); Assert.assertTrue(emptyTocd.getId().contains(value)); @@ -97,7 +96,7 @@ public void setDescriptionToNullTest() { @Test public void setAndGetDescriptionTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regular Description", "49", "regularDescription49", "DESCRIPTION", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regular Description", "49", "regularDescription49", "DESCRIPTION", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { emptyTocd.setDescription(value); Assert.assertNull(emptyTocd.getDescription()); diff --git a/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTadTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTadTest.java new file mode 100644 index 00000000000..2c608bfe3b2 --- /dev/null +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTadTest.java @@ -0,0 +1,283 @@ +/******************************************************************************* + * Copyright (c) 2020, 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.model.config.metatype; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(JUnitTests.class) +public class KapuaTadTest { + + @Before + public void createInstanceOfClasses() { + + kapuaTad = new KapuaTad(); + toption = new KapuaToption(); + toption2 = new KapuaToption(); + } + + KapuaTad kapuaTad; + KapuaToption toption; + KapuaToption toption2; + + @Test + public void getOptionToNullTest() { + kapuaTad.getOption(); + Assert.assertTrue(kapuaTad.getOption().isEmpty()); + } + + @Test + public void setAndGetOptionRegularTest() { + List option = new ArrayList<>(); + option.add(toption); + kapuaTad.setOption(option); + Assert.assertEquals("tadImpl.option", option, kapuaTad.getOption()); + } + + @Test + public void addAndGetOptionTest() { + List options = new ArrayList<>(); + options.add(toption); + options.add(toption2); + + kapuaTad.addOption(toption); + kapuaTad.addOption(toption2); + + Assert.assertEquals("tadImpl.option", options, kapuaTad.getOption()); + } + + @Test + public void getAnyTest() { + Assert.assertTrue(kapuaTad.getAny().isEmpty()); + } + + @Test + public void setAndGetAnyTest() { + List options = new ArrayList<>(); + options.add(toption); + options.add(toption2); + options.add(null); + kapuaTad.setAny(options); + Assert.assertEquals("tadImpl.option", options, kapuaTad.getAny()); + } + + @Test + public void setAndGetNameToNullTest() { + kapuaTad.setName(null); + Assert.assertNull(kapuaTad.getName()); + } + + @Test + public void setAndGetNameTest() { + String[] permittedValues = { "", "regularName", "49", "regular Name", "regular name with spaces", "!@#$%&*()_+/->,<", "NAME", "name123" }; + for (String value : permittedValues) { + kapuaTad.setName(value); + Assert.assertTrue(kapuaTad.getName().contains(value)); + } + } + + @Test + public void setAndGetDescriptionToNullTest() { + kapuaTad.setDescription(null); + Assert.assertNull(kapuaTad.getDescription()); + } + + @Test + public void setAndGetDescriptionTest() { + String[] permittedValues = { "", "regularDescription", "49", "regular Description", "regular description with spaces", "!@#$%&*()_+/->,<", "DESCRIPTION", "description123" }; + for (String value : permittedValues) { + kapuaTad.setDescription(value); + Assert.assertTrue(kapuaTad.getDescription().contains(value)); + } + } + + @Test + public void setAndGetIdToNullTest() { + kapuaTad.setId(null); + Assert.assertNull(kapuaTad.getId()); + } + + @Test + public void setAndGetIdTest() { + String[] permittedValues = { "", "regularId", "49", "regular Id", "regular id with spaces", "!@#$%&*()_+/->,<", "ID", "id123" }; + for (String value : permittedValues) { + kapuaTad.setId(value); + Assert.assertTrue(kapuaTad.getId().contains(value)); + } + } + + @Test + public void setAndGetTypeStringTest() { + kapuaTad.setType(KapuaTscalar.STRING); + Assert.assertEquals("tadImpl.type", KapuaTscalar.STRING, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeLongTest() { + kapuaTad.setType(KapuaTscalar.LONG); + Assert.assertEquals("tadImpl.type", KapuaTscalar.LONG, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeDoubleTest() { + kapuaTad.setType(KapuaTscalar.DOUBLE); + Assert.assertEquals("tadImpl.type", KapuaTscalar.DOUBLE, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeFloatTest() { + kapuaTad.setType(KapuaTscalar.FLOAT); + Assert.assertEquals("tadImpl.type", KapuaTscalar.FLOAT, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeIntegerTest() { + kapuaTad.setType(KapuaTscalar.INTEGER); + Assert.assertEquals("tadImpl.type", KapuaTscalar.INTEGER, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeByteTest() { + kapuaTad.setType(KapuaTscalar.BYTE); + Assert.assertEquals("tadImpl.type", KapuaTscalar.BYTE, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeCharTest() { + kapuaTad.setType(KapuaTscalar.CHAR); + Assert.assertEquals("tadImpl.type", KapuaTscalar.CHAR, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeBooleanTest() { + kapuaTad.setType(KapuaTscalar.BOOLEAN); + Assert.assertEquals("tadImpl.type", KapuaTscalar.BOOLEAN, kapuaTad.getType()); + } + + @Test + public void setAndGetTypeShortTest() { + kapuaTad.setType(KapuaTscalar.SHORT); + Assert.assertEquals("tadImpl.type", KapuaTscalar.SHORT, kapuaTad.getType()); + } + + @Test + public void setAndGetTypePasswordTest() { + kapuaTad.setType(KapuaTscalar.PASSWORD); + Assert.assertEquals("tadImpl.type", KapuaTscalar.PASSWORD, kapuaTad.getType()); + } + + @Test + public void setAndGetCardinalityToNullTest() { + kapuaTad.setCardinality(null); + Assert.assertEquals("tadImpl.cardinality", 0, (int) kapuaTad.getCardinality()); + } + + @Test + public void setAndGetCardinalityRegularTest() { + int[] permittedValues = { 1, 10, 100, 500, -2147483648, 2147483647, 0 }; + for (int value : permittedValues) { + kapuaTad.setCardinality(value); + Assert.assertEquals("tadImpl.cardinality", Integer.valueOf(value), kapuaTad.getCardinality()); + } + } + + @Test + public void setAndGetMinToNullTest() { + kapuaTad.setMin(null); + Assert.assertNull(kapuaTad.getMin()); + } + + @Test + public void setAndGetMinTest() { + String[] permittedValues = { "", "regularMin", "49", "regular Min", "regular min with spaces", "!@#$%&*()_+/->,<", "MIN", "min123" }; + for (String value : permittedValues) { + kapuaTad.setMin(value); + Assert.assertTrue(kapuaTad.getMin().contains(value)); + } + } + + @Test + public void setAndGetMaxToNullTest() { + kapuaTad.setMax(null); + Assert.assertNull(kapuaTad.getMax()); + } + + @Test + public void setAndGetMaxTest() { + String[] permittedValues = { "", "regularMax", "49", "regular Max", "regular max with spaces", "!@#$%&*()_+/->,<", "MAX", "max123" }; + for (String value : permittedValues) { + kapuaTad.setMax(value); + Assert.assertTrue(kapuaTad.getMax().contains(value)); + } + } + + @Test + public void setAndGetDefaultToNullTest() { + kapuaTad.setDefault(null); + Assert.assertNull(kapuaTad.getDefault()); + } + + @Test + public void setAndGetDefaultTest() { + String[] permittedValues = { "", "regularDefault", "49", "regular Default", "regular default with spaces", "!@#$%&*()_+/->,<", "DEFAULT", "default123" }; + for (String value : permittedValues) { + kapuaTad.setDefault(value); + Assert.assertTrue(kapuaTad.getDefault().contains(value)); + } + } + + @Test + public void setIsRequiredToNullTest() { + kapuaTad.setRequired(null); + Assert.assertTrue(kapuaTad.isRequired()); + } + + @Test + public void setAndIsRequiredTest() { + boolean[] permittedValues = { false, true }; + for (boolean value : permittedValues) { + kapuaTad.setRequired(value); + Assert.assertEquals("tadImpl.value", value, kapuaTad.isRequired()); + } + } + + @Test + public void putAndGetOtherAttributeTest() { + Map expectedValues = new HashMap<>(); + + expectedValues.put(QName.valueOf("1"), "a"); + expectedValues.put(QName.valueOf("2"), "b"); + expectedValues.put(QName.valueOf("3"), "c"); + + kapuaTad.putOtherAttribute(QName.valueOf("1"), "a"); + kapuaTad.putOtherAttribute(QName.valueOf("2"), "b"); + kapuaTad.putOtherAttribute(QName.valueOf("3"), "c"); + + Assert.assertEquals("tadImpl.attributes", expectedValues, kapuaTad.getOtherAttributes()); + } + + @Test + public void getOtherAttributeTest() { + Assert.assertTrue(kapuaTad.getOtherAttributes().isEmpty()); + } +} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTattributeTest.java similarity index 76% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTattributeTest.java index 936a1119b0b..131abfa8c44 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TattributeImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTattributeTest.java @@ -10,7 +10,7 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,17 +18,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) -public class TattributeImplTest { +public class KapuaTattributeTest { @Before public void createInstanceOfClass() { - tattributeImpl = new TattributeImpl(); + tattributeImpl = new KapuaTattribute(); } - TattributeImpl tattributeImpl; + KapuaTattribute tattributeImpl; @Test public void getValueTest() { @@ -48,7 +47,7 @@ public void setAndGetAdrefToNullTest() { @Test public void setAndGetAdrefTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularAdref", "regular Adref", "49", "regularAdref49", "ADREF", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularAdref", "regular Adref", "49", "regularAdref49", "ADREF", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { tattributeImpl.setAdref(value); Assert.assertTrue(tattributeImpl.getAdref().contains(value)); @@ -63,7 +62,8 @@ public void setAndGetContentToNullTest() { @Test public void setAndGetContentTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularContent", "regular Content", "49", "regularContent49", "CONTENT", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularContent", "regular Content", "49", "regularContent49", "CONTENT", + "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { tattributeImpl.setContent(value); Assert.assertTrue(tattributeImpl.getContent().contains(value)); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignateTest.java similarity index 80% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignateTest.java index b239249089c..0ee4d41d154 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TdesignateImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTdesignateTest.java @@ -10,7 +10,9 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; + +import java.util.ArrayList; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,19 +20,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.ArrayList; - - @Category(JUnitTests.class) -public class TdesignateImplTest { +public class KapuaTdesignateTest { @Before public void createInstanceOfClass() { - tdesignate = new TdesignateImpl(); + tdesignate = new KapuaTdesignate(); } - TdesignateImpl tdesignate; + KapuaTdesignate tdesignate; @Test public void setAndGetObjectToNullTest() { @@ -40,7 +39,7 @@ public void setAndGetObjectToNullTest() { @Test public void setAndGetObjectTest() { - TobjectImpl tobject = new TobjectImpl(); + KapuaTobject tobject = new KapuaTobject(); tdesignate.setObject(tobject); Assert.assertEquals("tdesignate.object", tobject, tdesignate.getObject()); } @@ -65,7 +64,7 @@ public void setAndGetAnyTest() { objectArrayList.add(11122.33); objectArrayList.add(true); objectArrayList.add(false); - objectArrayList.add(new ToptionImpl()); + objectArrayList.add(new KapuaToption()); tdesignate.setAny(objectArrayList); Assert.assertEquals("tdesignate.any", objectArrayList, tdesignate.getAny()); @@ -79,7 +78,7 @@ public void setAndGetPidToNullTest() { @Test public void setAndGetPidTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularPid", "regular Pid", "49", "regularPid49", "PID", "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularPid", "regular Pid", "49", "regularPid49", "PID", "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844" }; for (String value : permittedValues) { tdesignate.setPid(value); Assert.assertTrue(tdesignate.getPid().contains(value)); @@ -94,7 +93,7 @@ public void setAndGetFactoryPidToNullTest() { @Test public void setAndGetFactoryPidTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularPid", "regular Pid", "49", "regularPid49", "PID", "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularPid", "regular Pid", "49", "regularPid49", "PID", "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844" }; for (String value : permittedValues) { tdesignate.setFactoryPid(value); Assert.assertTrue(tdesignate.getFactoryPid().contains(value)); @@ -109,7 +108,8 @@ public void setAndGetBundleToNullTest() { @Test public void setAndGetBundleTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularBundle", "regular Bundle", "49", "regularBundle49", "BUNDLE", "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularBundle", "regular Bundle", "49", "regularBundle49", "BUNDLE", + "2 46 465494 13564612 0009 09004 9684646496468456468496846464968496844" }; for (String value : permittedValues) { tdesignate.setBundle(value); Assert.assertTrue(tdesignate.getBundle().contains(value)); @@ -124,7 +124,7 @@ public void setAndGetOptionalToNullTest() { @Test public void setAndIsOptionalTest() { - boolean[] permittedValues = {false, true}; + boolean[] permittedValues = { false, true }; for (boolean value : permittedValues) { tdesignate.setOptional(value); Assert.assertEquals("tdesignate.isOptional", value, tdesignate.isOptional()); @@ -139,7 +139,7 @@ public void setAndGetMergeToNullTest() { @Test public void setAndIsMergeTest() { - boolean[] permittedValues = {false, true}; + boolean[] permittedValues = { false, true }; for (boolean value : permittedValues) { tdesignate.setMerge(value); Assert.assertEquals("tdesignate.isMerge", value, tdesignate.isMerge()); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TiconImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTiconTest.java similarity index 85% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TiconImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTiconTest.java index 1ebc734d38e..be81b085155 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TiconImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTiconTest.java @@ -10,7 +10,9 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; + +import java.math.BigInteger; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,19 +20,17 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import java.math.BigInteger; - - @Category(JUnitTests.class) -public class TiconImplTest { +public class KapuaTiconTest { @Before public void createInstanceOfClass() { - ticonImpl = new TiconImpl(); + ticonImpl = new KapuaTicon(); } - TiconImpl ticonImpl; + KapuaTicon ticonImpl; + @Test public void getAnyTest() { Assert.assertTrue(ticonImpl.getAny().isEmpty()); @@ -44,7 +44,7 @@ public void setAndGetResourcesToNullTest() { @Test public void setAndGetResourcesTest() { - String[] permittedValues = {"", "regularResources", "49", "regular Resources", "regular esources with spaces", "!@#$%&*()_+/->,<", "RESOURCES", "resources123"}; + String[] permittedValues = { "", "regularResources", "49", "regular Resources", "regular esources with spaces", "!@#$%&*()_+/->,<", "RESOURCES", "resources123" }; for (String value : permittedValues) { ticonImpl.setResource(value); Assert.assertTrue(ticonImpl.getResource().contains(value)); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadataTest.java similarity index 82% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadataTest.java index d2bafa6b3ba..1af97f2ad92 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TmetadataImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTmetadataTest.java @@ -10,38 +10,36 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; -import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.xml.namespace.QName; + +import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; @Category(JUnitTests.class) -public class TmetadataImplTest { +public class KapuaTmetadataTest { @Before public void createInstanceOfClasses() { emptyTocd = new EmptyTocd(); - tocd = new TocdImpl(); - tmetadata = new TmetadataImpl(); - tdesignate = new TdesignateImpl(); + tocd = new KapuaTocd(); + tmetadata = new KapuaTmetadata(); + tdesignate = new KapuaTdesignate(); } EmptyTocd emptyTocd; - TocdImpl tocd; - TmetadataImpl tmetadata; - TdesignateImpl tdesignate; + KapuaTocd tocd; + KapuaTmetadata tmetadata; + KapuaTdesignate tdesignate; @Test public void getOCDTest() { @@ -92,7 +90,8 @@ public void setAndGetLocalizationToNullTest() { @Test public void setAndGetLocalizationTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularLocalization", "regular Localization", "49", "regularLocalization49", "LOCALIZATION", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularLocalization", "regular Localization", "49", "regularLocalization49", "LOCALIZATION", + "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { tmetadata.setLocalization(value); Assert.assertTrue(tmetadata.getLocalization().contains(value)); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTobjectTest.java similarity index 80% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTobjectTest.java index 00464a9ac19..54ace97a6f5 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/TobjectImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTobjectTest.java @@ -10,7 +10,7 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,16 +18,15 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) -public class TobjectImplTest { +public class KapuaTobjectTest { @Before public void createInstanceOfClasses() { - tobjectImpl = new TobjectImpl(); + tobjectImpl = new KapuaTobject(); } - TobjectImpl tobjectImpl; + KapuaTobject tobjectImpl; @Test public void getAttributeTest() { @@ -47,7 +46,8 @@ public void setAndGetOcdrefToNullTest() { @Test public void setAndGetOcdrefTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularOcdref", "regular Ocdref", "49", "regularOcdref49", "OCDREF", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularOcdref", "regular Ocdref", "49", "regularOcdref49", "OCDREF", + "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { tobjectImpl.setOcdref(value); Assert.assertTrue(tobjectImpl.getOcdref().contains(value)); diff --git a/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTocdTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTocdTest.java new file mode 100644 index 00000000000..5d65a8e45dc --- /dev/null +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaTocdTest.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2020, 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.model.config.metatype; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(JUnitTests.class) +public class KapuaTocdTest { + + @Before + public void createInstanceOfClasses() { + + kapuaTocd = new KapuaTocd(); + kapuaTad1 = new KapuaTad(); + kapuaTad2 = new KapuaTad(); + kapuaTad3 = new KapuaTad(); + ticon = new KapuaTicon(); + ticon2 = new KapuaTicon(); + } + + KapuaTocd kapuaTocd; + KapuaTad kapuaTad1; + KapuaTad kapuaTad2; + KapuaTad kapuaTad3; + KapuaTicon ticon; + KapuaTicon ticon2; + + @Test + public void getADTest() { + Assert.assertTrue(kapuaTocd.getAD().isEmpty()); + } + + @Test + public void setAndGetADTest() { + List expectedValues = new ArrayList<>(); + expectedValues.add(kapuaTad1); + kapuaTocd.setAD(expectedValues); + Assert.assertEquals("tocdImpl.ad", expectedValues, kapuaTocd.getAD()); + } + + @Test + public void addAndGetADTest() { + kapuaTocd.addAD(kapuaTad3); + kapuaTocd.addAD(kapuaTad2); + kapuaTocd.getAD(); + Assert.assertTrue(kapuaTocd.getAD().contains(kapuaTad3) && kapuaTocd.getAD().contains(kapuaTad2)); + } + + @Test + public void getIconTest() { + Assert.assertTrue(kapuaTocd.getIcon().isEmpty()); + } + + @Test + public void setAndGetIconTest() { + List listOfObj = new ArrayList<>(); + listOfObj.add(ticon); + kapuaTocd.setIcon(listOfObj); + Assert.assertEquals("tocdImpl.icon", listOfObj, kapuaTocd.getIcon()); + } + + @Test + public void addAndGetIconTest() { + kapuaTocd.addIcon(ticon); + kapuaTocd.addIcon(ticon2); + kapuaTocd.getIcon(); + Assert.assertTrue(kapuaTocd.getIcon().contains(ticon) && kapuaTocd.getIcon().contains(ticon2)); + } + + @Test + public void getAnyTest() { + Assert.assertTrue(kapuaTocd.getAny().isEmpty()); + } + + @Test + public void setAndGetAnyTest() { + List options = new ArrayList<>(); + options.add(ticon); + options.add(ticon2); + kapuaTocd.setAny(options); + Assert.assertEquals("tocdImpl.any", options, kapuaTocd.getAny()); + } + + @Test + public void addAndGetAnyTest() { + kapuaTocd.addAny(ticon); + kapuaTocd.addAny(ticon2); + Assert.assertTrue(kapuaTocd.getAny().contains(ticon) && kapuaTocd.getAny().contains(ticon2)); + } + + @Test + public void setAndGetNameToNullTest() { + kapuaTocd.setName(null); + Assert.assertNull(kapuaTocd.getName()); + } + + @Test + public void setAndGetNameTest() { + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularName", "regular Name", "49", "regularName49", "REGULAR", "246465494135646120009090049684646496468456468496846464968496844" }; + for (String value : permittedValues) { + kapuaTocd.setName(value); + Assert.assertTrue(kapuaTocd.getName().contains(value)); + } + } + + @Test + public void setAndGetDescriptionToNullTest() { + kapuaTocd.setDescription(null); + Assert.assertNull(kapuaTocd.getDescription()); + } + + @Test + public void setAndGetDescriptionTest() { + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regular Description", "49", "regularDescription49", "DESCRIPTION", "246465494135646120009090049684646496468456468496846464968496844" }; + for (String value : permittedValues) { + kapuaTocd.setDescription(value); + Assert.assertTrue(kapuaTocd.getDescription().contains(value)); + } + } + + @Test + public void setAndGetIdToNullTest() { + kapuaTocd.setId(null); + Assert.assertNull(kapuaTocd.getId()); + } + + @Test + public void setAndGetIdTest() { + String[] permittedValues = { "", "regularId", "49", "regular Id", "regular id with spaces", "!@#$%&*()_+/->,<", "ID", "id123" }; + for (String value : permittedValues) { + kapuaTocd.setId(value); + Assert.assertTrue(kapuaTocd.getId().contains(value)); + } + } + + @Test + public void putAndGetOtherAttributeTest() { + Map expectedValues = new HashMap<>(); + + expectedValues.put(QName.valueOf("1"), "a"); + expectedValues.put(QName.valueOf("2"), "b"); + expectedValues.put(QName.valueOf("3"), "c"); + + kapuaTocd.putOtherAttribute(QName.valueOf("1"), "a"); + kapuaTocd.putOtherAttribute(QName.valueOf("2"), "b"); + kapuaTocd.putOtherAttribute(QName.valueOf("3"), "c"); + + Assert.assertEquals("tocdImpl.otherAttributes", expectedValues, kapuaTocd.getOtherAttributes()); + } + + @Test + public void getOtherAttributeTest() { + Assert.assertTrue(kapuaTocd.getOtherAttributes().isEmpty()); + } + + @Test + public void testSetAndGetOtherAttribute() { + Map values = new HashMap<>(); + + values.put(QName.valueOf("1"), "a"); + values.put(QName.valueOf("2"), "b"); + values.put(QName.valueOf("3"), "c"); + + kapuaTocd.setOtherAttributes(values); + Assert.assertEquals("tocdImpl.otherAttributes", values, kapuaTocd.getOtherAttributes()); + } +} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImplTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaToptionTest.java similarity index 76% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImplTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaToptionTest.java index a356e292cb8..fe008696b4a 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/ToptionImplTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/KapuaToptionTest.java @@ -10,7 +10,7 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -18,17 +18,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) -public class ToptionImplTest { +public class KapuaToptionTest { @Before public void createInstanceOfClass() { - toption = new ToptionImpl(); + toption = new KapuaToption(); } - ToptionImpl toption; + KapuaToption toption; @Test public void getAnyWithNullTest() { @@ -43,7 +42,7 @@ public void setAndGetLabelToNullTest() { @Test public void setAndGetLabelTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularLabel", "regular Label", "49", "regularLabel49", "LABEL", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularLabel", "regular Label", "49", "regularLabel49", "LABEL", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { toption.setLabel(value); Assert.assertTrue(toption.getLabel().contains(value)); @@ -58,7 +57,7 @@ public void setAndGetValueToNullTest() { @Test public void setAndGetValueTest() { - String[] permittedValues = {"", "!@#$%^^&**(-()_)+/|", "regularValue", "regular Value", "49", "regularValue49", "VALUE", "246465494135646120009090049684646496468456468496846464968496844"}; + String[] permittedValues = { "", "!@#$%^^&**(-()_)+/|", "regularValue", "regular Value", "49", "regularValue49", "VALUE", "246465494135646120009090049684646496468456468496846464968496844" }; for (String value : permittedValues) { toption.setValue(value); Assert.assertTrue(toption.getValue().contains(value)); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/PasswordTest.java b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/PasswordTest.java similarity index 95% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/PasswordTest.java rename to service/api/src/test/java/org/eclipse/kapua/model/config/metatype/PasswordTest.java index 332fbc2396d..ea2faddf4aa 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/metatype/PasswordTest.java +++ b/service/api/src/test/java/org/eclipse/kapua/model/config/metatype/PasswordTest.java @@ -10,14 +10,13 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.configuration.metatype; +package org.eclipse.kapua.model.config.metatype; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) public class PasswordTest { diff --git a/service/authentication-app/src/main/java/org/eclipse/kapua/service/authentication/AuthenticationJAXBContextProvider.java b/service/authentication-app/src/main/java/org/eclipse/kapua/service/authentication/AuthenticationJAXBContextProvider.java index 6924ef94b52..e70be5bd8cc 100644 --- a/service/authentication-app/src/main/java/org/eclipse/kapua/service/authentication/AuthenticationJAXBContextProvider.java +++ b/service/authentication-app/src/main/java/org/eclipse/kapua/service/authentication/AuthenticationJAXBContextProvider.java @@ -15,7 +15,6 @@ import javax.xml.bind.JAXBContext; import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; @@ -29,7 +28,7 @@ import org.eclipse.kapua.model.config.metatype.KapuaTobject; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,11 +51,10 @@ public JAXBContext getJAXBContext() throws KapuaException { KapuaTocd.class, KapuaTad.class, KapuaTicon.class, - TscalarImpl.class, + KapuaTscalar.class, KapuaToption.class, KapuaTdesignate.class, KapuaTobject.class, - MetatypeXmlRegistry.class, // Kapua Service Event ServiceEvent.class, EventStoreRecordCreator.class, diff --git a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreJAXBContextProvider.java b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreJAXBContextProvider.java index 02fb4a444b8..6e5524a4dd3 100644 --- a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreJAXBContextProvider.java +++ b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreJAXBContextProvider.java @@ -12,8 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.datastore.test.junit; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; + import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.TscalarImpl; import org.eclipse.kapua.commons.util.xml.JAXBContextProvider; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTdesignate; @@ -22,17 +27,12 @@ import org.eclipse.kapua.model.config.metatype.KapuaTobject; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; -import org.eclipse.kapua.model.config.metatype.MetatypeXmlRegistry; +import org.eclipse.kapua.model.config.metatype.KapuaTscalar; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.MarshallerProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import java.util.HashMap; -import java.util.Map; - public class DatastoreJAXBContextProvider implements JAXBContextProvider { private static final Logger logger = LoggerFactory.getLogger(DatastoreJAXBContextProvider.class); @@ -42,17 +42,16 @@ public class DatastoreJAXBContextProvider implements JAXBContextProvider { @Override public JAXBContext getJAXBContext() throws KapuaException { if (context == null) { - Class[] classes = new Class[]{ + Class[] classes = new Class[] { KapuaTmetadata.class, KapuaTocd.class, KapuaTad.class, KapuaTicon.class, - TscalarImpl.class, + KapuaTscalar.class, KapuaToption.class, KapuaTmetadata.class, KapuaTdesignate.class, - KapuaTobject.class, - MetatypeXmlRegistry.class + KapuaTobject.class }; try { Map properties = new HashMap<>(1); diff --git a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/configuration/KuraDeviceComponentConfiguration.java b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/configuration/KuraDeviceComponentConfiguration.java index 614412ad297..ec4f21ce160 100644 --- a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/configuration/KuraDeviceComponentConfiguration.java +++ b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/configuration/KuraDeviceComponentConfiguration.java @@ -12,12 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.call.kura.model.configuration; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; -import org.eclipse.kapua.model.config.metatype.KapuaTocd; -import org.eclipse.kapua.service.device.call.kura.model.configuration.xml.KuraXmlConfigPropertiesAdapter; +import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -25,14 +20,18 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Map; + +import org.eclipse.kapua.model.config.metatype.KapuaTocd; +import org.eclipse.kapua.service.device.call.kura.model.configuration.xml.KuraXmlConfigPropertiesAdapter; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; /** - * Describes the configuration of an OSGi Component.
- * The Component configuration groups all the information related to the configuration of a Component.
- * It provides access to parsed ObjectClassDefintion associated to this Component.
- * The configuration does not reuse the OSGi ObjectClassDefinition as the latter does not provide access to certain aspects such as the required attribute, the min and max values.
- * Instead it returns the raw ObjectClassDefintion as parsed from the MetaType Information XML resource associated to this Component. + * Describes the configuration of an OSGi Component.
The Component configuration groups all the information related to the configuration of a Component.
It provides access to parsed + * ObjectClassDefintion associated to this Component.
The configuration does not reuse the OSGi ObjectClassDefinition as the latter does not provide access to certain aspects such as the required + * attribute, the min and max values.
Instead it returns the raw ObjectClassDefintion as parsed from the MetaType Information XML resource associated to this Component. * * @since 1.0 */ @@ -41,23 +40,19 @@ public class KuraDeviceComponentConfiguration { /** - * The PID (service's persistent identity) of the OSGi Component - * associated to this configuration.
- * The service's persistent identity is defined as the name attribute of the - * Component Descriptor XML file; at runtime, the same value is also available - * in the component.name and in the service.pid attributes of the Component Configuration. + * The PID (service's persistent identity) of the OSGi Component associated to this configuration.
The service's persistent identity is defined as the name attribute of the Component + * Descriptor XML file; at runtime, the same value is also available in the component.name and in the service.pid attributes of the Component Configuration. */ @JsonProperty("pid") @XmlAttribute(name = "pid") private String componentId; /** - * The raw ObjectClassDefinition as parsed from the MetaType - * Information XML resource associated to this Component. + * The raw ObjectClassDefinition as parsed from the MetaType Information XML resource associated to this Component. */ @JsonIgnore @XmlElementRef(type = KapuaTocd.class) - private TocdImpl definition; + private KapuaTocd definition; /** * The Dictionary of properties currently used by this component. @@ -72,12 +67,8 @@ public KuraDeviceComponentConfiguration() { } /** - * Get the component identifier.
- * The PID (service's persistent identity) of the OSGi Component - * associated to this configuration.
- * The service's persistent identity is defined as the name attribute of the - * Component Descriptor XML file; at runtime, the same value is also available - * in the component.name and in the service.pid attributes of the Component Configuration. + * Get the component identifier.
The PID (service's persistent identity) of the OSGi Component associated to this configuration.
The service's persistent identity is defined as the name + * attribute of the Component Descriptor XML file; at runtime, the same value is also available in the component.name and in the service.pid attributes of the Component Configuration. * * @return */ @@ -95,9 +86,7 @@ public void setComponentId(String componentId) { } /** - * Get the class definition.
- * The raw ObjectClassDefinition as parsed from the MetaType - * Information XML resource associated to this Component. + * Get the class definition.
The raw ObjectClassDefinition as parsed from the MetaType Information XML resource associated to this Component. * * @return */ @@ -111,12 +100,11 @@ public KapuaTocd getDefinition() { * @param definition */ public void setDefinition(KapuaTocd definition) { - this.definition = (TocdImpl) definition; + this.definition = definition; } /** - * Get configuration properties.
- * The Dictionary of properties currently used by this component. + * Get configuration properties.
The Dictionary of properties currently used by this component. * * @return */ diff --git a/service/device/management/asset-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/asset/store/dummy/DeviceAssetStoreServiceDummy.java b/service/device/management/asset-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/asset/store/dummy/DeviceAssetStoreServiceDummy.java index f044fdf7076..b8df0cf5965 100644 --- a/service/device/management/asset-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/asset/store/dummy/DeviceAssetStoreServiceDummy.java +++ b/service/device/management/asset-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/asset/store/dummy/DeviceAssetStoreServiceDummy.java @@ -12,18 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset.store.dummy; -import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; +import java.util.Map; + +import javax.inject.Singleton; + import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; import org.eclipse.kapua.message.device.data.KapuaDataMessage; +import org.eclipse.kapua.model.config.metatype.EmptyTocd; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.asset.DeviceAssets; import org.eclipse.kapua.service.device.management.asset.store.DeviceAssetStoreService; import org.eclipse.kapua.service.device.management.asset.store.settings.DeviceAssetStoreSettings; -import javax.inject.Singleton; -import java.util.Map; - /** * {@link DeviceAssetStoreService} implementation. * diff --git a/service/device/management/configuration-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/configuration/store/dummy/DeviceConfigurationStoreServiceDummy.java b/service/device/management/configuration-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/configuration/store/dummy/DeviceConfigurationStoreServiceDummy.java index 77c8b489bd6..4c57f7d5b33 100644 --- a/service/device/management/configuration-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/configuration/store/dummy/DeviceConfigurationStoreServiceDummy.java +++ b/service/device/management/configuration-store/dummy/src/main/java/org/eclipse/kapua/service/device/management/configuration/store/dummy/DeviceConfigurationStoreServiceDummy.java @@ -12,8 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.configuration.store.dummy; -import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; +import java.util.Map; + +import javax.inject.Singleton; + import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; +import org.eclipse.kapua.model.config.metatype.EmptyTocd; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.configuration.DeviceComponentConfiguration; @@ -21,9 +25,6 @@ import org.eclipse.kapua.service.device.management.configuration.store.DeviceConfigurationStoreService; import org.eclipse.kapua.service.device.management.configuration.store.settings.DeviceConfigurationStoreSettings; -import javax.inject.Singleton; -import java.util.Map; - /** * {@link DeviceConfigurationStoreService} dummy implementation. * diff --git a/service/device/management/configuration/api/src/main/java/org/eclipse/kapua/service/device/management/configuration/DeviceXmlConfigPropertiesAdapter.java b/service/device/management/configuration/api/src/main/java/org/eclipse/kapua/service/device/management/configuration/DeviceXmlConfigPropertiesAdapter.java index e73c118a9db..111fc9a1707 100644 --- a/service/device/management/configuration/api/src/main/java/org/eclipse/kapua/service/device/management/configuration/DeviceXmlConfigPropertiesAdapter.java +++ b/service/device/management/configuration/api/src/main/java/org/eclipse/kapua/service/device/management/configuration/DeviceXmlConfigPropertiesAdapter.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.configuration; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + import org.eclipse.kapua.commons.configuration.metatype.PasswordPropertyAdapter; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.locator.KapuaLocator; @@ -28,10 +33,6 @@ import org.eclipse.kapua.model.xml.adapters.XmlPropertyAdapter; import org.eclipse.kapua.service.device.management.configuration.DeviceXmlConfigPropertyAdapted.ConfigPropertyType; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.HashMap; -import java.util.Map; - /** * Xml configuration properties adapter. It marshal and unmarshal configuration properties in a proper way. * @@ -39,7 +40,9 @@ */ public class DeviceXmlConfigPropertiesAdapter extends XmlAdapter> { - private XmlPropertiesAdapter adapter = new XmlPropertiesAdapter<>(DeviceXmlConfigPropertyAdapted.class, () -> new DeviceXmlConfigPropertyAdapted(), new HashMap() { + private XmlPropertiesAdapter adapter = new XmlPropertiesAdapter<>(DeviceXmlConfigPropertyAdapted.class, + () -> new DeviceXmlConfigPropertyAdapted(), new HashMap() { + { put(ConfigPropertyType.stringType, new StringPropertyAdapter()); put(ConfigPropertyType.longType, new LongPropertyAdapter()); diff --git a/service/device/management/configuration/internal/src/main/java/org/eclipse/kapua/service/device/management/configuration/internal/DeviceComponentConfigurationImpl.java b/service/device/management/configuration/internal/src/main/java/org/eclipse/kapua/service/device/management/configuration/internal/DeviceComponentConfigurationImpl.java index 2d366ea137f..9bb37435150 100644 --- a/service/device/management/configuration/internal/src/main/java/org/eclipse/kapua/service/device/management/configuration/internal/DeviceComponentConfigurationImpl.java +++ b/service/device/management/configuration/internal/src/main/java/org/eclipse/kapua/service/device/management/configuration/internal/DeviceComponentConfigurationImpl.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.configuration.internal; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; +import java.util.Map; + import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.service.device.management.configuration.DeviceComponentConfiguration; -import java.util.Map; - /** * Device component configuration entity implementation. * @@ -27,7 +26,7 @@ public class DeviceComponentConfigurationImpl implements DeviceComponentConfigur private String id; private String name; - private TocdImpl definition; + private KapuaTocd definition; private Map properties; /** @@ -41,7 +40,8 @@ public DeviceComponentConfigurationImpl() { /** * Constructor. * - * @param id The {@link DeviceComponentConfiguration#getId()} + * @param id + * The {@link DeviceComponentConfiguration#getId()} * @since 1.0.0 */ public DeviceComponentConfigurationImpl(String id) { @@ -70,7 +70,7 @@ public void setName(String name) { @Override public void setDefinition(KapuaTocd definition) { - this.definition = (TocdImpl) definition; + this.definition = definition; } @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java index bd018a85761..163a8f6a252 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java @@ -39,7 +39,6 @@ import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.event.ServiceEventBus; import org.eclipse.kapua.event.ServiceEventBusException; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.domain.Domain; import org.eclipse.kapua.model.domain.DomainEntry; @@ -258,7 +257,6 @@ ServiceConfigurationManager deviceConnectionServiceConfigurationManager( RootUserTester rootUserTester, KapuaJpaRepositoryConfiguration jpaRepoConfig, Map availableDeviceConnectionAdapters, - KapuaMetatypeFactory kapuaMetatypeFactory, EntityCacheFactory entityCacheFactory, KapuaDeviceRegistrySettings kapuaDeviceRegistrySettings, XmlUtil xmlUtil) { @@ -270,7 +268,6 @@ ServiceConfigurationManager deviceConnectionServiceConfigurationManager( ), rootUserTester, availableDeviceConnectionAdapters, - kapuaMetatypeFactory, kapuaDeviceRegistrySettings, xmlUtil) ); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java index ff70679452d..1a74f7b6f44 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java @@ -23,7 +23,6 @@ import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.util.xml.XmlUtil; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; @@ -45,7 +44,6 @@ public class DeviceConnectionServiceConfigurationManager extends ServiceConfigur private final Map availableDeviceConnectionAdapters; private final KapuaDeviceRegistrySettings deviceRegistrySettings; - private final KapuaMetatypeFactory kapuaMetatypeFactory; /** * Constructor. @@ -56,21 +54,17 @@ public class DeviceConnectionServiceConfigurationManager extends ServiceConfigur * The {@link RootUserTester} instance. * @param availableDeviceConnectionAdapters * The {@link Map} of available {@link DeviceConnectionCredentialAdapter}. - * @param kapuaMetatypeFactory - * The {@link KapuaMetatypeFactory} instance. * @since 2.0.0 */ public DeviceConnectionServiceConfigurationManager( ServiceConfigRepository serviceConfigRepository, RootUserTester rootUserTester, Map availableDeviceConnectionAdapters, - KapuaMetatypeFactory kapuaMetatypeFactory, KapuaDeviceRegistrySettings kapuaDeviceRegistrySettings, XmlUtil xmlUtil) { super(DeviceConnectionService.class.getName(), serviceConfigRepository, rootUserTester, xmlUtil); this.availableDeviceConnectionAdapters = availableDeviceConnectionAdapters; - this.kapuaMetatypeFactory = kapuaMetatypeFactory; this.deviceRegistrySettings = kapuaDeviceRegistrySettings; } @@ -107,7 +101,7 @@ public KapuaTocd getConfigMetadata(TxContext txContext, KapuaId scopeId, boolean .keySet() .stream() .map(authType -> { - KapuaToption authTypeToption = kapuaMetatypeFactory.newKapuaToption(); + KapuaToption authTypeToption = new KapuaToption(); authTypeToption.setLabel(authType); authTypeToption.setValue(authType); return authTypeToption; diff --git a/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java b/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java index 8064339b11b..52319448367 100644 --- a/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java +++ b/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java @@ -12,18 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -41,7 +36,6 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.message.KapuaMessageFactory; import org.eclipse.kapua.message.internal.KapuaMessageFactoryImpl; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountService; @@ -87,8 +81,14 @@ import org.mockito.Matchers; import org.mockito.Mockito; -import java.util.HashMap; -import java.util.Map; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; @Singleton public class DeviceRegistryLocatorConfiguration { @@ -133,8 +133,6 @@ protected void configure() { bind(AccountService.class).toInstance(Mockito.mock(AccountService.class)); bind(RootUserTester.class).toInstance(Mockito.mock(RootUserTester.class)); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // Inject actual Device registry service related services //TODO: FIXME: PRIORITY: build test instance @@ -180,7 +178,8 @@ protected void configure() { bind(DeviceEventFactory.class).toInstance(new DeviceEventFactoryImpl()); bind(KapuaMessageFactory.class).toInstance(new KapuaMessageFactoryImpl()); - final DeviceValidation deviceValidation = new DeviceValidationImpl(new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), + final DeviceValidation deviceValidation = new DeviceValidationImpl( + new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_EXTENDED_PROPERTIES_LENGTH_MAX), mockedAuthorization, permissionFactory, diff --git a/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java b/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java index f3498d75669..665fc6d35d7 100644 --- a/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java +++ b/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java @@ -15,7 +15,6 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -30,7 +29,6 @@ import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.job.engine.JobEngineService; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -121,7 +119,6 @@ protected void configure() { bind(MetricsService.class).to(MetricsServiceImpl.class).in(Singleton.class); // Commons - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); // Account diff --git a/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java b/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java index 4c2dcf1beeb..b30cec0e93a 100644 --- a/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java +++ b/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -32,7 +31,6 @@ import org.eclipse.kapua.job.engine.client.JobEngineServiceClient; import org.eclipse.kapua.job.engine.client.settings.JobEngineClientSetting; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -110,8 +108,6 @@ protected void configure() { // Inject mocked Permission Factory final PermissionFactory permissionFactory = Mockito.mock(PermissionFactory.class); bind(PermissionFactory.class).toInstance(permissionFactory); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // binding Account related services bind(AccountRelativeFinder.class).toInstance(Mockito.mock(AccountRelativeFinder.class)); diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java index d898bc207bd..abcc2da0c2a 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java @@ -12,14 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.internal; -import com.google.common.base.Strings; -import com.google.common.collect.Sets; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.util.ArgumentValidator; import org.eclipse.kapua.commons.util.KapuaFileUtils; +import org.eclipse.kapua.model.config.metatype.EmptyTocd; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; @@ -43,12 +49,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.common.base.Strings; +import com.google.common.collect.Sets; @Singleton public class CertificateServiceImpl implements CertificateService { @@ -65,7 +67,7 @@ public class CertificateServiceImpl implements CertificateService { @Inject public CertificateServiceImpl(AuthorizationService authorizationService, PermissionFactory permissionFactory, CertificateFactory certificateFactory, - KapuaCertificateSetting kapuaCertificateSetting) throws KapuaException { + KapuaCertificateSetting kapuaCertificateSetting) throws KapuaException { this.authorizationService = authorizationService; this.permissionFactory = permissionFactory; this.certificateFactory = certificateFactory; diff --git a/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java b/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java index ed2dbb4c9f3..7edc2e64063 100644 --- a/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java +++ b/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java @@ -21,7 +21,6 @@ import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -37,7 +36,6 @@ import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -137,8 +135,6 @@ protected void configure() { // Inject mocked Permission Factory PermissionFactory mockPermissionFactory = Mockito.mock(PermissionFactory.class); bind(PermissionFactory.class).toInstance(mockPermissionFactory); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // Inject actual Role service related services final KapuaJpaRepositoryConfiguration jpaRepoConfig = new KapuaJpaRepositoryConfiguration(); diff --git a/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java b/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java index 6d472a6a28c..4c6eeb797a6 100644 --- a/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java +++ b/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java @@ -12,15 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.systeminfo.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -31,7 +23,6 @@ import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.service.account.AccountFactory; @@ -51,13 +42,20 @@ import org.mockito.Matchers; import org.mockito.Mockito; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; + @Singleton public class SystemInfoLocatorConfiguration { /** - * Setup DI with Google Guice DI. - * Create mocked and non mocked service under test and bind them with Guice. - * It is based on custom MockedLocator locator that is meant for service unit tests. + * Setup DI with Google Guice DI. Create mocked and non mocked service under test and bind them with Guice. It is based on custom MockedLocator locator that is meant for service unit tests. */ @Before(value = "@setup", order = 1) public void setupDI() { @@ -92,8 +90,6 @@ protected void configure() { bind(AuthorizationService.class).toInstance(mockedAuthorization); // Inject mocked Permission Factory bind(PermissionFactory.class).toInstance(Mockito.mock(PermissionFactory.class)); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // binding Account related services bind(AccountService.class).toInstance(Mockito.mock(AccountService.class)); diff --git a/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java b/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java index f867da80f3f..f6eadfb7310 100644 --- a/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java +++ b/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java @@ -12,18 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; +import java.util.Collections; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -41,7 +35,6 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.message.KapuaMessageFactory; import org.eclipse.kapua.message.internal.KapuaMessageFactoryImpl; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.service.account.AccountFactory; @@ -87,15 +80,20 @@ import org.mockito.Matchers; import org.mockito.Mockito; -import java.util.Collections; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; @Singleton public class TagLocatorConfiguration { /** - * Setup DI with Google Guice DI. - * Create mocked and non mocked service under test and bind them with Guice. - * It is based on custom MockedLocator locator that is meant for service unit tests. + * Setup DI with Google Guice DI. Create mocked and non mocked service under test and bind them with Guice. It is based on custom MockedLocator locator that is meant for service unit tests. */ @Before(value = "@setup", order = 1) public void setupDI() { @@ -133,9 +131,6 @@ protected void configure() { } bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); - // binding Account related services bind(AccountRelativeFinder.class).toInstance(Mockito.mock(AccountRelativeFinder.class)); bind(AccountService.class).toInstance(Mockito.mock(AccountService.class)); @@ -170,7 +165,8 @@ protected void configure() { new DeviceEventImplJpaRepository(jpaRepoConfig) ); - final DeviceValidation deviceValidation = new DeviceValidationImpl(new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), + final DeviceValidation deviceValidation = new DeviceValidationImpl( + new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_EXTENDED_PROPERTIES_LENGTH_MAX), mockedAuthorization, permissionFactory, diff --git a/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java b/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java index 39e9e78e324..b2d0d2f95f3 100644 --- a/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java +++ b/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.UsedEntitiesCounterImpl; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -34,7 +33,6 @@ import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -107,8 +105,6 @@ protected void configure() { // Inject mocked Permission Factory PermissionFactory mockPermissionFactory = Mockito.mock(PermissionFactory.class); bind(PermissionFactory.class).toInstance(mockPermissionFactory); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); // binding Account related services final AccountRelativeFinder accountRelativeFinder = Mockito.mock(AccountRelativeFinder.class); diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppConfigurationKapuaKura.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppConfigurationKapuaKura.java index 00e30e04639..461152995ba 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppConfigurationKapuaKura.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppConfigurationKapuaKura.java @@ -20,14 +20,12 @@ import javax.inject.Inject; -import org.eclipse.kapua.commons.configuration.metatype.Password; -import org.eclipse.kapua.commons.configuration.metatype.TadImpl; -import org.eclipse.kapua.commons.configuration.metatype.TiconImpl; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; -import org.eclipse.kapua.commons.configuration.metatype.ToptionImpl; import org.eclipse.kapua.commons.util.xml.XmlUtil; +import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTicon; import org.eclipse.kapua.model.config.metatype.KapuaTocd; +import org.eclipse.kapua.model.config.metatype.KapuaToption; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.service.device.call.kura.model.configuration.ConfigurationMetrics; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceConfiguration; @@ -136,14 +134,14 @@ protected KuraDeviceConfiguration translate(DeviceConfiguration kapuaDeviceConfi } protected KapuaTocd translate(KapuaTocd kapuaDefinition) { - TocdImpl definition = new TocdImpl(); + KapuaTocd definition = new KapuaTocd(); definition.setId(kapuaDefinition.getId()); definition.setName(kapuaDefinition.getName()); definition.setDescription(kapuaDefinition.getDescription()); kapuaDefinition.getAD().forEach(kapuaAd -> { - TadImpl ad = new TadImpl(); + KapuaTad ad = new KapuaTad(); ad.setCardinality(kapuaAd.getCardinality()); ad.setDefault(ad.getDefault()); ad.setDescription(kapuaAd.getDescription()); @@ -155,7 +153,7 @@ protected KapuaTocd translate(KapuaTocd kapuaDefinition) { ad.setRequired(kapuaAd.isRequired()); kapuaAd.getOption().forEach(kuraToption -> { - ToptionImpl kapuaToption = new ToptionImpl(); + KapuaToption kapuaToption = new KapuaToption(); kapuaToption.setLabel(kuraToption.getLabel()); kapuaToption.setValue(kuraToption.getValue()); ad.addOption(kapuaToption); @@ -167,7 +165,7 @@ protected KapuaTocd translate(KapuaTocd kapuaDefinition) { }); kapuaDefinition.getIcon().forEach(kapuaIcon -> { - KapuaTicon icon = new TiconImpl(); + KapuaTicon icon = new KapuaTicon(); icon.setResource(kapuaIcon.getResource()); icon.setSize(kapuaIcon.getSize()); diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppConfigurationKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppConfigurationKuraKapua.java index aa0759627ef..6dcdc885cfd 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppConfigurationKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppConfigurationKuraKapua.java @@ -13,13 +13,16 @@ *******************************************************************************/ package org.eclipse.kapua.translator.kura.kapua; -import org.eclipse.kapua.commons.configuration.metatype.Password; -import org.eclipse.kapua.commons.configuration.metatype.TadImpl; -import org.eclipse.kapua.commons.configuration.metatype.TiconImpl; -import org.eclipse.kapua.commons.configuration.metatype.TocdImpl; -import org.eclipse.kapua.commons.configuration.metatype.ToptionImpl; +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; + +import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTicon; import org.eclipse.kapua.model.config.metatype.KapuaTocd; +import org.eclipse.kapua.model.config.metatype.KapuaToption; +import org.eclipse.kapua.model.config.metatype.Password; import org.eclipse.kapua.service.device.call.kura.model.configuration.ConfigurationMetrics; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration; import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceConfiguration; @@ -37,10 +40,6 @@ import org.eclipse.kapua.translator.exception.InvalidChannelException; import org.eclipse.kapua.translator.exception.InvalidPayloadException; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Map; - /** * {@link org.eclipse.kapua.translator.Translator} implementation from {@link KuraResponseMessage} to {@link ConfigurationResponseMessage} * @@ -104,14 +103,14 @@ private DeviceConfiguration translate(KuraDeviceConfiguration kuraDeviceConfigur } private KapuaTocd translate(KapuaTocd kuraDefinition) { - TocdImpl definition = new TocdImpl(); + KapuaTocd definition = new KapuaTocd(); definition.setId(kuraDefinition.getId()); definition.setName(kuraDefinition.getName()); definition.setDescription(kuraDefinition.getDescription()); kuraDefinition.getAD().forEach(kuraAd -> { - TadImpl ad = new TadImpl(); + KapuaTad ad = new KapuaTad(); ad.setCardinality(kuraAd.getCardinality()); ad.setDefault(ad.getDefault()); ad.setDescription(kuraAd.getDescription()); @@ -123,7 +122,7 @@ private KapuaTocd translate(KapuaTocd kuraDefinition) { ad.setRequired(kuraAd.isRequired()); kuraAd.getOption().forEach(kuraToption -> { - ToptionImpl kapuaToption = new ToptionImpl(); + KapuaToption kapuaToption = new KapuaToption(); kapuaToption.setLabel(kuraToption.getLabel()); kapuaToption.setValue(kuraToption.getValue()); ad.addOption(kapuaToption); @@ -134,7 +133,7 @@ private KapuaTocd translate(KapuaTocd kuraDefinition) { }); kuraDefinition.getIcon().forEach(kuraIcon -> { - KapuaTicon icon = new TiconImpl(); + KapuaTicon icon = new KapuaTicon(); icon.setResource(kuraIcon.getResource()); icon.setSize(kuraIcon.getSize()); definition.addIcon(icon); diff --git a/translator/test/src/test/java/org/eclipse/kapua/translator/test/TranslatorLocatorConfiguration.java b/translator/test/src/test/java/org/eclipse/kapua/translator/test/TranslatorLocatorConfiguration.java index 5b70d86b0d8..8b84694b410 100644 --- a/translator/test/src/test/java/org/eclipse/kapua/translator/test/TranslatorLocatorConfiguration.java +++ b/translator/test/src/test/java/org/eclipse/kapua/translator/test/TranslatorLocatorConfiguration.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.translator.test; import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; import org.eclipse.kapua.commons.crypto.CryptoUtilImpl; import org.eclipse.kapua.commons.crypto.setting.CryptoSettings; @@ -28,7 +27,6 @@ import org.eclipse.kapua.message.KapuaMessageFactory; import org.eclipse.kapua.message.device.data.KapuaDataMessageFactory; import org.eclipse.kapua.message.internal.KapuaMessageFactoryImpl; -import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; import org.eclipse.kapua.model.id.KapuaIdFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; @@ -116,8 +114,6 @@ protected void configure() { bind(DeviceConfigurationFactory.class).toInstance(Mockito.mock(DeviceConfigurationFactory.class)); bind(DeviceInventoryManagementFactory.class).toInstance(Mockito.mock(DeviceInventoryManagementFactory.class)); bind(DeviceKeystoreManagementFactory.class).toInstance(Mockito.mock(DeviceKeystoreManagementFactory.class)); - // Set KapuaMetatypeFactory for Metatype configuration - bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); } };