Skip to content

Commit

Permalink
RA| removed codacy errors regarding naked strings
Browse files Browse the repository at this point in the history
  • Loading branch information
raihan-mpower committed Oct 16, 2017
1 parent fb01731 commit c71339d
Show file tree
Hide file tree
Showing 18 changed files with 287 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Date;
import java.util.HashMap;


/**
* Created by onaio on 30/08/2017.
*/
Expand All @@ -19,12 +18,15 @@ public class ServiceRecordTest extends BaseUnitTest {
public final static String PROGRAMCLIENTID = "programClientID";
public final static String NAME = "name";
public final static String TYPE = "type";
public static final String ANMID = "anmId";
public static final String FORMSUBMISSIONID = "formSubmissionId";
public static final String VALUE = "value";

@Test
public void assertDefaultConstructorsCreateNonNullObjectOnInstantiation() {
junit.framework.Assert.assertNotNull(new ServiceRecord());
junit.framework.Assert.assertNotNull(new ServiceRecord(0l, BASEENTITYID, 0l, "value", new Date(), "anmId", LOCATIONID, "syncStatus", "eventId", "formSubmissionId", 0l));
junit.framework.Assert.assertNotNull(new ServiceRecord(0l, BASEENTITYID, "programClientId", 0l, "value", new Date(), "anmId", LOCATIONID, "syncStatus", "eventId", "formSubmissionId", 0l));
junit.framework.Assert.assertNotNull(new ServiceRecord(0l, BASEENTITYID, 0l, VALUE, new Date(), ANMID, LOCATIONID, SYNCED, EVENTID, FORMSUBMISSIONID, 0l));
junit.framework.Assert.assertNotNull(new ServiceRecord(0l, BASEENTITYID, PROGRAMCLIENTID, 0l, VALUE, new Date(), ANMID, LOCATIONID, SYNCED, EVENTID, FORMSUBMISSIONID, 0l));
}

@Test
Expand All @@ -40,27 +42,27 @@ public void assetTestallgettersandsetters() {
serviceRecord.setRecurringServiceId(0l);
junit.framework.Assert.assertEquals(0l, serviceRecord.getRecurringServiceId().longValue());

serviceRecord.setValue("value");
junit.framework.Assert.assertEquals("value", serviceRecord.getValue());
serviceRecord.setValue(VALUE);
junit.framework.Assert.assertEquals(VALUE, serviceRecord.getValue());

Date date = new Date();
serviceRecord.setDate(date);
junit.framework.Assert.assertEquals(date, serviceRecord.getDate());

serviceRecord.setAnmId("anmId");
junit.framework.Assert.assertEquals("anmId", serviceRecord.getAnmId());
serviceRecord.setAnmId(ANMID);
junit.framework.Assert.assertEquals(ANMID, serviceRecord.getAnmId());

serviceRecord.setLocationId("locationID");
junit.framework.Assert.assertEquals("locationID", serviceRecord.getLocationId());
serviceRecord.setLocationId(LOCATIONID);
junit.framework.Assert.assertEquals(LOCATIONID, serviceRecord.getLocationId());

serviceRecord.setSyncStatus(SYNCED);
junit.framework.Assert.assertEquals(SYNCED, serviceRecord.getSyncStatus());

serviceRecord.setEventId(EVENTID);
junit.framework.Assert.assertEquals(EVENTID, serviceRecord.getEventId());

serviceRecord.setFormSubmissionId("formSubmissionId");
junit.framework.Assert.assertEquals("formSubmissionId", serviceRecord.getFormSubmissionId());
serviceRecord.setFormSubmissionId(FORMSUBMISSIONID);
junit.framework.Assert.assertEquals(FORMSUBMISSIONID, serviceRecord.getFormSubmissionId());

serviceRecord.setUpdatedAt(0l);
junit.framework.Assert.assertEquals(0l, serviceRecord.getUpdatedAt().longValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import java.util.ArrayList;
import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

/**
* Created by onaio on 30/08/2017.
*/
Expand Down Expand Up @@ -43,9 +40,9 @@ public void assertInitReturnsNonNullTriggers() throws JSONException {
JSONObject data1 = new JSONObject(stringdata1);
JSONObject data2 = new JSONObject(stringdata2);
JSONObject data3 = new JSONObject(stringdata3);
assertNotNull(ServiceTrigger.init(data1));
assertNotNull(ServiceTrigger.init(data2));
assertNotNull(ServiceTrigger.init(data3));
junit.framework.Assert.assertNotNull(ServiceTrigger.init(data1));
junit.framework.Assert.assertNotNull(ServiceTrigger.init(data2));
junit.framework.Assert.assertNotNull(ServiceTrigger.init(data3));
}

@Test
Expand All @@ -59,11 +56,11 @@ public void assertGetMethodsReturnsCorrectValues() throws JSONException {
prerequisites.add("Vit A IFC 2");
prerequisites.add("dob");

assertEquals(ServiceTrigger.init(data2).getMultiple().getCondition(), condition);
assertEquals(ServiceTrigger.init(data2).getMultiple().getPrerequisites(), prerequisites);
assertEquals(ServiceTrigger.init(data2).getReference(), ServiceTrigger.Reference.MULTIPLE);
assertEquals(ServiceTrigger.init(data1).getOffset(), "+0d");
assertEquals(ServiceTrigger.init(data3).getPrerequisite(), "Vit A 2");
junit.framework.Assert.assertEquals(ServiceTrigger.init(data2).getMultiple().getCondition(), condition);
junit.framework.Assert.assertEquals(ServiceTrigger.init(data2).getMultiple().getPrerequisites(), prerequisites);
junit.framework.Assert.assertEquals(ServiceTrigger.init(data2).getReference(), ServiceTrigger.Reference.MULTIPLE);
junit.framework.Assert.assertEquals(ServiceTrigger.init(data1).getOffset(), "+0d");
junit.framework.Assert.assertEquals(ServiceTrigger.init(data3).getPrerequisite(), "Vit A 2");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import org.junit.Test;
import org.smartregister.immunization.BaseUnitTest;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

/**
* Created by onaio on 30/08/2017.
*/
Expand All @@ -15,58 +12,65 @@ public class ServiceTypeTest extends BaseUnitTest {
public static final String PREOFFSET = "PreOffset";
public static final String EXPIRYOFFSET = "ExpiryOffset";
public static final String MILESTONEOFFSET = "MilestoneOffset";
public static final String NAME = "name";
public static final String SERVICENAMEENTITY = "serviceNameEntity" ;
public static final String SERVICENAMEENTITYID = "serviceNameEntityId";
public static final String DATEENTITY = "dateEntity";
public static final String DATEENTITYID = "dateEntityId";
public static final String UNITS = "units";
public static final String SERVICELOGIC = "serviceLogic";
public static final String PREREQUISITE = "prerequisite";

@Test
public void assertDefaultConstructorsCreateNonNullObjectOnInstantiation() {
assertNotNull(new ServiceType());
assertNotNull(new ServiceType(0l, TYPE, "name", "serviceNameEntity", "serviceNameEntityId", "dateEntity", "dateEntityId", "units", "serviceLogic", "prerequisite", "preOffset", "expiryOffset", "milestoneOffset", 0l));
junit.framework.Assert.assertNotNull(new ServiceType());
junit.framework.Assert.assertNotNull(new ServiceType(0l, TYPE, NAME, SERVICENAMEENTITY, SERVICENAMEENTITYID, DATEENTITY, DATEENTITYID, UNITS, SERVICELOGIC, PREREQUISITE, "preOffset", "expiryOffset", "milestoneOffset", 0l));
}

@Test
public void assertCheckGettersandSetters() {
ServiceType serviceType = new ServiceType();

serviceType.setId(0l);
assertEquals(0l, serviceType.getId().longValue());
junit.framework.Assert.assertEquals(0l, serviceType.getId().longValue());

serviceType.setType(TYPE);
assertEquals(TYPE, serviceType.getType());
junit.framework.Assert.assertEquals(TYPE, serviceType.getType());

serviceType.setName("name");
assertEquals("name", serviceType.getName());
serviceType.setName(NAME);
junit.framework.Assert.assertEquals(NAME, serviceType.getName());

serviceType.setServiceNameEntity("serviceNameEntity");
assertEquals("serviceNameEntity", serviceType.getServiceNameEntity());
serviceType.setServiceNameEntity(SERVICENAMEENTITY);
junit.framework.Assert.assertEquals(SERVICENAMEENTITY, serviceType.getServiceNameEntity());

serviceType.setServiceNameEntityId("serviceNameEntityId");
assertEquals("serviceNameEntityId", serviceType.getServiceNameEntityId());
serviceType.setServiceNameEntityId(SERVICENAMEENTITYID);
junit.framework.Assert.assertEquals(SERVICENAMEENTITYID, serviceType.getServiceNameEntityId());

serviceType.setDateEntity("dateEntity");
assertEquals("dateEntity", serviceType.getDateEntity());
serviceType.setDateEntity(DATEENTITY);
junit.framework.Assert.assertEquals(DATEENTITY, serviceType.getDateEntity());

serviceType.setDateEntityId("dateEntityId");
assertEquals("dateEntityId", serviceType.getDateEntityId());
serviceType.setDateEntityId(DATEENTITYID);
junit.framework.Assert.assertEquals(DATEENTITYID, serviceType.getDateEntityId());

serviceType.setUnits("units");
assertEquals("units", serviceType.getUnits());
serviceType.setUnits(UNITS);
junit.framework.Assert.assertEquals(UNITS, serviceType.getUnits());

serviceType.setServiceLogic("serviceLogic");
assertEquals("serviceLogic", serviceType.getServiceLogic());
serviceType.setServiceLogic(SERVICELOGIC);
junit.framework.Assert.assertEquals(SERVICELOGIC, serviceType.getServiceLogic());

serviceType.setPrerequisite("prerequisite");
assertEquals("prerequisite", serviceType.getPrerequisite());
serviceType.setPrerequisite(PREREQUISITE);
junit.framework.Assert.assertEquals(PREREQUISITE, serviceType.getPrerequisite());

serviceType.setPreOffset(PREOFFSET);
assertEquals(PREOFFSET, serviceType.getPreOffset());
junit.framework.Assert.assertEquals(PREOFFSET, serviceType.getPreOffset());

serviceType.setExpiryOffset(EXPIRYOFFSET);
assertEquals(EXPIRYOFFSET, serviceType.getExpiryOffset());
junit.framework.Assert.assertEquals(EXPIRYOFFSET, serviceType.getExpiryOffset());

serviceType.setMilestoneOffset(MILESTONEOFFSET);
assertEquals(MILESTONEOFFSET, serviceType.getMilestoneOffset());
junit.framework.Assert.assertEquals(MILESTONEOFFSET, serviceType.getMilestoneOffset());

serviceType.setUpdatedAt(0l);
assertEquals(0l, serviceType.getUpdatedAt().longValue());

junit.framework.Assert.assertEquals(0l, serviceType.getUpdatedAt().longValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import org.smartregister.domain.Photo;
import org.smartregister.immunization.BaseUnitTest;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

/**
* Created by onaio on 30/08/2017.
*/
Expand All @@ -29,7 +26,7 @@ public class ServiceWrapperTest extends BaseUnitTest {

@Test
public void assertDefaultConstructorsCreateNonNullObjectOnInstantiation() {
assertNotNull(new ServiceWrapper());
junit.framework.Assert.assertNotNull(new ServiceWrapper());
}

@Test
Expand All @@ -38,72 +35,72 @@ public void assetTestallgettersandsetters() {
DateTime datetime = new DateTime();

serviceWrapper.setId(ID);
assertEquals(ID, serviceWrapper.getId());
junit.framework.Assert.assertEquals(ID, serviceWrapper.getId());

serviceWrapper.setDbKey(0l);
assertEquals(0l, serviceWrapper.getDbKey().longValue());
junit.framework.Assert.assertEquals(0l, serviceWrapper.getDbKey().longValue());

serviceWrapper.setStatus(STATUS);
assertEquals(STATUS, serviceWrapper.getStatus());
junit.framework.Assert.assertEquals(STATUS, serviceWrapper.getStatus());

serviceWrapper.setVaccineDate(datetime);
assertEquals(datetime, serviceWrapper.getVaccineDate());
junit.framework.Assert.assertEquals(datetime, serviceWrapper.getVaccineDate());

Alert alert = Mockito.mock(Alert.class);
serviceWrapper.setAlert(alert);
assertEquals(alert, serviceWrapper.getAlert());
junit.framework.Assert.assertEquals(alert, serviceWrapper.getAlert());

serviceWrapper.setDefaultName(DEFAULTNAME);
assertEquals(DEFAULTNAME, serviceWrapper.getDefaultName());
assertEquals(DEFAULTNAME, serviceWrapper.getName());
junit.framework.Assert.assertEquals(DEFAULTNAME, serviceWrapper.getDefaultName());
junit.framework.Assert.assertEquals(DEFAULTNAME, serviceWrapper.getName());

serviceWrapper.setPreviousVaccine(ID);
assertEquals(ID, serviceWrapper.getPreviousVaccineId());
junit.framework.Assert.assertEquals(ID, serviceWrapper.getPreviousVaccineId());

serviceWrapper.setColor(COLOR);
assertEquals(COLOR, serviceWrapper.getColor());
junit.framework.Assert.assertEquals(COLOR, serviceWrapper.getColor());

serviceWrapper.setDob(datetime);
assertEquals(datetime, serviceWrapper.getDob());
junit.framework.Assert.assertEquals(datetime, serviceWrapper.getDob());

ServiceType serviceType = new ServiceType();
serviceType.setUnits("units");
serviceType.setType("type");
serviceType.setId(0l);
serviceWrapper.setServiceType(serviceType);
serviceType.setName(NAME);
assertEquals(NAME, serviceWrapper.getName());
assertEquals(serviceType, serviceWrapper.getServiceType());
assertEquals(serviceType.getUnits(), serviceWrapper.getUnits());
assertEquals(serviceType.getType(), serviceWrapper.getType());
assertEquals(0l, serviceWrapper.getTypeId().longValue());
junit.framework.Assert.assertEquals(NAME, serviceWrapper.getName());
junit.framework.Assert.assertEquals(serviceType, serviceWrapper.getServiceType());
junit.framework.Assert.assertEquals(serviceType.getUnits(), serviceWrapper.getUnits());
junit.framework.Assert.assertEquals(serviceType.getType(), serviceWrapper.getType());
junit.framework.Assert.assertEquals(0l, serviceWrapper.getTypeId().longValue());

serviceWrapper.setValue(VALUE);
assertEquals(VALUE, serviceWrapper.getValue());
junit.framework.Assert.assertEquals(VALUE, serviceWrapper.getValue());

serviceWrapper.setPatientName(PATIENTNAME);
assertEquals(PATIENTNAME, serviceWrapper.getPatientName());
junit.framework.Assert.assertEquals(PATIENTNAME, serviceWrapper.getPatientName());

serviceWrapper.setUpdatedVaccineDate(datetime, true);
assertEquals(datetime, serviceWrapper.getVaccineDate());
assertEquals(datetime, serviceWrapper.getUpdatedVaccineDate());
assertEquals(true, serviceWrapper.isToday());
assertEquals(datetime.toString(YYYY_MM_DD), serviceWrapper.getUpdatedVaccineDateAsString());
assertEquals(datetime.toString(YYYY_MM_DD), serviceWrapper.getVaccineDateAsString());
junit.framework.Assert.assertEquals(datetime, serviceWrapper.getVaccineDate());
junit.framework.Assert.assertEquals(datetime, serviceWrapper.getUpdatedVaccineDate());
junit.framework.Assert.assertEquals(true, serviceWrapper.isToday());
junit.framework.Assert.assertEquals(datetime.toString(YYYY_MM_DD), serviceWrapper.getUpdatedVaccineDateAsString());
junit.framework.Assert.assertEquals(datetime.toString(YYYY_MM_DD), serviceWrapper.getVaccineDateAsString());

serviceWrapper.setPatientNumber(NUMBER);
assertEquals(NUMBER, serviceWrapper.getPatientNumber());
junit.framework.Assert.assertEquals(NUMBER, serviceWrapper.getPatientNumber());

Photo photo = Mockito.mock(Photo.class);
serviceWrapper.setPhoto(photo);
assertEquals(photo, serviceWrapper.getPhoto());
junit.framework.Assert.assertEquals(photo, serviceWrapper.getPhoto());

serviceWrapper.setGender(GENDER);
assertEquals(GENDER, serviceWrapper.getGender());
junit.framework.Assert.assertEquals(GENDER, serviceWrapper.getGender());


serviceWrapper.setSynced(true);
assertEquals(true, serviceWrapper.isSynced());
junit.framework.Assert.assertEquals(true, serviceWrapper.isSynced());

}

Expand Down

0 comments on commit c71339d

Please sign in to comment.