+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
/**
* Created by ayalaben on 9/26/2017
*/
-public class ElementToLimitConvertor extends ElementConvertor {
+public class ElementToLimitConvertor extends ElementConvertor<LimitEntity> {
@Override
- public Object convert(Element element) {
+ public LimitEntity convert(Element element) {
if (element == null) {
return null;
}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+
+public class ElementToEntitlementPoolConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+
+ private ElementToEntitlementPoolConvertor converter = new ElementToEntitlementPoolConvertor();
+
+
+ @Test
+ public void shouldConvertElementToEntitlementPoolEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ EntitlementPoolEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToEntitlementPoolEntity(){
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ EntitlementPoolEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ }
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.setName(ENTITY_NAME);
+ info.setDescription(ENTITY_DESCRIPTION);
+ return info;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+
+public class ElementToFeatureGroupConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+
+
+ private ElementToFeatureGroupConvertor converter = new ElementToFeatureGroupConvertor();
+
+ @Test
+ public void shouldConvertElementToFeatureGroupEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ FeatureGroupEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToFeatureGroupEntity(){
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ FeatureGroupEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ }
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.setName(ENTITY_NAME);
+ info.setDescription(ENTITY_DESCRIPTION);
+ return info;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import java.util.HashMap;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
+
+public class ElementToLicenseAgreementConvertorTest {
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+ private static final String LICENSE_TERM = "Fixed_Term";
+
+ private ElementToLicenseAgreementConvertor converter = new ElementToLicenseAgreementConvertor();
+
+ @Test
+ public void shouldConvertElementToLicenseAgreementEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ LicenseAgreementEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ assertEquals(LICENSE_TERM, result.getLicenseTerm().getChoice().name());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToLicenseAgreementEntity(){
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ LicenseAgreementEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID,result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ assertEquals(LICENSE_TERM, result.getLicenseTerm().getChoice().name());
+ }
+
+ private Info createInfo(){
+ Info info = new Info();
+ info.setName(ENTITY_NAME);
+ info.setDescription(ENTITY_DESCRIPTION);
+ HashMap<String,String> choiceOrOther = new HashMap<>();
+ choiceOrOther.put("choice", LICENSE_TERM);
+ choiceOrOther.put("other", "other");
+ info.addProperty("licenseTerm", choiceOrOther);
+ return info;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+
+public class ElementToLicenseKeyGroupConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+ private static final String LICENSE_KEY_TYPE = "Unique";
+
+ private ElementToLicenseKeyGroupConvertor converter = new ElementToLicenseKeyGroupConvertor();
+
+ @Test
+ public void shouldConvertElementToLicenseKeyGroupEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ Info info = createInfo();
+ elementToConvert.setInfo(info);
+ LicenseKeyGroupEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID,result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ assertEquals(LICENSE_KEY_TYPE, result.getType().name());
+
+ }
+
+
+ @Test
+ public void shouldConvertElementInfoToLicenseKeyGroupEntity() {
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ Info info = createInfo();
+ elementToConvert.setInfo(info);
+ LicenseKeyGroupEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID,result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ assertEquals(LICENSE_KEY_TYPE, result.getType().name());
+
+ }
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.setName(ENTITY_NAME);
+ info.setDescription(ENTITY_DESCRIPTION);
+ info.addProperty("LicenseKeyType",LICENSE_KEY_TYPE);
+ return info;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+
+public class ElementToLimitConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+ private static final String LIMIT_TYPE = "ServiceProvider";
+
+ private ElementToLimitConvertor converter = new ElementToLimitConvertor();
+
+ @Test
+ public void shouldConvertElementToLimitEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ Info info = new Info();
+ info.setName(ENTITY_NAME);
+ info.setDescription(ENTITY_DESCRIPTION);
+ info.addProperty("type",LIMIT_TYPE);
+ elementToConvert.setInfo(info);
+ LimitEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID,result.getId());
+ assertEquals(ENTITY_NAME, result.getName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ assertEquals(LIMIT_TYPE, result.getType().name());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
+
+public class ElementToVLMGeneralConvertorTest {
+
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+
+ private ElementToVLMGeneralConvertor converter = new ElementToVLMGeneralConvertor();
+
+ @Test
+ public void shouldConvertElementToVendorLicenseModelEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ Info info = new Info();
+ info.addProperty("name",ENTITY_NAME);
+ info.addProperty("description",ENTITY_DESCRIPTION);
+ elementToConvert.setInfo(info);
+ VendorLicenseModelEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_NAME, result.getVendorName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+
+
+ }
+
+ @Test
+ public void shouldConvertElementInfoToVendorLicenseModelEntity() {
+ ElementInfo elementInfo = new ElementInfo();
+ Info info = new Info();
+ info.addProperty("name",ENTITY_NAME);
+ info.addProperty("description",ENTITY_DESCRIPTION);
+ elementInfo.setInfo(info);
+ VendorLicenseModelEntity result = converter.convert(elementInfo);
+ assertEquals(ENTITY_NAME, result.getVendorName());
+ assertEquals(ENTITY_DESCRIPTION, result.getDescription());
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import java.io.ByteArrayInputStream;
+import org.junit.Test;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+
+public class ElementToComponentConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ENTITY_NAME = "entityTestName";
+ private static final String ENTITY_DISPLAY_NAME = "entityTestDisplayName";
+ private static final String ENTITY_DESCRIPTION = "entityTestDesc";
+ private static final String COMPOSITION_DATA =
+ "{\"name\":\"entityTestName\",\"description\":\"entityTestDesc\",\"displayName\":\"entityTestDisplayName\"}";
+
+ private ElementToComponentConvertor converter = new ElementToComponentConvertor();
+
+ @Test
+ public void shouldConvertElementToEntitlementPoolEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setData(new ByteArrayInputStream(COMPOSITION_DATA.getBytes()));
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ ComponentEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getComponentCompositionData().getName());
+ assertEquals(ENTITY_DISPLAY_NAME, result.getComponentCompositionData().getDisplayName());
+ assertEquals(ENTITY_DESCRIPTION, result.getComponentCompositionData().getDescription());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToEntitlementPoolEntity() {
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ ComponentEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ENTITY_NAME, result.getComponentCompositionData().getName());
+ assertEquals(ENTITY_DISPLAY_NAME, result.getComponentCompositionData().getDisplayName());
+ assertEquals(ENTITY_DESCRIPTION, result.getComponentCompositionData().getDescription());
+ }
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.addProperty("compositionData", COMPOSITION_DATA);
+ return info;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.junit.Test;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+
+public class ElementToComponentDependencyModelConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String SOURCE_ID = "sourceId1";
+ private static final String TARGET_ID = "targetId1";
+ private static final String RELATION_TYPE = "dependsOn";
+
+ private ElementToComponentDependencyModelConvertor converter = new ElementToComponentDependencyModelConvertor();
+
+
+ @Test
+ public void shouldConvertElementToComponentDependencyModelEntity() {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ ComponentDependencyModelEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(SOURCE_ID, result.getSourceComponentId());
+ assertEquals(TARGET_ID, result.getTargetComponentId());
+ assertEquals(RELATION_TYPE, result.getRelation());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToComponentDependencyModelEntity() {
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ ComponentDependencyModelEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(SOURCE_ID, result.getSourceComponentId());
+ assertEquals(TARGET_ID, result.getTargetComponentId());
+ assertEquals(RELATION_TYPE, result.getRelation());
+ }
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.addProperty("sourcecomponent_id", SOURCE_ID);
+ info.addProperty("targetcomponent_id", TARGET_ID);
+ info.addProperty("relation", RELATION_TYPE);
+ return info;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import static org.junit.Assert.assertEquals;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+
+public class ElementToComponentMonitoringUploadConvertorTest {
+
+ private static final String ENTITY_ID = "entityId1";
+ private static final String ARTIFACT_NAME ="testArtifact.zip";
+
+ private ElementToComponentMonitoringUploadConvertor converter = new ElementToComponentMonitoringUploadConvertor();
+
+
+ @Test
+ public void shouldConvertElementToComponentMonitoringUploadEntity() throws IOException {
+ ZusammenElement elementToConvert = new ZusammenElement();
+ elementToConvert.setElementId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ InputStream inputStreamMock = IOUtils.toInputStream("some test data for my input stream", "UTF-8");
+ elementToConvert.setData(inputStreamMock);
+ ComponentMonitoringUploadEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ARTIFACT_NAME, result.getArtifactName());
+ assertEquals("SNMP_TRAP", result.getType().name());
+ }
+
+ @Test
+ public void shouldConvertElementInfoToComponentMonitoringUploadEntity() {
+ ElementInfo elementToConvert = new ElementInfo();
+ elementToConvert.setId(new Id(ENTITY_ID));
+ elementToConvert.setInfo(createInfo());
+ ComponentMonitoringUploadEntity result = converter.convert(elementToConvert);
+ assertEquals(ENTITY_ID, result.getId());
+ assertEquals(ARTIFACT_NAME, result.getArtifactName());
+ assertEquals("SNMP_TRAP", result.getType().name());
+ }
+
+
+ private Info createInfo() {
+ Info info = new Info();
+ info.setName("SNMP_TRAP");
+ info.addProperty("artifactName", ARTIFACT_NAME);
+ return info;
+ }
+
+}