<commit_before><commit_msg>Added basic connection testing<commit_after>package org.smof.test;

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Test.None;
import org.smof.annnotations.SmofArray;
import org.smof.annnotations.SmofBuilder;
import org.smof.annnotations.SmofNumber;
import org.smof.annnotations.SmofObject;
import org.smof.annnotations.SmofParam;
import org.smof.annnotations.SmofString;
import org.smof.collection.Smof;
import org.smof.element.AbstractElement;
import org.smof.parsers.SmofType;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

@SuppressWarnings("javadoc")
public class BasicSmofTest {
	
	private static Smof smof;
	private static MongoClient client;

	@BeforeClass
	public static void setUpBeforeClass() {
		final MongoDatabase database;
		client = new MongoClient("localhost", 27017);
		database = client.getDatabase("test");
		smof = Smof.create(database);
		smof.createCollection("guitars", Guitar.class);
		smof.registerSmofObject(Brand.class);
	}

	@AfterClass
	public static void tearDownAfterClass() {
		client.close();
	}

	@Test
	public void testSingleInsert() {
		final Guitar g1 = new Guitar("GR400", Type.ELECTRIC, Arrays.asList("D", "A", "D", "G", "B", "E"));
		smof.insert(g1);
	}
	
	private static enum Type {
		CLASSIC,
		ACOUSTIC,
		ELECTRIC;
	}
	
	private static class Guitar extends AbstractElement {
		
		@SmofObject(name = "brand")
		private Brand brand;
		
		@SmofString(name = "model")
		private final String model;
		
		@SmofString(name = "type")
		private final Type type;
		
		@SmofArray(name = "tunning", type = SmofType.STRING)
		private final List<String> tunning;

		@SmofBuilder
		public Guitar(@SmofParam(name="model") String model, @SmofParam(name="type") Type type, @SmofParam(name="tunning") List<String> tunning) {
			super();
			this.model = model;
			this.type = type;
			this.tunning = tunning;
		}
		
	}
	
	private static class Brand {

		@SmofNumber(name="year")
		private final int year;
		
		@SmofString(name="founder")
		private final String founder;
		
		@SmofNumber(name="units")
		private final int units;
		
		@SmofBuilder
		public Brand(@SmofParam(name="year") Integer year, @SmofParam(name="founder") String founder, @SmofParam(name="units") Integer units) {
			this.year = year;
			this.founder = founder;
			this.units = units;
		}
	}

}
{'fraction_non_alphanumeric': 0.12343686970552642, 'fraction_numerical': 0.004033884630899556, 'mean_word_length': 4.727482678983834, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5698641', 'n_tokens_mistral': 918, 'n_tokens_neox': 822, 'n_words': 188}