<commit_before>/*
 * Copyright 2016 <NAME>
 *
 * 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 io.craigmiller160.locus;

import io.craigmiller160.locus.reflect.ObjectAndMethod;
import io.craigmiller160.locus.sample.ModelOne;
import io.craigmiller160.locus.util.LocusStorage;
import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.math.BigDecimal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
 * A JUnit test class for the LocusModel class.
 *
 * Created by craig on 3/24/16.
 */
public class LocusModelTest {

    private static LocusStorage storage;
    private static LocusModel locusModel;
    private static ModelOne modelOne;

    static{
        try{
            Constructor<LocusStorage> constructor = LocusStorage.class.getDeclaredConstructor();
            constructor.setAccessible(true);
            storage = constructor.newInstance();

            modelOne = new ModelOne();
            Method[] methods = ModelOne.class.getDeclaredMethods();
            for(Method m : methods){
                if(m.getName().startsWith("set")){
                    String propName = m.getName().substring(3);
                    storage.addModelPropSetter(propName, new ObjectAndMethod(modelOne, m));
                }
                else if(m.getName().startsWith("get")){
                    String propName = m.getName().substring(3);
                    storage.addModelPropGetter(propName, new ObjectAndMethod(modelOne, m));
                }
            }<commit_msg>LFT-8 - Added documentation to LocusModelTest.<commit_after>/*
 * Copyright 2016 <NAME>
 *
 * 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 io.craigmiller160.locus;

import io.craigmiller160.locus.reflect.ObjectAndMethod;
import io.craigmiller160.locus.sample.ModelOne;
import io.craigmiller160.locus.util.LocusStorage;
import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.math.BigDecimal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
 * A JUnit test class for the LocusModel class.
 *
 * Created by craig on 3/24/16.
 */
public class LocusModelTest {

    private static LocusStorage storage;
    private static LocusModel locusModel;
    private static ModelOne modelOne;

    /**
     * Static initializer to set up the LocusStorage properly for
     * use in these tests. It's created reflectively because
     * there's no access to its constructor normally.
     */
    static{
        try{
            Constructor<LocusStorage> constructor = LocusStorage.class.getDeclaredConstructor();
            constructor.setAccessible(true);
            storage = constructor.newInstance();

            modelOne = new ModelOne();
            Method[] methods = ModelOne.class.getDeclaredMethods();
            for(Method m : methods){
                if(m.getName().startsWith("set")){
                    String propName = m.getName().substring(3);
                    storage.addModelPropSetter(propName, new ObjectAndMethod(modelOne, m));
                }
                else if(m.getName().startsWith("get")){
                    String propName = m.getName().substring(3);
                    storage.addModelPropGetter(propName, new ObjectAndMethod(modelOne, m));
                }
            }
{'fraction_non_alphanumeric': 0.09109042553191489, 'fraction_numerical': 0.012189716312056738, 'mean_word_length': 2.8638698630136985, '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': '2978639', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1167, 'n_words': 366}