Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

/*
* SeocTest.java
* Copyright (c) 2017 Veterans Affairs.
*/
package gov.va.oneconsult.seoc.api.model;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import org.junit.Before;
import org.junit.Test;

import gov.va.oneconsult.seoc.api.controller.SeocObjectGenerator;
import gov.va.oneconsult.seoc.api.util.ApiUtil;
import gov.va.oneconsult.seoc.api.util.Constants;
import gov.va.oneconsult.seoc.api.util.TestUtil;

/**
* Test cases for Seoc model object
*
* @author AbleVets
*/
public class SeocTest
{

ServiceLine sl = new ServiceLine();

Status draft = new Status();
Status active = new Status();

PayableService serv1 = new PayableService();
PayableService serv2 = new PayableService();
PayableService serv3 = new PayableService();
PayableService serv4 = new PayableService();

BillingCode bc1 = new BillingCode();
BillingCode bc2 = new BillingCode();

private Validator validator;
/**
* Description: Setup before running the test case
*/
@Before
public void setUp()
{
sl.setDescription("TestServiceLine");
sl.setId(1);
sl.setServiceAbbreviation("SLABBR");

draft.setId(1);
draft.setDescription("Draft");

active.setId(2);
active.setDescription("Active");

// billing codes
bc1.setId(1);
bc1.setBillingCode("Bc1");
bc1.setPrecertRequired(false);

bc2.setId(2);
bc2.setBillingCode("Bc2");
bc2.setPrecertRequired(true);

Set<BillingCode> bcs = new HashSet<BillingCode>();
bcs.add(bc1);
bcs.add(bc2);

// Service with billing codes
serv1.setId(1);
serv1.setDescription("service1");
serv1.setBillingCodes(bcs);

// Service with no billing codes
serv2.setId(2);
serv2.setDescription("service2");

// Service with codeRequired "NO"
serv3.setId(3);
serv3.setDescription("service3");
serv3.setCodeRequired("NO");

// Service with codeRequired "ANY"
serv4.setId(4);
serv4.setDescription("service4");
serv4.setCodeRequired("ANY");

ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
validator = validatorFactory.getValidator();

}

/**
* Description: Check validity of seoc title when the status is 'draft'
*/
@Test
public void checkSeocIdForDraft()
{
Seoc draftSeoc = new Seoc();
draftSeoc.setId(1);
draftSeoc.setName("SeocTest");
draftSeoc.setServiceLine(sl);
draftSeoc.setStatus(draft);

String expectedSeocId = "SLABBR_SeocTest";

assertThat(expectedSeocId.toUpperCase()).isEqualTo(draftSeoc.getSeocId());
}

/**
* Description: Check validity of Seoc title when the Seoc is REV
*/
@Test
public void checkSeocIdWithRev()
{
Seoc seocWithRev = new Seoc();
seocWithRev.setName("SeocTest");
seocWithRev.setVersionNumber("1.0.1");
seocWithRev.setServiceLine(sl);
seocWithRev.setStatus(active);
seocWithRev.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv2);
seocWithRev.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1_REV";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithRev.getSeocId());
}

/**
* Description: Check validity of Seoc title when the Seoc is not REV
*/
@Test
public void checkSeocIdWithNoRev()
{
Seoc seocWithNoRev = new Seoc();
seocWithNoRev.setName("SeocTest");
seocWithNoRev.setVersionNumber("1.0.1");
seocWithNoRev.setServiceLine(sl);
seocWithNoRev.setStatus(active);
seocWithNoRev.setRev(false);

String expectedSeoc = "SLABBR_SeocTest_1.0.1";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithNoRev.getSeocId());
}

/**
* Description: Check validity of Seoc title when the Seoc is REV. At least one
* billing code is Precert.
*/
@Test
public void checkSeocRevPrecert()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv1);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1_REV_PRCT";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithRevPrecert.getSeocId());
}

/**
* Description: Check validity of Seoc title when the service is marked as
* No Codes Required.
*/
@Test
public void checkSeocNoCodeRequired()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv3);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1_REV_PRCT";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithRevPrecert.getSeocId());
}

/**
* Description: Check validity of Seoc title when the service is marked as
* Any Code Accepted.
*/
@Test
public void checkSeocAnyCodeAccepted()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv4);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1_REV_PRCT";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithRevPrecert.getSeocId());
}

/**
* Description: Check validity of Seoc title when the Seoc is not REV. At least
* one billing code is Precert
*/
@Test
public void checkSeocPrecertNoRev()
{
Seoc seocWithPrecertNoRev = new Seoc();
seocWithPrecertNoRev.setName("SeocTest");
seocWithPrecertNoRev.setVersionNumber("1.0.1");
seocWithPrecertNoRev.setServiceLine(sl);
seocWithPrecertNoRev.setStatus(active);
seocWithPrecertNoRev.setRev(false);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv1);
seocWithPrecertNoRev.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1_PRCT";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocWithPrecertNoRev.getSeocId());
}

/**
* Description: Check validity of Seoc title when the Seoc is not REV. At least
* one billing code of Precert is not found.
*/
@Test
public void checkSeocNoRevNoPrecert()
{
Seoc seocNoRevNoPrecert = new Seoc();
seocNoRevNoPrecert.setName("SeocTest");
seocNoRevNoPrecert.setVersionNumber("1.0.1");
seocNoRevNoPrecert.setServiceLine(sl);
seocNoRevNoPrecert.setStatus(active);
seocNoRevNoPrecert.setRev(false);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv2);
seocNoRevNoPrecert.setServices(services);

String expectedSeoc = "SLABBR_SeocTest_1.0.1";

assertThat(expectedSeoc.toUpperCase()).isEqualTo(seocNoRevNoPrecert.getSeocId());
}

/**
* Description: Check validity of Seoc name with flags when the Seoc is not REV
* and does not require pre-certification.
*/
@Test
public void checkGetNameWithFlagsNoRevNoPrct()
{
Seoc seocWithNoRevNoPrct = new Seoc();
seocWithNoRevNoPrct.setName("SeocTest");
seocWithNoRevNoPrct.setVersionNumber("1.0.1");
seocWithNoRevNoPrct.setServiceLine(sl);
seocWithNoRevNoPrct.setStatus(active);
seocWithNoRevNoPrct.setRev(false);

String expectedSeoc = "SeocTest";

assertThat(expectedSeoc).isEqualTo(seocWithNoRevNoPrct.getNameWithFlags());
}

/**
* Description: Check validity of Seoc name with flags when the Seoc is REV
*/
@Test
public void checkGetNameWithFlagsRev()
{
Seoc seocWithRev = new Seoc();
seocWithRev.setName("SeocTest");
seocWithRev.setVersionNumber("1.0.1");
seocWithRev.setServiceLine(sl);
seocWithRev.setStatus(active);
seocWithRev.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv2);
seocWithRev.setServices(services);

String expectedSeoc = "SeocTest_REV";

assertThat(expectedSeoc).isEqualTo(seocWithRev.getNameWithFlags());
}

/**
* Description: Check validity of Seoc name with flags when the Seoc is REV.
* At least one billing code is Precert.
*/
@Test
public void checkGetNameWithFlagsRevPrct()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv1);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SeocTest_REV_PRCT";

assertThat(expectedSeoc).isEqualTo(seocWithRevPrecert.getNameWithFlags());
}

/**
* Description: Check validity of Seoc name with flags when the service is
* marked as No Codes Required.
*/
@Test
public void checkGetNameWithFlagsNoCodeRequired()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv3);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SeocTest_REV_PRCT";

assertThat(expectedSeoc).isEqualTo(seocWithRevPrecert.getNameWithFlags());
}

/**
* Description: Check validity of Seoc name with flags when the service is
* marked as Any Code Accepted.
*/
@Test
public void checkGetNameWithFlagsAnyCodeAccepted()
{
Seoc seocWithRevPrecert = new Seoc();
seocWithRevPrecert.setName("SeocTest");
seocWithRevPrecert.setVersionNumber("1.0.1");
seocWithRevPrecert.setServiceLine(sl);
seocWithRevPrecert.setStatus(active);
seocWithRevPrecert.setRev(true);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv4);
seocWithRevPrecert.setServices(services);

String expectedSeoc = "SeocTest_REV_PRCT";

assertThat(expectedSeoc).isEqualTo(seocWithRevPrecert.getNameWithFlags());
}

/**
* Description: Check validity of Seoc name with flags when the Seoc is not REV.
* At least one billing code is Precert
*/
@Test
public void checkGetNameWithFlagsPrecertNoRev()
{
Seoc seocWithPrecertNoRev = new Seoc();
seocWithPrecertNoRev.setName("SeocTest");
seocWithPrecertNoRev.setVersionNumber("1.0.1");
seocWithPrecertNoRev.setServiceLine(sl);
seocWithPrecertNoRev.setStatus(active);
seocWithPrecertNoRev.setRev(false);
List<PayableService> services = new ArrayList<PayableService>();
services.add(serv1);
seocWithPrecertNoRev.setServices(services);

String expectedSeoc = "SeocTest_PRCT";

assertThat(expectedSeoc).isEqualTo(seocWithPrecertNoRev.getNameWithFlags());
}

/**
* Description: After cloning the seoc attributes changed on the clone are not affecting the main copy of clone.
*/
@Test
public void deepCloneNonRecursiveProperties()
{
Seoc thatSeoc = new Seoc();
Date activatedDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");
Date discontDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");
Date effectiveDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");
Date endDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setVersionNumber("1.0.1");
thatSeoc.setEffectiveDate(effectiveDate);
thatSeoc.setEndDate(endDate);
thatSeoc.setDisclaimer("Disclaimer1");
thatSeoc.setDuration(5);
thatSeoc.setDescription("Description1");
thatSeoc.setRev(true);
thatSeoc.setProceduralOverview("ProceduralOverview1");
thatSeoc.setMaxAllowableVisits(5);
thatSeoc.setActivatedTimestamp(activatedDate);
thatSeoc.setActivatedBy("SystemName");
thatSeoc.setDiscontinuedTimestamp(discontDate);
thatSeoc.setDiscontinuedBy("SystemName");
thatSeoc.setStatus(SeocObjectGenerator.datehold);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);
thatSeoc.setServices(new ArrayList<PayableService>());

Seoc thisSeoc = thatSeoc.deepClone();

thisSeoc.setSeocKey(1);
thisSeoc.setName("Seoc Test1");
thisSeoc.setVersionNumber(Constants.VERSION_PENDING_REVISION);
thisSeoc.setEffectiveDate(new Date());
thisSeoc.setEndDate(new Date());
thisSeoc.setDisclaimer("Disclaimer2");
thisSeoc.setDuration(6);
thisSeoc.setDescription("Description2");
thisSeoc.setRev(false);
thisSeoc.setProceduralOverview("ProceduralOverview2");
thisSeoc.setMaxAllowableVisits(6);
thisSeoc.setActivatedTimestamp(new Date());
thisSeoc.setActivatedBy("System");
thisSeoc.setDiscontinuedTimestamp(new Date());
thisSeoc.setDiscontinuedBy("System");
thisSeoc.setStatus(SeocObjectGenerator.inprogress);
thisSeoc.setCategoryOfCare(SeocObjectGenerator.cc2);
thisSeoc.setServiceLine(SeocObjectGenerator.sl2);
thisSeoc.setQasp(SeocObjectGenerator.qasp2);
thisSeoc.setServices(new ArrayList<PayableService>());


assertThat(thisSeoc.getName()).isNotEqualTo(thatSeoc.getName());
assertThat(thisSeoc.getVersionNumber()).isNotEqualTo(thatSeoc.getVersionNumber());
assertThat(thisSeoc.getEffectiveDate()).isNotEqualTo(thatSeoc.getEffectiveDate());
assertThat(thisSeoc.getEndDate()).isNotEqualTo(thatSeoc.getEndDate());
assertThat(thisSeoc.getDisclaimer()).isNotEqualTo(thatSeoc.getDisclaimer());
assertThat(thisSeoc.getDuration()).isNotEqualTo(thatSeoc.getDuration());
assertThat(thisSeoc.getDescription()).isNotEqualTo(thatSeoc.getDescription());
assertThat(thisSeoc.getRev()).isNotEqualTo(thatSeoc.getRev());
assertThat(thisSeoc.getProceduralOverview()).isNotEqualTo(thatSeoc.getProceduralOverview());
assertThat(thisSeoc.getMaxAllowableVisits()).isNotEqualTo(thatSeoc.getMaxAllowableVisits());
assertThat(thisSeoc.getActivatedTimestamp()).isNotEqualTo(thatSeoc.getActivatedTimestamp());
assertThat(thisSeoc.getActivatedBy()).isNotEqualTo(thatSeoc.getActivatedBy());
assertThat(thisSeoc.getDiscontinuedTimestamp()).isNotEqualTo(thatSeoc.getDiscontinuedTimestamp());
assertThat(thisSeoc.getDiscontinuedBy()).isNotEqualTo(thatSeoc.getDiscontinuedBy());
assertThat(thisSeoc.getStatus()).isNotEqualTo(thatSeoc.getStatus());
assertThat(thisSeoc.getCategoryOfCare()).isNotEqualTo(thatSeoc.getCategoryOfCare());
assertThat(thisSeoc.getQasp()).isNotEqualTo(thatSeoc.getQasp());

}

/**
* Description: Deep clone recursively cloned embedded objects and they are referring to different instances of objects.
*/
@Test
public void deepCloneRecursiveProperties()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);

PayableService ps1 = new PayableService();
PayableService ps2 = new PayableService();

ps1.setDescription("PayableService11");
ps1.setBillingCodes(SeocObjectGenerator.bc5Set);

ps2.setDescription("PayableService12");

List<PayableService> psList = new ArrayList<PayableService>();
psList.add(ps1);
psList.add(ps2);
thatSeoc.setServices(psList);

Seoc thisSeoc = thatSeoc.deepClone();

assertThat(thatSeoc.getServices()).size().isEqualTo(2);
assertThat(thisSeoc.getServices()).size().isEqualTo(2);

thatSeoc.getServices().forEach(s -> {
assertThat(thisSeoc.getServices()).doesNotContain(s);
});

assertThat(thisSeoc.getServices().get(0).getBillingCodes()).isEqualTo(SeocObjectGenerator.bc5Set);
}

/**
* Description: Deep clone when noDeactivatedBillingCodes is true
*/
@Test
public void deepCloneNoDeactivatedBillingCodes()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);

PayableService ps1 = new PayableService();
PayableService ps2 = new PayableService();

ps1.setDescription("PayableService11");
ps1.setBillingCodes(SeocObjectGenerator.bc5Set);

ps2.setDescription("PayableService12");

List<PayableService> psList = new ArrayList<PayableService>();
psList.add(ps1);
psList.add(ps2);
thatSeoc.setServices(psList);

Seoc thisSeoc = thatSeoc.deepClone(true);

assertThat(thatSeoc.getServices()).size().isEqualTo(2);
assertThat(thisSeoc.getServices()).size().isEqualTo(2);

thatSeoc.getServices().forEach(s -> {
assertThat(thisSeoc.getServices()).doesNotContain(s);
});

assertThat(thisSeoc.getServices().get(0).getBillingCodes()).isEqualTo(SeocObjectGenerator.bc1234Set);
}

/**
* Description: Deep clone when noDeactivatedBillingCodes is null
*/
@Test
public void deepCloneNoDeactivatedBillingCodesNull()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);

PayableService ps1 = new PayableService();
PayableService ps2 = new PayableService();

ps1.setDescription("PayableService11");
ps1.setBillingCodes(SeocObjectGenerator.bc5Set);

ps2.setDescription("PayableService12");

List<PayableService> psList = new ArrayList<PayableService>();
psList.add(ps1);
psList.add(ps2);
thatSeoc.setServices(psList);

Seoc thisSeoc = thatSeoc.deepClone(null);

assertThat(thatSeoc.getServices()).size().isEqualTo(2);
assertThat(thisSeoc.getServices()).size().isEqualTo(2);

thatSeoc.getServices().forEach(s -> {
assertThat(thisSeoc.getServices()).doesNotContain(s);
});

assertThat(thisSeoc.getServices().get(0).getBillingCodes()).isEqualTo(SeocObjectGenerator.bc5Set);
}

/**
* Description: Deep clone when noDeactivatedBillingCodes is false
*/
@Test
public void deepCloneNoDeactivatedBillingCodesFalse()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);

PayableService ps1 = new PayableService();
PayableService ps2 = new PayableService();

ps1.setDescription("PayableService11");
ps1.setBillingCodes(SeocObjectGenerator.bc5Set);

ps2.setDescription("PayableService12");

List<PayableService> psList = new ArrayList<PayableService>();
psList.add(ps1);
psList.add(ps2);
thatSeoc.setServices(psList);

Seoc thisSeoc = thatSeoc.deepClone(false);

assertThat(thatSeoc.getServices()).size().isEqualTo(2);
assertThat(thisSeoc.getServices()).size().isEqualTo(2);

thatSeoc.getServices().forEach(s -> {
assertThat(thisSeoc.getServices()).doesNotContain(s);
});

assertThat(thisSeoc.getServices().get(0).getBillingCodes()).isEqualTo(SeocObjectGenerator.bc5Set);
}

/**
* Description: Deep clone when Service Line is discontinued.
*/
@Test
public void deepCloneServiceLineDiscontinued()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl3);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc3);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);
thatSeoc.setServices(new ArrayList<PayableService>());

Seoc thisSeoc = thatSeoc.deepClone();

assertThat(thisSeoc.getServiceLine()).isEqualTo(null);
assertThat(thisSeoc.getCategoryOfCare()).isEqualTo(null);
}

/**
* Description: Deep clone when Category of Care is discontinued.
*/
@Test
public void deepCloneCategoryOfCareDiscontinued()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl4);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc4);
thatSeoc.setQasp(SeocObjectGenerator.qasp1);
thatSeoc.setServices(new ArrayList<PayableService>());

Seoc thisSeoc = thatSeoc.deepClone();

assertThat(thisSeoc.getServiceLine()).isEqualTo(thatSeoc.getServiceLine());
assertThat(thisSeoc.getCategoryOfCare()).isEqualTo(null);
}

/**
* Description: Deep clone when Qasp is discontinued.
*/
@Test
public void deepCloneQaspDiscontinued()
{
Seoc thatSeoc = new Seoc();

thatSeoc.setSeocKey(1);
thatSeoc.setName("Seoc Test");
thatSeoc.setServiceLine(SeocObjectGenerator.sl1);
thatSeoc.setCategoryOfCare(SeocObjectGenerator.cc1);
thatSeoc.setQasp(SeocObjectGenerator.qasp3);
thatSeoc.setServices(new ArrayList<PayableService>());

Seoc thisSeoc = thatSeoc.deepClone();

assertThat(thisSeoc.getQasp()).isEqualTo(null);
}

/**
* Description: Seoc Activate Condition Check - Missing Seoc attributes
*/
@Test
public void validationFailedInSeocFields()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "description", null, null, 9, "YES", null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);
Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(8);

}


/**
* Description: Seoc Activate Condition Check - Missing Seoc attributes
*/
@Test
public void validationCheckNullMaxVisitsAllowed()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, null, null, null, null, null, maxVisits, null, null, null, null, null,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "description", null, null, 9, "YES", null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);
Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(8);

}

/**
* Description: Seoc Activate Condition Check - Null Service
*/
@Test
public void validationFailedDueToNoServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", 5, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.datehold, SeocObjectGenerator.qasp1, null);
Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);
Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Condition Check - Empty Services
*/
@Test
public void validationFailedDueToEmptyServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", 5, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.datehold, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Condition Check - Missing Service attributes
*/
@Test
public void validationFailedMissingServiceFields()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", 5, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, null, null, null, 0, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(3);

}

/**
* Description: Seoc Activate Condition Check - Discontinued Service Line
*/
@Test
public void validationFailedServiceLineDiscontinued()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc3, SeocObjectGenerator.sl3, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Condition Check - Discontinued Category of Care
*/
@Test
public void validationFailedCategoryOfCareDiscontinued()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc4, SeocObjectGenerator.sl4, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Condition Check - Discontinued QASP
*/
@Test
public void validationFailedQaspDiscontinued()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp3, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Condition Check - Discontinued Clinical Service
*/
@Test
public void validationFailedClinicalServiceDiscontinued()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs4Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);

}

/**
* Description: Seoc Activate Success
*/
@Test
public void validationSucceeds()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());
PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(0);

}
/**
* Description: Seoc Activate Condition Check - Null Hptc
*/
@Test
public void validationFailedNullHptc()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", 5, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.datehold, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

testSeoc.setHptcs(null);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);
}

/**
* Description: Seoc Activate Condition Check - Empty Hptc
*/
@Test
public void validationFailedEmptyHptc()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", 5, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.datehold, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

PayableService service1 = SeocObjectGenerator.getPayableService(1, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

testSeoc.setHptcs(new HashSet<Hptc>());

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);
}

/**
* Description: Seoc Activate Condition Check - REV is true when precert-required is false
*/
@Test
public void validationFailedREVTruePRCTFalse()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", true, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(SeocObjectGenerator.getBillingCode(1, "01234", "CPT", "Test BillingCode1", false));

PayableService service1 = SeocObjectGenerator.getPayableService("desc", null, null, 5, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc, billingCodes);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(1);
}

/**
* Description: Seoc Activate Condition Check - REV is true when precert-required is true
*/
@Test
public void validationSucceedsREVTruePRCTTrue()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", true, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(SeocObjectGenerator.getBillingCode(1, "01234", "CPT", "Test BillingCode1", false));
billingCodes.add(SeocObjectGenerator.getBillingCode(2, "23456", "CPT", "Test BillingCode2", true));

PayableService service1 = SeocObjectGenerator.getPayableService("desc", null, null, 5, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc, billingCodes);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(0);
}

/**
* Description: Seoc Activate Condition Check - REV is true when precert-required is true, No Code Required
*/
@Test
public void validationSucceedsREVTruePRCTTrueNoCodeRequired()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", true, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(SeocObjectGenerator.getBillingCode(1, "01234", "CPT", "Test BillingCode1", false));

PayableService service1 = SeocObjectGenerator.getPayableService("desc", null, null, 5, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc, billingCodes);
PayableService service2 = SeocObjectGenerator.getPayableService(2, "desc", null, null, 5, CodeRequired.NO.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);

testSeoc.getServices().add(service1);
testSeoc.getServices().add(service2);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(0);
}

/**
* Description: Seoc Activate Condition Check - REV is true when precert-required is true, Any Code Accepted
*/
@Test
public void validationSucceedsREVTruePRCTTrueAnyCodeAccepted()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", true, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(SeocObjectGenerator.getBillingCode(1, "01234", "CPT", "Test BillingCode1", false));

PayableService service1 = SeocObjectGenerator.getPayableService("desc", null, null, 5, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc, billingCodes);
PayableService service2 = SeocObjectGenerator.getPayableService(2, "desc", null, null, 5, CodeRequired.ANY.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc);

testSeoc.getServices().add(service1);
testSeoc.getServices().add(service2);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(0);
}

/**
* Description: Seoc Activate Condition Check - REV is false when precert-required is false
*/
@Test
public void validationSucceedsREVFalsePRCTFalse()
{
Integer maxVisits = null;
Seoc testSeoc = SeocObjectGenerator.getSeoc("name", 1, null, null, null, "disclaimer", 5, "description", false, "proceduralOverview", maxVisits, null, null, null,
null, SeocObjectGenerator.cc1, SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1, new ArrayList<PayableService>());

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(SeocObjectGenerator.getBillingCode(1, "01234", "CPT", "Test BillingCode1", false));

PayableService service1 = SeocObjectGenerator.getPayableService("desc", null, null, 5, CodeRequired.YES.getValue(), null, null, SeocObjectGenerator.cs1Set, testSeoc, billingCodes);
testSeoc.getServices().add(service1);
testSeoc.setStatus(SeocObjectGenerator.datehold);

Set<Hptc> hptcs = new HashSet<Hptc>();
hptcs.add(SeocObjectGenerator.hptc1);
testSeoc.setHptcs(hptcs);

Set<ConstraintViolation<Seoc>> violations = validator.validate(testSeoc);
assertThat(violations.size()).isEqualTo(0);
}


/**
* Description: Effective Date is Null
*/
@Test
public void calculateStatusReturnDraft()
{
String expectedStatus = Constants.STATUS_INPROGRESS;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: Effective Date next day End Date null- return DRAFT
*/
@Test
public void calculateStatusReturnEffectiveDateTomorrow()
{
String expectedStatus = Constants.STATUS_INPROGRESS;
//Set effective date to tomorrow after 5:01 am
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, 1);
cal.set(Calendar.HOUR, 5);
cal.set(Calendar.MINUTE, 1);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.AM_PM, Calendar.AM);
Date effectiveDate = cal.getTime();

Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, effectiveDate, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: Effective date is earlier than today and end date is null
*/
@Test
public void calculateStatusReturnEffectiveDateBeforeToday()
{
String expectedStatus = Constants.STATUS_ACTIVE;
Date effectiveDate = ApiUtil.convertStringToDate("09-04-2018 03:34:05 AM");
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, effectiveDate, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: Effective Date is earlier than today and end date after today
*/
@Test
public void calculateStatusReturnEffectiveDateEndDate()
{
Date effectiveDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");
Date endDate = TestUtil.getEffectiveDate();
String expectedStatus = Constants.STATUS_ACTIVE;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, effectiveDate, endDate, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: Effective Date and End Date past today
*/
@Test
public void calculateStatusReturnEffectiveDateEndDatePassed()
{
Date effectiveDate = ApiUtil.convertStringToDate("09-04-2018 07:34:05 AM");
Date endDate = ApiUtil.convertStringToDate("09-05-2018 07:34:05 AM");
String expectedStatus = Constants.STATUS_DISCONTINUED;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, effectiveDate, endDate, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.inprogress, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}


/**
* Description: SEOC with legacy status Draft returns In-Progress
*/
@Test
public void calculateStatusLegacyStatusDraft()
{
String expectedStatus = Constants.STATUS_INPROGRESS;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.draft, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: SEOC with legacy status Active returns Date Hold
*/
@Test
public void calculateStatusLegacyStatusActive()
{
String expectedStatus = Constants.STATUS_DATEHOLD;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

/**
* Description: SEOC with legacy status Discontinued returns Date Hold
*/
@Test
public void calculateStatusLegacyStatusDiscontinued()
{
String expectedStatus = Constants.STATUS_DATEHOLD;
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.discontinue, SeocObjectGenerator.qasp1,null);

String actualStatus = testSeoc.getCalculatedStatus();
assertThat(actualStatus).isEqualTo(expectedStatus);
}

@Test
public void removeBillingCodeSuccess()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);
PayableService serv = SeocObjectGenerator.getPayableService(1, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);
BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
serv.setBillingCodes(new HashSet<BillingCode>());
serv.getBillingCodes().add(bc1);
testSeoc.setServices(new ArrayList<PayableService>());
testSeoc.getServices().add(serv);
assertThat(testSeoc.getServices().get(0).getBillingCodes()).contains(bc1);
testSeoc.removeBillingCode(bc1);
assertThat(testSeoc.getServices().get(0).getBillingCodes()).doesNotContain(bc1);
}

@Test
public void updateBillingCodeSuccess()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

PayableService serv = SeocObjectGenerator.getPayableService(1, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);

serv.setBillingCodes(new HashSet<BillingCode>());
serv.getBillingCodes().add(bc1);
testSeoc.setServices(new ArrayList<PayableService>());
testSeoc.getServices().add(serv);
assertThat(testSeoc.getServices().get(0).getBillingCodes()).contains(bc1);
testSeoc.updateBillingCode(bc1, bc2);
assertThat(testSeoc.getServices().get(0).getBillingCodes()).doesNotContain(bc1);
assertThat(testSeoc.getServices().get(0).getBillingCodes()).contains(bc2);
}

@Test
public void updateBillingCodeNullServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);

assertThat(testSeoc.getServices()).isNull();
testSeoc.updateBillingCode(bc1, bc2);
assertThat(testSeoc.getServices()).isNull();
}

@Test
public void updateBillingCodeEmptyServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);

List<PayableService> services = new ArrayList<PayableService>();

testSeoc.setServices(services);

assertThat(testSeoc.getServices().isEmpty()).isTrue();
testSeoc.updateBillingCode(bc1, bc2);
assertThat(testSeoc.getServices().isEmpty()).isTrue();
}

@Test
public void updateBillingCodePreviousBillingCodeNotInService()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

PayableService serv = SeocObjectGenerator.getPayableService(1, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);

serv.setBillingCodes(new HashSet<BillingCode>());
testSeoc.setServices(new ArrayList<PayableService>());
testSeoc.getServices().add(serv);
assertThat(testSeoc.getServices().get(0).getBillingCodes().isEmpty()).isTrue();
testSeoc.updateBillingCode(bc1, bc2);
assertThat(testSeoc.getServices().get(0).getBillingCodes().isEmpty()).isTrue();
}

@Test
public void getBillingCodesForSeocNullServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

testSeoc.setServices(null);

assertThat(testSeoc.getBillingCodesForSeoc()).isEqualTo(null);
}

@Test
public void getBillingCodesForSeocEmptyServices()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

testSeoc.setServices(new ArrayList<PayableService>());

assertThat(testSeoc.getBillingCodesForSeoc()).isEqualTo(null);
}

@Test
public void getBillingCodesForSeocSuccess()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, null, 0, null,
false, null, 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

PayableService serv1 = SeocObjectGenerator.getPayableService(1, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);
PayableService serv2 = SeocObjectGenerator.getPayableService(2, "description", 4, "TEST", 4, CodeRequired.YES.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);
PayableService serv3 = SeocObjectGenerator.getPayableService(3, "description", 4, "TEST", 4, CodeRequired.NO.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);
PayableService serv4 = SeocObjectGenerator.getPayableService(4, "description", 4, "TEST", 4, CodeRequired.ANY.getValue(), "System", new Date(), SeocObjectGenerator.cs1Set, testSeoc);

BillingCode bc1 = SeocObjectGenerator.getBillingCode(5, "BC1", "CPT", "DESC", true);
BillingCode bc2 = SeocObjectGenerator.getBillingCode(6, "BC2", "CPT", "DESC", true);
BillingCode bc3 = SeocObjectGenerator.getBillingCode(7, "BC3", "CPT", "DESC", true);
BillingCode bc4 = SeocObjectGenerator.getBillingCode(8, "BC4", "CPT", "DESC", true);

serv1.setBillingCodes(new HashSet<BillingCode>());
serv1.getBillingCodes().add(bc1);
serv1.getBillingCodes().add(bc2);
serv1.getBillingCodes().add(bc3);
serv1.getBillingCodes().add(null);

serv2.setBillingCodes(new HashSet<BillingCode>());
serv2.getBillingCodes().add(bc2);
serv2.getBillingCodes().add(bc3);
serv2.getBillingCodes().add(bc4);

serv3.setBillingCodes(new HashSet<BillingCode>());

serv4.setBillingCodes(null);

testSeoc.setServices(new ArrayList<PayableService>());
testSeoc.getServices().add(serv1);
testSeoc.getServices().add(serv2);
testSeoc.getServices().add(serv3);
testSeoc.getServices().add(serv4);
testSeoc.getServices().add(null);

Set<BillingCode> billingCodes = new HashSet<BillingCode>();

billingCodes.add(bc1);
billingCodes.add(bc2);
billingCodes.add(bc3);
billingCodes.add(bc4);

assertThat(testSeoc.getBillingCodesForSeoc()).isEqualTo(billingCodes);
}

private List<String> getListOfMatches(String string, String substr) {
List<String> matches = new ArrayList<String>();

Matcher matcher = Pattern.compile(substr).matcher(string);

while(matcher.find()) {
matches.add(matcher.group(0));
}

return matches;
}

@Test
public void updateFormattedComment()
{
Seoc testSeoc = SeocObjectGenerator.getSeoc("Name", 1, null, null, null, "disclaimer\nhas multiple lines\n", 0, "disclaimer\nhas multiple lines\n",
false, "procedural overview\nhas multiple lines\n", 0, null, "System", null, "System", SeocObjectGenerator.cc1,
SeocObjectGenerator.sl1, SeocObjectGenerator.active, SeocObjectGenerator.qasp1,null);

String comment = testSeoc.getComment();
List<String> crlfMatches = getListOfMatches(comment, "\r\n");
List<String> lfMatches = getListOfMatches(comment, "\n");

// If the number of \r\n sequences is the same as the number of \n sequences, there are no sequences that are just \n
assertThat(crlfMatches.size()).isEqualTo(lfMatches.size());
}
}