Package org.openengsb.core.workflow.drools.model

Examples of org.openengsb.core.workflow.drools.model.GlobalConfiguration


        Map<String, String> globals = readStorageFile();

        if (globals.containsKey(variableName)) {
            String className = globals.get(variableName);
            GlobalDeclaration global = new GlobalDeclaration(className, variableName);
            GlobalConfiguration cnf = new GlobalConfiguration(global.toMetadata(), global);
            ret.add(cnf);
        }
        return ret;
    }
View Full Code Here


        List<ConfigItem<GlobalDeclaration>> ret = new ArrayList<ConfigItem<GlobalDeclaration>>();
        Map<String, String> globals = readStorageFile();

        for (Entry<String, String> entry : globals.entrySet()) {
            GlobalDeclaration global = new GlobalDeclaration(entry.getValue(), entry.getKey());
            GlobalConfiguration cnf = new GlobalConfiguration(global.toMetadata(), global);
            ret.add(cnf);
        }
        return ret;
    }
View Full Code Here

        assertFalse(service.supports(ImportConfiguration.class));
    }

    @Test
    public void testPersistGlobalConfiguration_shouldPersistAndLoadConfig() throws Exception {
        GlobalConfiguration conf = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        service.persist(conf);

        List<ConfigItem<GlobalDeclaration>> loaded = service.load(conf.getMetaData());
        assertEquals(1, loaded.size());
        GlobalConfiguration confLoaded = (GlobalConfiguration) loaded.get(0);
        assertTrue(confLoaded.getContent().equals(conf.getContent()));
    }
View Full Code Here

    @Test
    public void testPersistGlobalConfiguration_shouldCreateFileIfNoneExists() throws Exception {
        FileUtils.forceDelete(storageFile);
        assertFalse(storageFile.exists());
        GlobalConfiguration conf = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        service.persist(conf);
        assertTrue(storageFile.exists());
    }
View Full Code Here

        assertTrue(storageFile.exists());
    }

    @Test
    public void testPersistGlobalConfiguration_shouldUpdatePreviousConfiguration() throws Exception {
        GlobalConfiguration conf = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        service.persist(conf);

        conf.getContent().setClassName("java.util.ArrayList");
        service.persist(conf);

        List<ConfigItem<GlobalDeclaration>> loaded = service.load(conf.getMetaData());
        assertEquals(1, loaded.size());

        GlobalConfiguration confLoaded = (GlobalConfiguration) loaded.get(0);
        assertEquals("java.util.ArrayList", confLoaded.getContent().getClassName());
    }
View Full Code Here

        assertEquals("java.util.ArrayList", confLoaded.getContent().getClassName());
    }

    @Test
    public void testLoadGlobalConfiguration_shouldOnlyLoadOneConfig() throws Exception {
        GlobalConfiguration conf1 = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        GlobalConfiguration conf2 = new GlobalConfiguration(new GlobalDeclaration("java.util.Map", "map"));
        GlobalConfiguration conf3 = new GlobalConfiguration(new GlobalDeclaration("java.util.Dictionary", "dict"));

        service.persist(conf1);
        service.persist(conf2);
        service.persist(conf3);

        List<ConfigItem<GlobalDeclaration>> loaded = service.load(conf2.getMetaData());
        assertEquals(1, loaded.size());
        GlobalConfiguration confLoaded = (GlobalConfiguration) loaded.get(0);
        assertEquals("java.util.Map", confLoaded.getContent().getClassName());
        assertEquals("map", confLoaded.getContent().getVariableName());
    }
View Full Code Here

        assertEquals("map", confLoaded.getContent().getVariableName());
    }

    @Test
    public void testLoadGlobalConfiguration_shouldLoadAllConfig() throws Exception {
        GlobalConfiguration conf1 = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        GlobalConfiguration conf2 = new GlobalConfiguration(new GlobalDeclaration("java.util.Map", "map"));
        GlobalConfiguration conf3 = new GlobalConfiguration(new GlobalDeclaration("java.util.Dictionary", "dict"));

        service.persist(conf1);
        service.persist(conf2);
        service.persist(conf3);
View Full Code Here

        assertEquals(0, loaded.size());
    }

    @Test
    public void testRemoveGlobalConfiguration_ShouldDeleteConfiguration() throws Exception {
        GlobalConfiguration conf1 = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list"));
        GlobalConfiguration conf2 = new GlobalConfiguration(new GlobalDeclaration("java.util.Map", "map"));

        service.persist(conf1);
        service.persist(conf2);

        service.remove(conf1.getMetaData());
        List<ConfigItem<GlobalDeclaration>> loaded = service.load(new HashMap<String, String>());
        assertEquals(1, loaded.size());
        GlobalConfiguration confLoaded = (GlobalConfiguration) loaded.get(0);
        assertEquals("java.util.Map", confLoaded.getContent().getClassName());
        assertEquals("map", confLoaded.getContent().getVariableName());
    }
View Full Code Here

        }
        if (!queryResult.isEmpty()) {
            throw new RuleBaseException(String.format("Global with name \"%s\" already exists", name));
        }
        globalDeclaration.setClassName(className);
        GlobalConfiguration cnf = new GlobalConfiguration(metaData, globalDeclaration);
        try {
            globalPersistence.persist(cnf);
        } catch (PersistenceException e) {
            throw new RuleBaseException(e);
        }
        try {
            builder.reloadRulebase();
        } catch (RuleBaseException e) {
            globalPersistence.remove(cnf.getMetaData());
            throw e;
        }

    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.workflow.drools.model.GlobalConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.