<commit_before>/**
 * JBoss, Home of Professional Open Source
 * Copyright Red Hat, Inc., and individual contributors.
 *
 * 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.jboss.aerogear.android.impl.datamanager;


import org.jboss.aerogear.android.DataManager;
import org.jboss.aerogear.android.datamanager.Store;
import org.jboss.aerogear.android.impl.helper.Data;
import org.jboss.aerogear.android.store.MainActivity;
import org.jboss.aerogear.android.store.impl.util.PatchedActivityInstrumentationTestCase;

import static org.jboss.aerogear.android.impl.datamanager.StoreTypes.MEMORY;
import static org.jboss.aerogear.android.impl.datamanager.StoreTypes.SQL;

public class DataManagerTest extends PatchedActivityInstrumentationTestCase<MainActivity> {

    public DataManagerTest() {
        super(MainActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
    }

    public void testCreateStoreWithDefaultType() {
        Store store = DataManager
                .config("foo1", MemoryStoreConfig.class)
                .createMemoryStore();

        assertNotNull("store could not be null", store);
    }

    public void testCreateStoreWithMemoryType() {
        Store store = DataManager
                .config("foo2", MemoryStoreConfig.class)
                .createMemoryStore();

        assertNotNull("store could not be null", store);
        assertEquals("verifying the type", MEMORY, store.getType());
    }

    public void testAddStoreWithMemoryType() {
        DataManager
                .config("foo3", MemoryStoreConfig.class)
                .createMemoryStore();

        Store store = DataManager.getStore("foo3");

        assertNotNull("store could not be null", store);
        assertEquals("verifying the type", MEMORY, store.getType());
    }

    public void testAddStoreWithSQLType() {
        DataManager
                .config("foo4", SQLStoreConfig.class)
                .setKlass(Data.class)
                .setContext(super.getActivity().getApplicationContext())
                .createSQLStore();

        Store store = DataManager.getStore("foo4");

        assertNotNull("store could not be null", store);
        assertEquals("verifying the type", SQL, store.getType());
    }

}<commit_msg>Improve DataManager test<commit_after>/**
 * JBoss, Home of Professional Open Source
 * Copyright Red Hat, Inc., and individual contributors.
 *
 * 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.jboss.aerogear.android.impl.datamanager;


import org.jboss.aerogear.android.ConfigurationProvider;
import org.jboss.aerogear.android.DataManager;
import org.jboss.aerogear.android.datamanager.Store;
import org.jboss.aerogear.android.store.MainActivity;
import org.jboss.aerogear.android.store.impl.util.PatchedActivityInstrumentationTestCase;

public class DataManagerTest extends PatchedActivityInstrumentationTestCase<MainActivity> {

    public DataManagerTest() {
        super(MainActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
    }

    public void testCreateStore() {
        Store store = DataManager
                .config("foo1", MemoryStoreConfig.class)
                .createMemoryStore();

        assertNotNull("store could not be null", store);
    }

    public void testGetStore() {
        DataManager
                .config("foo2", MemoryStoreConfig.class)
                .createMemoryStore();

        Store store = DataManager.getStore("foo2");

        assertNotNull("store could not be null", store);
    }

    public void testCreateStoreType() {
        Store store = DataManager
                .config("foo3", MemoryStoreConfig.class)
                .createMemoryStore();

        assertNotNull("store could not be null", store);
        assertEquals("store type should be MEMORY", StoreTypes.MEMORY, store.getType());
    }

    public void testCreateMoreThanOneStoreInDataManager() {
        DataManager
                .config("foo4", MemoryStoreConfig.class)
                .createMemoryStore();

        DataManager
                .config("foo5", MemoryStoreConfig.class)
                .createMemoryStore();

        Store store1 = DataManager.getStore("foo4");
        Store store2 = DataManager.getStore("foo5");

        assertNotNull("store could not be null", store1);
        assertNotNull("store could not be null", store2);
    }

    public void testCreateDiferentStore() {

        DataManager
                .config("foo6", MemoryStoreConfig.class)
                .createMemoryStore();

        DataManager
                .config("foo7", SQLStoreConfig.class)
                .setKlass(String.class)
                .setContext(getActivity().getApplicationContext())
                .createSQLStore();

        Store memoryStore = DataManager.getStore("foo6");
        Store sqlStore = DataManager.getStore("foo7");

        assertNotNull("store could not be null", memoryStore);
        assertEquals("store type should be MEMORY", StoreTypes.MEMORY, memoryStore.getType());

        assertNotNull("store could not be null", sqlStore);
        assertEquals("store type should be MEMORY", StoreTypes.SQL, sqlStore.getType());
    }

    public void testAddSimpleAuthenticator() {

        DataManager.registerConfigurationProvider(StubStoreConfig.class, new DummyStoreConfigProvider());
        StubStoreConfig config = DataManager.config("test", StubStoreConfig.class);
        assertNotNull(config);

    }

    private static final class DummyStoreConfigProvider implements ConfigurationProvider<StubStoreConfig> {
        @Override
        public StubStoreConfig newConfiguration() {
            return new StubStoreConfig();
        }
    }

    private static class StubStoreConfig extends StoreConfig<StubStoreConfig> {
        public StubStoreConfig() {
        }
    }

}
{'fraction_non_alphanumeric': 0.09292227529309596, 'fraction_numerical': 0.004342162396873643, 'mean_word_length': 2.9328400682982356, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6127154', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1755, 'n_words': 485}