<commit_before>package com.example.seudoto.test;

import java.util.Random;

import model.ProfissionalSaude;

import com.parse.Parse;
import com.parse.ParseException;

import controller.ProfissionalController;
import dao.DAOParse;
import exception.ProfissionalSaudeException;
import android.test.AndroidTestCase;
import com.parse.*;

public class TestDAOParse extends AndroidTestCase {
	
	protected void setUp() throws Exception {
		
		super.setUp();
				
	}
	
	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	public void testCadastrarProfissionalComSucesso(){
		Exception exception = null;
		try {
			ProfissionalSaude p1 = new ProfissionalSaude("Medico", "abc-124", "TalesBoy", "Psiquiatra", "Particular");
			ProfissionalSaude p2 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001111", "Nazareno", "Terapeuta Social", "SUS");
			ProfissionalSaude p3 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001110", "<NAME> Todo Poderoso Alpha e Omega e etc e tal", "Placebista", "UniCristao");
			ProfissionalSaude p4 = new ProfissionalSaude("Medico", "1010101", "<NAME>", "Experimentalista", "Particular");
			
			DAOParse.getInstance().cadastrarProfissional(p1);
			DAOParse.getInstance().cadastrarProfissional(p2);
			DAOParse.getInstance().cadastrarProfissional(p3);
			DAOParse.getInstance().cadastrarProfissional(p4);
			
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		
		assertNull(exception);
	}
	
	public void testCadastrarProfissionalComFalhas(){
		Exception exception = null;
		
		try {
			ProfissionalSaude p1 = new ProfissionalSaude("Medico", "abc-124", "TalesBoy", "Psiquiatra", "Particular");		
			ProfissionalSaude p2 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001111", "Nazareno", "Terapeuta Social", "SUS");
			ProfissionalSaude p3 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001110", "<NAME> Todo Poderoso Alpha e Omega e etc e tal", "Placebista", "UniCristao");
			ProfissionalSaude p4 = new ProfissionalSaude("Medico", "1010101", "<NAME>", "Experimentalista", "Particular");
			DAOParse.getInstance().cadastrarProfissional(p1);
	
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			
		}catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		
		assertNotNull(exception);
		exception = null;
		
		try {
			ProfissionalSaude p2 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001111", "Nazareno", "Terapeuta Social", "SUS");
			DAOParse.getInstance().cadastrarProfissional(p2);
	
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			
		}catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		
		assertNotNull(exception);
		exception = null;
		
		try {
			ProfissionalSaude p3 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001110", "<NAME> Todo Poderoso Alpha e Omega e etc e tal", "Placebista", "UniCristao");
			DAOParse.getInstance().cadastrarProfissional(p3);
	
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			
		}catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		
		assertNotNull(exception);
		exception = null;
		
		try {
			ProfissionalSaude p4 = new ProfissionalSaude("Medico", "1010101", "<NAME>", "Experimentalista", "Particular");
			DAOParse.getInstance().cadastrarProfissional(p4);
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			
		}catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		
		assertNotNull(exception);
		
	}

}<commit_msg>Cadastrar profissional testado ao máximo.<commit_after>package com.example.seudoto.test;

import java.util.ArrayList;

import model.ProfissionalSaude;
import android.test.AndroidTestCase;

import com.parse.Parse;
import com.parse.ParseException;

import dao.DAOParse;
import exception.ProfissionalSaudeException;

public class TestDAOParse extends AndroidTestCase {
	
	private ArrayList<String> crmProfsFake;
	
	protected void setUp() throws Exception {
		crmProfsFake = new ArrayList<String>();
		Parse.initialize(getContext(), "7EqoOy2DDnMMHlXUGAbi9aJkqIgryikPIRv7CzX3", "nvT2iYY8AfuMJgH7cJQeoemBFFQsrXDqoR4wy2OJ");
		super.setUp();
				
	}
	
	protected void tearDown() throws Exception {
		removeProfissinaisFakeFromTest();
		super.tearDown();
	}

	public void testCadastrarProfissionalComSucesso(){
		Exception exception = new Exception();
		try {
			ProfissionalSaude p1 = new ProfissionalSaude("Medico", "abc-124", "TalesBoy", "Psiquiatra", "Particular");
			DAOParse.getInstance().cadastrarProfissional(p1);
			crmProfsFake.add(p1.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		assertNull(exception);

		exception = new Exception();
		try {
			ProfissionalSaude p2 = new ProfissionalSaude("Medico", "1010101", "<NAME>", "Experimentalista", "Particular");
			DAOParse.getInstance().cadastrarProfissional(p2);
			crmProfsFake.add(p2.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}

		assertNull(exception);
	}
	
	public void testCadastrarProfissionalCRMLongoComSucesso(){
		Exception exception = new Exception();
		try {
			ProfissionalSaude p3 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001111", "Nazareno", "Terapeuta Social", "SUS");			
			DAOParse.getInstance().cadastrarProfissional(p3);
			crmProfsFake.add(p3.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		assertNull(exception);
		
		exception = new Exception();
		try {
			ProfissionalSaude p4 = new ProfissionalSaude("Medico", "101010100001111000011110000111100001110", "<NAME> Todo Poderoso Alpha e Omega e etc e tal", "Placebista", "UniCristao");
			DAOParse.getInstance().cadastrarProfissional(p4);		
			crmProfsFake.add(p4.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			exception = e;
			e.printStackTrace();
		}
		assertNull(exception);
	}
	
	public void testCadastrarProfissionalCRMRepetido(){
		boolean uniqueCRM = true;
		try {
			ProfissionalSaude p1 = new ProfissionalSaude("Medico", "abc-124", "TalesBoy-CRMRepetido", "Psiquiatra", "Particular");			
			uniqueCRM = DAOParse.getInstance().isCrmUnico(p1.getNumeroRegistro());
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			fail("Problemas com ProfissionalSaude");
		} catch (ParseException e) {
			e.printStackTrace();
			fail("Problemas com Parse");
		}
		assertTrue(uniqueCRM);
		
		uniqueCRM = true;
		try {
			ProfissionalSaude p2 = new ProfissionalSaude("Medico", "1010101", "<NAME> - CRMRepetido", "Experimentalista", "Particular");
			uniqueCRM = DAOParse.getInstance().isCrmUnico(p2.getNumeroRegistro());
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			fail("Problemas com ProfissionalSaude");
		} catch (ParseException e) {
			e.printStackTrace();
			fail("Problemas com Parse");
		}
		assertTrue(uniqueCRM);
	}
	
	public void testCadastrarProfissionalComFalhas(){
		Exception exception = new Exception();	
		//Tipo null
		try {
			ProfissionalSaude p5 = new ProfissionalSaude(null, "123null456", "Dr Fake", "Placebologista", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//CRM null
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", null, "Dr Fake", "Placebologista", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//CRM string vazia
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", "", "Dr Fake", "Placebologista", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//Nome null
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", "314156", null, "Placebologista", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//Nome vazio
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", "314156", "", "Placebologista", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//Especialidade null
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", "314156", "Dr Fake", null, "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
		
		exception = new Exception();	
		//Especialidade vazio
		try {
			ProfissionalSaude p5 = new ProfissionalSaude("Médico", "314156", "Dr Fake", "", "UniT");
			crmProfsFake.add(p5.getNumeroRegistro());
			exception = null;
			
		} catch (ProfissionalSaudeException e) {
			e.printStackTrace();
			exception = e;
		}
		assertNotNull(exception);
	}
	
	private void removeProfissinaisFakeFromTest() {
		System.out.println("CRM " + crmProfsFake.size());
		
		try {
			DAOParse.getInstance().removerProfissional("abc-124");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			DAOParse.getInstance().removerProfissional("1010101");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			DAOParse.getInstance().removerProfissional("101010100001111000011110000111100001111");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			DAOParse.getInstance().removerProfissional("101010100001111000011110000111100001110");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
{'fraction_non_alphanumeric': 0.12473317865429234, 'fraction_numerical': 0.04974477958236659, 'mean_word_length': 4.568992248062015, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '6740976', 'n_tokens_mistral': 4539, 'n_tokens_neox': 3562, 'n_words': 695}