Skip to content

Commit

Permalink
Create test for create and update methods in CR Vaccination
Browse files Browse the repository at this point in the history
Related to issue #37
Related to issue #43

Signed-off-by: João Paulo Ferreira <[email protected]>
Signed-off-by: LucasAmoedo <[email protected]>
  • Loading branch information
iamferreirajp committed May 12, 2017
1 parent ba2a659 commit 520a4b9
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

import junit.framework.Assert;

import org.junit.After;
import org.junit.Test;
import org.mockito.Mockito;

import br.com.bovdog.bean.ClinicalRecordVaccination;
import br.com.bovdog.bean.VaccinationFactory;
import br.com.bovdog.dao.DataAccessObject;
import br.com.bovdog.helper.PersistenceHelper;

public class ClinicalRecordVaccinationServiceTest {
DataAccessObject dataAcessObject = DataAccessObject.getInstance("test-unit");
Expand All @@ -27,7 +29,6 @@ public ClinicalRecordVaccination setupVaccination() throws ParseException {

VaccinationFactory vaccinationFactory = new VaccinationFactory();


DateFormat formatter = new SimpleDateFormat("dd/MM/YYYY");
Date testDate = formatter.parse("01/01/2000");

Expand All @@ -46,6 +47,11 @@ public ClinicalRecordVaccination setupVaccination() throws ParseException {
return record;
}

@After
public void clearDatabase(){
PersistenceHelper.clearDatabase();
}

@Test
public void getAllClinicalRecordVaccinationTest() throws ParseException {

Expand All @@ -69,4 +75,33 @@ record = dataAcessObject.createObject(record);
}
Assert.assertEquals(vaccinations, dataAcessObject.getAllObjects(null, ClinicalRecordVaccination.class));
}

@Test
public void createClinicalReccordVaccinationTest() throws ParseException{
ClinicalRecordVaccination clinicalRecordVaccination = setupVaccination();
clinicalRecordVaccination = dataAcessObject.createObject(clinicalRecordVaccination);
int id = clinicalRecordVaccination.getId();
Assert.assertEquals(clinicalRecordVaccination, dataAcessObject.getObjectById(id, ClinicalRecordVaccination.class));
}

@Test
public void updateClinicalRecordVaccinationTest() throws ParseException{
ClinicalRecordVaccination clinicalRecordVaccination = setupVaccination();
clinicalRecordVaccination = dataAcessObject.createObject(clinicalRecordVaccination);

int id = clinicalRecordVaccination.getId();
String vermifugeName = clinicalRecordVaccination.getVermifugeName();

Assert.assertEquals(clinicalRecordVaccination, dataAcessObject.getObjectById(id, ClinicalRecordVaccination.class));
Assert.assertEquals(vermifugeName, dataAcessObject.getObjectById(id, ClinicalRecordVaccination.class).getVermifugeName());

String updatedVermifugeName = "UpdatedVermifugeName";

clinicalRecordVaccination.setVermifugeName(updatedVermifugeName);

dataAcessObject.updateObject(clinicalRecordVaccination);

Assert.assertEquals(updatedVermifugeName, dataAcessObject.getObjectById(id, ClinicalRecordVaccination.class).getVermifugeName());

}
}

0 comments on commit 520a4b9

Please sign in to comment.