From cca36094faa88f90e62e8da8d612637201a9f896 Mon Sep 17 00:00:00 2001
From: erbel <johannes.erbel@cs.uni-goettingen.de>
Date: Fri, 21 Dec 2018 10:43:33 +0100
Subject: [PATCH] Added CreateElements example

---
 README.md                                     |  1 +
 config/html/model/index.html                  |  2 +-
 .../ugoe/cs/rwm/mocci/CreateElementsTest.java | 93 +++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 src/test/java/de/ugoe/cs/rwm/mocci/CreateElementsTest.java

diff --git a/README.md b/README.md
index 65858f5..2538163 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
 # Project Title
+[![build status](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/badges/master/pipeline.svg)](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/commits/master)
 
 Mocci is a toolchain using the Open Cloud Computing Interface (OCCI) to enable a model-driven cloud orchestration of cloud deployments and its monitoring instruments.
 Moreover, a runtime model manager is provided that grants access to gathered monitoring data.
diff --git a/config/html/model/index.html b/config/html/model/index.html
index 95aa39e..b306643 100644
--- a/config/html/model/index.html
+++ b/config/html/model/index.html
@@ -18,7 +18,7 @@
       <b><a href="../updatesite.zip">Download Eclipse Plugin Archive</a></b>
     </div>
 
-    <h1>WOCCI Model Report</h1>
+    <h1>MOCCI Model Report</h1>
 
     <p>
       This is a small report navigation page for the Mocci model project.
diff --git a/src/test/java/de/ugoe/cs/rwm/mocci/CreateElementsTest.java b/src/test/java/de/ugoe/cs/rwm/mocci/CreateElementsTest.java
new file mode 100644
index 0000000..17a473d
--- /dev/null
+++ b/src/test/java/de/ugoe/cs/rwm/mocci/CreateElementsTest.java
@@ -0,0 +1,93 @@
+package de.ugoe.cs.rwm.mocci;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.eclipse.cmf.occi.core.Configuration;
+import org.eclipse.cmf.occi.core.Link;
+import org.eclipse.cmf.occi.core.Mixin;
+import org.eclipse.cmf.occi.core.MixinBase;
+import org.eclipse.cmf.occi.core.OCCIFactory;
+import org.eclipse.cmf.occi.core.OCCIPackage;
+import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
+import org.eclipse.cmf.occi.core.util.OcciRegistry;
+import org.eclipse.cmf.occi.infrastructure.Compute;
+import org.eclipse.cmf.occi.infrastructure.InfrastructureFactory;
+import org.eclipse.cmf.occi.infrastructure.impl.InfrastructureFactoryImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.epsilon.emc.emf.CachedResourceSet;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import de.ugoe.cs.rwm.docci.MartDeployer;
+import de.ugoe.cs.rwm.docci.ModelUtility;
+import de.ugoe.cs.rwm.mocci.TestUtility;
+import de.ugoe.cs.rwm.docci.connector.Connector;
+import de.ugoe.cs.rwm.docci.connector.LocalhostConnector;
+import de.ugoe.cs.rwm.tocci.Transformator;
+import de.ugoe.cs.rwm.tocci.TransformatorFactory;
+import de.ugoe.cs.rwm.tocci.occi2openstack.OCCI2OPENSTACKTransformator;
+import monitoring.MonitoringFactory;
+import monitoring.MonitoringPackage;
+import monitoring.MonitoringProperty;
+import monitoring.MonitoringPropertyArray;
+import monitoring.Monitoringproperties;
+import monitoring.Sensor;
+import monitoring.impl.MonitoringFactoryImpl;
+
+public class CreateElementsTest {
+	
+	@BeforeClass
+	public static void OCCIRegistrySetup() {		
+		TestUtility.loggerSetup();
+		TestUtility.extensionRegistrySetup();
+	}
+	
+	@Test
+	public void createModel() {
+		//Factories to create OCCI elements
+		OCCIFactory cFact = new OCCIFactoryImpl();
+		InfrastructureFactory iFact = new InfrastructureFactoryImpl();
+		MonitoringFactory mFact = new MonitoringFactoryImpl();
+		
+		//Top level element
+		Configuration config = cFact.createConfiguration();
+		//Resources
+		Sensor sensor = mFact.createSensor();
+		Compute comp = iFact.createCompute();
+		//MixinBase
+		Monitoringproperties monProps = mFact.createMonitoringproperties();
+		MonitoringPropertyArray monArr = mFact.createMonitoringPropertyArray();
+		MonitoringProperty monProp = mFact.createMonitoringProperty();
+		monProp.setName("CPU");
+		monProp.setValue("Critical");
+		monProp.setId("123452");
+		monArr.getMonitoringpropertyarrayValues().add(monProp);
+		monProps.setMonitoringProperties(monArr);
+		
+		comp.getParts().add(monProps);
+		
+		config.getResources().add(sensor);
+		config.getResources().add(comp);
+		System.out.println(config);
+		for(org.eclipse.cmf.occi.core.Resource res : config.getResources()) {
+			System.out.println(res);
+			for(MixinBase mixBase: res.getParts()) {
+				System.out.println(mixBase);
+				if(mixBase instanceof Monitoringproperties) {
+					System.out.println(((Monitoringproperties) mixBase).getMonitoringProperties().getMonitoringpropertyarrayValues());
+				}
+			}
+		}
+	}
+}
-- 
GitLab