Search in sources :

Example 1 with JsonPatchHelper

use of org.eclipse.emfcloud.modelserver.emf.util.JsonPatchHelper in project emfcloud-modelserver by eclipse-emfcloud.

the class DefaultModelResourceManagerTest method beforeTests.

@Before
public void beforeTests() throws DecodingException {
    when(serverConfig.getWorkspaceRootURI()).thenReturn(URI.createFileURI(getCWD().getAbsolutePath() + "/" + RESOURCE_PATH));
    modelResourceManager = Guice.createInjector(new AbstractModule() {

        private Multibinder<EPackageConfiguration> ePackageConfigurationBinder;

        private ArrayList<Class<? extends EPackageConfiguration>> ePackageConfigurations;

        @Override
        protected void configure() {
            ePackageConfigurations = Lists.newArrayList(EcorePackageConfiguration.class, CommandPackageConfiguration.class);
            ePackageConfigurationBinder = Multibinder.newSetBinder(binder(), EPackageConfiguration.class);
            ePackageConfigurations.forEach(c -> ePackageConfigurationBinder.addBinding().to(c));
            bind(ServerConfiguration.class).toInstance(serverConfig);
            bind(CommandCodec.class).toInstance(commandCodec);
            bind(ModelWatchersManager.class).toInstance(watchersManager);
            bind(AdapterFactory.class).toInstance(new EcoreAdapterFactory());
            bind(ModelRepository.class).to(DefaultModelRepository.class).in(Scopes.SINGLETON);
            bind(ModelResourceManager.class).to(DefaultModelResourceManager.class).in(Scopes.SINGLETON);
            bind(JsonPatchHelper.class).toInstance(jsonPatchHelper);
        }
    }).getInstance(DefaultModelResourceManager.class);
}
Also used : EcoreFactory(org.eclipse.emf.ecore.EcoreFactory) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) EcoreAdapterFactory(org.eclipse.emf.ecore.util.EcoreAdapterFactory) DefaultModelResourceManager(org.eclipse.emfcloud.modelserver.emf.common.DefaultModelResourceManager) JsonPatchTestException(org.eclipse.emfcloud.modelserver.common.patch.JsonPatchTestException) ModelRepository(org.eclipse.emfcloud.modelserver.emf.common.ModelRepository) Map(java.util.Map) JsonPatchHelper(org.eclipse.emfcloud.modelserver.emf.util.JsonPatchHelper) Json(org.eclipse.emfcloud.modelserver.jsonschema.Json) EPackageConfiguration(org.eclipse.emfcloud.modelserver.emf.configuration.EPackageConfiguration) CommandCodec(org.eclipse.emfcloud.modelserver.edit.CommandCodec) ServerConfiguration(org.eclipse.emfcloud.modelserver.emf.configuration.ServerConfiguration) EObject(org.eclipse.emf.ecore.EObject) ModelResourceManager(org.eclipse.emfcloud.modelserver.emf.common.ModelResourceManager) Multibinder(com.google.inject.multibindings.Multibinder) EPackage(org.eclipse.emf.ecore.EPackage) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Assert.assertFalse(org.junit.Assert.assertFalse) Resource(org.eclipse.emf.ecore.resource.Resource) Optional(java.util.Optional) DecodingException(org.eclipse.emfcloud.modelserver.common.codecs.DecodingException) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) JsonPatchException(org.eclipse.emfcloud.modelserver.common.patch.JsonPatchException) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) URI(org.eclipse.emf.common.util.URI) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) ModelWatchersManager(org.eclipse.emfcloud.modelserver.emf.common.watchers.ModelWatchersManager) Lists(com.google.common.collect.Lists) EClass(org.eclipse.emf.ecore.EClass) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) Before(org.junit.Before) Answers(org.mockito.Answers) Assert.assertNotNull(org.junit.Assert.assertNotNull) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Scopes(com.google.inject.Scopes) File(java.io.File) DefaultModelRepository(org.eclipse.emfcloud.modelserver.emf.common.DefaultModelRepository) Mockito.verify(org.mockito.Mockito.verify) EcorePackageConfiguration(org.eclipse.emfcloud.modelserver.emf.configuration.EcorePackageConfiguration) CommandPackageConfiguration(org.eclipse.emfcloud.modelserver.emf.configuration.CommandPackageConfiguration) Guice(com.google.inject.Guice) Assert.assertEquals(org.junit.Assert.assertEquals) AbstractModule(com.google.inject.AbstractModule) ModelRepository(org.eclipse.emfcloud.modelserver.emf.common.ModelRepository) DefaultModelRepository(org.eclipse.emfcloud.modelserver.emf.common.DefaultModelRepository) EPackageConfiguration(org.eclipse.emfcloud.modelserver.emf.configuration.EPackageConfiguration) DefaultModelResourceManager(org.eclipse.emfcloud.modelserver.emf.common.DefaultModelResourceManager) EClass(org.eclipse.emf.ecore.EClass) DefaultModelResourceManager(org.eclipse.emfcloud.modelserver.emf.common.DefaultModelResourceManager) ModelResourceManager(org.eclipse.emfcloud.modelserver.emf.common.ModelResourceManager) EcoreAdapterFactory(org.eclipse.emf.ecore.util.EcoreAdapterFactory) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Lists (com.google.common.collect.Lists)1 AbstractModule (com.google.inject.AbstractModule)1 Guice (com.google.inject.Guice)1 Scopes (com.google.inject.Scopes)1 Multibinder (com.google.inject.multibindings.Multibinder)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 URI (org.eclipse.emf.common.util.URI)1 EClass (org.eclipse.emf.ecore.EClass)1 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 EcoreFactory (org.eclipse.emf.ecore.EcoreFactory)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 EcoreAdapterFactory (org.eclipse.emf.ecore.util.EcoreAdapterFactory)1