Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Model Documentation Generation #6

Open
wants to merge 21 commits into
base: snapshot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
header:
license:
spdx-id: EPL-2.0
copyright-owner: Data In Motion Consulting GmbH
copyright-owner: Data In Motion
content: |
This program and the accompanying materials are made available under the terms of the
Eclipse Public License v2.0 which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v20.html

Copyright (c) 2012 - 2022 Data In Motion and others.
All rights reserved.

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:
pattern: |
This program and the accompanying materials are made available under the terms of the
Eclipse Public License v2.0 which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v20.html
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/

paths-ignore:
- 'dist'
Expand Down Expand Up @@ -54,5 +59,6 @@ header:
- 'gradlew'
- 'gradlew.bat'
- 'settings.gradle'
- '**/*Test.java'

comment: always
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {

sonarqube {
properties {
property "sonar.ce.javaOpts", "-Xmx2G"
property "sonar.projectName", "Gecko EMF Utilities"
property "sonar.projectKey", "geckoprojects-org_org.gecko.emf.utils"
property "sonar.organization", "geckoprojects-org"
Expand Down
2 changes: 1 addition & 1 deletion cnf/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ base-version: 1.0.0.SNAPSHOT
javac.source: 11
javac.target: 11

-require-bnd "(version>=6.2.0)"
-require-bnd "(version>=6.3.1)"

-plugin.Central: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
Expand Down
19 changes: 14 additions & 5 deletions cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ org.osgi:osgi.core:8.0.0
org.slf4j:slf4j-api:1.7.30
org.slf4j:slf4j-simple:1.7.30

org.eclipse.emf:org.eclipse.emf.common:2.23.0
org.eclipse.emf:org.eclipse.emf.ecore:2.25.0
org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.16.0
#org.eclipse.emf:org.eclipse.emf.common:2.23.0
#org.eclipse.emf:org.eclipse.emf.ecore:2.25.0
#org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.16.0
org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.28.0
org.eclipse.emf:org.eclipse.emf.codegen:2.22.0
org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.6.0
Expand All @@ -157,14 +157,23 @@ org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.1.1

#org.geckoprojects.emf:org.gecko.emf.osgi.api:4.1.1.202202162308
org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:4.1.1-SNAPSHOT
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:4.1.1-SNAPSHOT

com.fasterxml.jackson.core:jackson-core:2.13.2
com.fasterxml.jackson.core:jackson-databind:2.13.2
com.fasterxml.jackson.core:jackson-annotations:2.13.2
com.fasterxml.jackson.dataformat:jackson-dataformat-properties:2.13.2
com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.2
org.eclipse.emfcloud:emfjson-jackson:2.1.0-SNAPSHOT
org.eclipse.emfcloud:emfjson-jackson:2.1.0
de.undercouch:bson4jackson:2.13.1
org.yaml:snakeyaml:1.30
#org.emfjson:emfjson-jackson:1.3.0
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:4.1.1-SNAPSHOT


#xtext
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.29.0.M1
org.eclipse.xtext:org.eclipse.xtext.builder:2.10.0
com.google.guava:guava:30.1-jre
com.google.guava:failureaccess:1.0.1

org.gecko.runtime:org.gecko.templates:1.0.31
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bnd_version=6.3.0-RC1
bnd_version=6.3.1
bnd_snapshots=https://bndtools.jfrog.io/ui/native/libs-release/
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m
9 changes: 5 additions & 4 deletions org.gecko.emf.bson.tests/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
org.apache.felix.configadmin;version='[1.9.22,1.9.23)',\
org.eclipse.emf.ecore.xmi;version='[2.16.0,2.16.1)',\
org.opentest4j;version='[1.2.0,1.2.1)',\
org.osgi.service.component;version='[1.4.0,1.4.1)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.1.1,1.1.2)',\
com.fasterxml.jackson.core.jackson-annotations;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.core.jackson-core;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.core.jackson-databind;version='[2.13.2,2.13.3)',\
Expand All @@ -23,12 +21,15 @@
org.gecko.emf.osgi.example.model.basic;version='[4.1.1,4.1.2)',\
com.fasterxml.jackson.dataformat.jackson-dataformat-properties;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.dataformat.jackson-dataformat-yaml;version='[2.13.2,2.13.3)',\
emfjson-jackson;version='[2.1.0,2.1.1)',\
org.gecko.emf.bson;version=snapshot,\
org.gecko.emf.json;version=snapshot,\
org.yaml.snakeyaml;version='[1.30.0,1.30.1)',\
org.gecko.emf.bson.tests;version=snapshot,\
junit-jupiter-api;version='[5.8.2,5.8.3)',\
junit-jupiter-params;version='[5.8.2,5.8.3)',\
org.osgi.test.common;version='[1.1.0,1.1.1)',\
org.osgi.test.junit5;version='[1.1.0,1.1.1)'
org.osgi.test.junit5;version='[1.1.0,1.1.1)',\
org.apache.felix.converter;version='[1.0.18,1.0.19)',\
org.eclipse.emfcloud.emfjson-jackson;version='[2.1.0,2.1.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
org.osgi.util.promise;version='[1.2.0,1.2.1)'
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* 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:
* Data In Motion - initial API and implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* 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:
* Data In Motion - initial API and implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* 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:
* Data In Motion - initial API and implementation
Expand Down
6 changes: 5 additions & 1 deletion org.gecko.emf.json.tests/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ javac.target: 11

Bundle-Version: 1.0.1.SNAPSHOT
-buildpath: \
org.eclipse.emfcloud.emfjson-jackson;version=latest
org.eclipse.emfcloud.emfjson-jackson;version=latest,\
org.gecko.emf.osgi.component,\
org.eclipse.emf.ecore.xmi,\
org.eclipse.emf.ecore,\
org.gecko.emf.osgi.example.model.basic
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/**
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Data In Motion - initial API and implementation
*/
package org.gecko.emf.json.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.gecko.emf.json.configuration.ConfigurableJsonResource;
import org.gecko.emf.json.constants.EMFJs;
import org.gecko.emf.osgi.example.model.basic.BasicFactory;
import org.gecko.emf.osgi.example.model.basic.BasicPackage;
import org.gecko.emf.osgi.example.model.basic.Person;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.osgi.test.common.annotation.InjectService;
import org.osgi.test.common.service.ServiceAware;
import org.osgi.test.junit5.context.BundleContextExtension;
import org.osgi.test.junit5.service.ServiceExtension;

/**
*
* @author mark
* @since 15.07.2022
*/
@ExtendWith(BundleContextExtension.class)
@ExtendWith(ServiceExtension.class)
public class RootElementTest {

@Test
public void testSaveJson(@InjectService(timeout = 2000) ServiceAware<ResourceSet> rsAware,
@InjectService(timeout = 2000) ServiceAware<BasicFactory> bfAware) {

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

assertNotNull(bfAware);
assertThat(bfAware.getServices()).hasSize(1);
BasicFactory factoryImpl = bfAware.getService();
assertNotNull(factoryImpl);

Resource resource = resourceSet.createResource(URI.createURI("test.json"));
assertNotNull(resource);
assertTrue(resource instanceof ConfigurableJsonResource);

Person p = factoryImpl.createPerson();
p.setFirstName("Emil");
p.setLastName("Tester");
resource.getContents().add(p);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
resource.save(baos, null);
} catch (IOException e) {
fail("Error saving Person");
}
String result = new String(baos.toByteArray());
System.out.println(result);
}



@Test
public void testLoadJsonError(@InjectService(timeout = 2000) ServiceAware<ResourceSet> rsAware) {

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

String json = "{\n"
+ " \"firstName\" : \"Emil\",\n"
+ " \"lastName\" : \"Tester\"\n"
+ "}";
Resource loadResource = resourceSet.createResource(URI.createURI("test-load-error.json"));
assertNotNull(loadResource);
assertTrue(loadResource instanceof ConfigurableJsonResource);

ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes());
try {
loadResource.load(bais, null);
assertEquals(0, loadResource.getContents().size());
} catch (IOException e) {
fail("Error loading Person");
}
}


@Test
public void testLoadJson(@InjectService(timeout = 2000) ServiceAware<ResourceSet> rsAware,
@InjectService(timeout = 2000) ServiceAware<BasicPackage> basicPackageAware) {

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

assertNotNull(basicPackageAware);
assertThat(basicPackageAware.getServices()).hasSize(1);
BasicPackage packageImpl = basicPackageAware.getService();
assertNotNull(packageImpl);

String json = "{\n"
+ " \"firstName\" : \"Emil\",\n"
+ " \"lastName\" : \"Tester\"\n"
+ "}";
Resource loadResource = resourceSet.createResource(URI.createURI("test-load.json"));
assertNotNull(loadResource);
assertTrue(loadResource instanceof ConfigurableJsonResource);

ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes());
try {
Map<String, Object> loadOptions = new HashMap<String, Object>();
loadOptions.put(EMFJs.OPTION_ROOT_ELEMENT, packageImpl.getPerson());
loadResource.load(bais, loadOptions);
assertEquals(1, loadResource.getContents().size());
Person p = (Person) loadResource.getContents().get(0);
assertEquals("Emil", p.getFirstName());
assertEquals("Tester", p.getLastName());
} catch (IOException e) {
fail("Error loading Person");
}
}

}
15 changes: 11 additions & 4 deletions org.gecko.emf.json.tests/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
com.fasterxml.jackson.dataformat.jackson-dataformat-properties;version='[2.13.2,2.13.3)',\
com.fasterxml.jackson.dataformat.jackson-dataformat-yaml;version='[2.13.2,2.13.3)',\
de.undercouch.bson4jackson;version='[2.13.1,2.13.2)',\
emfjson-jackson;version='[2.1.0,2.1.1)',\
junit-jupiter-api;version='[5.8.2,5.8.3)',\
junit-platform-commons;version='[1.8.2,1.8.3)',\
net.bytebuddy.byte-buddy;version='[1.12.8,1.12.9)',\
Expand All @@ -30,11 +29,19 @@
org.mockito.mockito-core;version='[4.4.0,4.4.1)',\
org.objenesis;version='[3.2.0,3.2.1)',\
org.opentest4j;version='[1.2.0,1.2.1)',\
org.osgi.service.component;version='[1.4.0,1.4.1)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.1.1,1.1.2)',\
org.osgi.util.pushstream;version='[1.0.1,1.0.2)',\
org.yaml.snakeyaml;version='[1.30.0,1.30.1)'
org.yaml.snakeyaml;version='[1.30.0,1.30.1)',\
org.apache.felix.converter;version='[1.0.18,1.0.19)',\
org.eclipse.emfcloud.emfjson-jackson;version='[2.1.0,2.1.1)',\
org.osgi.util.promise;version='[1.2.0,1.2.1)',\
org.gecko.emf.bson;version=snapshot,\
org.gecko.emf.util.model;version=snapshot,\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
assertj-core;version='[3.22.0,3.22.1)',\
junit-jupiter-params;version='[5.8.2,5.8.3)',\
org.osgi.test.common;version='[1.1.0,1.1.1)',\
org.osgi.test.junit5;version='[1.1.0,1.1.1)'



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* 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:
* Data In Motion - initial API and implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Copyright (c) 2012 - 2022 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
* 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:
* Data In Motion - initial API and implementation
Expand Down
Loading