use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOTest method testRead.
/**
* Test of read method, of class ContractDAOImpl.
*/
@Test
public void testRead() {
Contract contract = contractDAO.read(1L);
assertNotNull(contract);
assertEquals("http://www.contract1.com/", getUrlFromContractOption(contract));
assertEquals(Long.valueOf("1"), contract.getUser().getId());
Set<String> functionalityCodeSet = new HashSet<>();
for (Functionality functionality : contract.getFunctionalitySet()) {
functionalityCodeSet.add(functionality.getCode());
}
assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
assertTrue(!functionalityCodeSet.contains("SITE_AUDIT"));
assertEquals(1, contract.getReferentialSet().size());
assertTrue(contract.getScenarioSet().isEmpty());
contract = contractDAO.read(2L);
assertNotNull(contract);
assertEquals("http://www.contract2.com/", getUrlFromContractOption(contract));
assertEquals(Long.valueOf("1"), contract.getUser().getId());
functionalityCodeSet = new HashSet<>();
for (Functionality functionality : contract.getFunctionalitySet()) {
functionalityCodeSet.add(functionality.getCode());
}
assertTrue(functionalityCodeSet.contains("PAGES_AUDIT"));
assertTrue(functionalityCodeSet.contains("SITE_AUDIT"));
assertEquals(2, contract.getReferentialSet().size());
assertEquals(2, contract.getScenarioSet().size());
contract = contractDAO.read(Long.valueOf(3));
assertNull(contract);
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class PageListControllerTest method setUpActDataService.
/**
* @param isActSiteScope
*/
private void setUpActDataService(boolean isActSiteScope) {
Scope mockGroupOfPagesScope = new Scope();
mockGroupOfPagesScope.setCode(ScopeEnum.GROUPOFPAGES);
Scope mockSiteScope = new Scope();
mockSiteScope.setCode(ScopeEnum.DOMAIN);
Contract mockContract = new Contract();
Act mockAct = new Act();
if (isActSiteScope) {
mockAct.setScope(mockSiteScope);
} else {
mockAct.setScope(mockGroupOfPagesScope);
}
GregorianCalendar calendar = new GregorianCalendar();
calendar.set(2030, 01, 01);
mockContract.setEndDate(calendar.getTime());
mockContract.setUser(mockUser);
mockContract.setLabel("CONTRACT LABEL");
mockContract.setId(1L);
mockAct.setContract(mockContract);
when(mockActDataService.getActFromAudit(mockAudit)).thenReturn(mockAct);
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class AddScenarioFormValidator method checkScenarioLabel.
/**
* @param addScenarioCommand
* @param errors
* @return whether the scenario handled by the current AddScenarioCommand
* has a well-formed label
*/
public boolean checkScenarioLabel(AddScenarioCommand addScenarioCommand, Errors errors) {
if (StringUtils.isEmpty(addScenarioCommand.getScenarioLabel())) {
// if no label set
LOGGER.debug("empty Scenario Label");
errors.rejectValue(GENERAL_ERROR_MSG_KEY, MANDATORY_FIELD_MSG_BUNDLE_KEY);
errors.rejectValue(SCENARIO_LABEL_KEY, NO_SCENARIO_LABEL_MSG_BUNDLE_KEY);
return false;
}
Contract contract = contractDataService.read(addScenarioCommand.getContractId());
Set<String> scenarioLabelSet = new HashSet();
for (Scenario scenario : contract.getScenarioSet()) {
scenarioLabelSet.add(scenario.getLabel());
}
if (scenarioLabelSet.contains(addScenarioCommand.getScenarioLabel())) {
errors.rejectValue(GENERAL_ERROR_MSG_KEY, MANDATORY_FIELD_MSG_BUNDLE_KEY);
errors.rejectValue(SCENARIO_LABEL_KEY, SCENARIO_LABEL_EXISTS_MSG_BUNDLE_KEY);
return false;
}
return true;
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractFactory method createContract.
public Contract createContract(String label, Date beginDate, Date endDate, Date renewalDate, Float price, Set<Functionality> functionalitySet, Set<OptionElementImpl> optionElementSet, Set<Referential> referentialSet, Set<Scenario> ScenarioSet, User user) {
Contract contract = create();
contract.setLabel(label);
contract.setBeginDate(beginDate);
contract.setEndDate(endDate);
contract.setRenewalDate(renewalDate);
contract.addAllFunctionality(functionalitySet);
contract.addAllOptionElement(optionElementSet);
contract.addAllReferential(referentialSet);
contract.addAllScenario(ScenarioSet);
contract.setPrice(price);
return contract;
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractDAOTest method testUpdate.
/**
* Test of update method, of class ContractDAOImpl.
*/
@Test
public void testUpdate() {
Contract contract = contractDAO.read((1L));
Float contractPrice = contract.getPrice();
contract.setPrice(contractPrice + 200);
contractDAO.update(contract);
assertEquals(contractPrice + 200, contractDAO.read((1L)).getPrice());
}
Aggregations