target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void nullNameShouldReturnNull() { openadk.library.common.Name sifName = null; Name sliName = converter.convert(sifName); Assert.assertNull(sliName); }
|
public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
@Test public void emptySifNameShouldMapToNullAndDefaultValues() { openadk.library.common.Name sifName = new openadk.library.common.Name(); Name sliName = converter.convert(sifName); Assert.assertNotNull(sliName); Assert.assertEquals("Missing first name should map to Unknown", defaultName, sliName.getFirstName()); Assert.assertEquals("Missing last name should map to Unknown", defaultName, sliName.getLastSurname()); Assert.assertNull("Missing optional fields should map to null", sliName.getGenerationCodeSuffix()); Assert.assertNull("Missing optional fields should map to null", sliName.getMiddleName()); Assert.assertNull("Missing optional fields should map to null", sliName.getPersonalTitlePrefix()); }
|
public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
@Test public void shouldMapSifNameToSliName() { Name sliName = converter.convert(createSifName(prefixes.get(0), suffixes.get(0))); Assert.assertNotNull(sliName); Assert.assertEquals("Incorrect prefix mapping", prefixes.get(0), sliName.getPersonalTitlePrefix()); Assert.assertEquals("Incorrect firstName mapping", firstName, sliName.getFirstName()); Assert.assertEquals("Incorrect lastName mapping", lastName, sliName.getLastSurname()); Assert.assertEquals("Incorrect middleName mapping", middleName, sliName.getMiddleName()); Assert.assertEquals("Incorrect suffix", suffixes.get(0), sliName.getGenerationCodeSuffix()); for (String prefix : prefixes) { sliName = converter.convert(createSifName(prefix, suffixes.get(0))); Assert.assertNotNull(sliName); Assert.assertEquals("Incorrect prefix mapping", prefix, sliName.getPersonalTitlePrefix()); } for (String suffix : suffixes) { sliName = converter.convert(createSifName(prefixes.get(0), suffix)); Assert.assertNotNull(sliName); Assert.assertEquals("Incorrect suffix", suffix, sliName.getGenerationCodeSuffix()); } sliName = converter.convert(createSifName("unsupported", suffixes.get(0))); Assert.assertNotNull(sliName); Assert.assertNull("Unsupported prefix should map to null", sliName.getPersonalTitlePrefix()); sliName = converter.convert(createSifName(prefixes.get(0), "unsupported")); Assert.assertNotNull(sliName); Assert.assertNull("Unsupported suffix should map to null", sliName.getGenerationCodeSuffix()); }
|
public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
NameConverter { public Name convert(openadk.library.common.Name sifName) { if (sifName == null) { return null; } Name sliName = new Name(); mapSifNameIntoSliName(sifName, sliName); return sliName; } Name convert(openadk.library.common.Name sifName); void mapSifNameIntoSliName(openadk.library.common.Name sifName, Name sliName); }
|
@Test public void testshouldExtractSchoolYear() { Map<String, Object> gradeBody = new HashMap<String, Object>(); gradeBody.put(ParameterConstants.SCHOOL_YEAR, "2009-2010"); Entity grade = new MongoEntity(EntityNames.GRADE, gradeBody); Assert.assertTrue(simpleExtractVerifier.shouldExtract(grade, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(simpleExtractVerifier.shouldExtract(grade, DateTime.parse("2010-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(simpleExtractVerifier.shouldExtract(grade, null)); Assert.assertFalse(simpleExtractVerifier.shouldExtract(grade, DateTime.parse("2009-05-24", DateHelper.getDateTimeFormat()))); Assert.assertFalse(simpleExtractVerifier.shouldExtract(grade, DateTime.parse("2008-05-24", DateHelper.getDateTimeFormat()))); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void testNullObject() { String result = converter.convert(null); Assert.assertNull("Teaching Assignment list should be null", result); }
|
public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } String convert(HRProgramType hrProgramType); }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } String convert(HRProgramType hrProgramType); }
|
@Test public void testMappings() { map.clear(); map.put(ProgramTypeCode.ADULT_BASIC_EDUCATION, "Title I-Non-Academic"); map.put(ProgramTypeCode.ADULT_CONTINUING_EDUCATION, "Title I-Non-Academic"); map.put(ProgramTypeCode.ADULT_ENGLISH_AS_A_SECOND, "Bilingual/English as a Second Language"); map.put(ProgramTypeCode.ADVANCED_ADULT_BASIC_EDUCATION, "Title I-Non-Academic"); map.put(ProgramTypeCode.AGRICULTURE, "Title I-Non-Academic"); map.put(ProgramTypeCode.ALTERNATIVE_EDUCATION, "Special Education"); map.put(ProgramTypeCode.ATHLETICS, "Title I-Non-Academic"); map.put(ProgramTypeCode.AUTISM, "Special Education"); map.put(ProgramTypeCode.BILINGUAL_EDUCATION_PROGRAM, "Bilingual/English as a Second Language"); map.put(ProgramTypeCode.BRAIN_INJURY, "Special Education"); map.put(ProgramTypeCode.BUSINESS, "Title I-Academic"); map.put(ProgramTypeCode.CIVIC_SERVICES, "Title I-Non-Academic"); map.put(ProgramTypeCode.COCURRICULAR_PROGRAMS, "Regular Education"); map.put(ProgramTypeCode.COLLEGE_PREPARATORY, "Regular Education"); map.put(ProgramTypeCode.COMMUNITY_JUNIOR_COLLEGE, "Regular Education"); map.put(ProgramTypeCode.COMMUNITY_RECREATION, "Title I-Non-Academic"); map.put(ProgramTypeCode.COMMUNITY_SERVICES_PROGRAM, "Title I-Non-Academic"); map.put(ProgramTypeCode.COMPENSATORY_DISADVANTAGED, "Special Education"); map.put(ProgramTypeCode.CONSUMER_AND_HOME_MAKING, "Title I-Non-Academic"); map.put(ProgramTypeCode.CONTENT_ESL, "Bilingual/English as a Second Language"); map.put(ProgramTypeCode.COORDINATION_OF_CASEWORK, "Title I-Non-Academic"); map.put(ProgramTypeCode.COUNSELING_SERVICES, "Title I-Non-Academic"); map.put(ProgramTypeCode.CROSS_CATEGORICAL, "Title I-Non-Academic"); map.put(ProgramTypeCode.CURRICULUM_CONTENT_IN_NATIVE, "Title I-Academic"); map.put(ProgramTypeCode.CUSTODY_AND_CHILD_CARE, "Title I-Non-Academic"); map.put(ProgramTypeCode.DEAF_BLIND, "Special Education"); map.put(ProgramTypeCode.DEVELOPMENTAL_BILINGUAL, "Special Education"); map.put(ProgramTypeCode.DEVELOPMENTAL_DELAY, "Special Education"); map.put(ProgramTypeCode.EARLY_IDENTIFICATION, "Special Education"); map.put(ProgramTypeCode.EARLY_INTERVENTION, "Special Education"); map.put(ProgramTypeCode.EMOTIONAL_DISTURBANCE, "Special Education"); map.put(ProgramTypeCode.ENGLISH_AS_A_SECOND_LANGUAGE, "Bilingual/English as a Second Language"); map.put(ProgramTypeCode.EVEN_START, "Special Education"); map.put(ProgramTypeCode.EXTENDED_DAY_CHILD_CARE, "Special Education"); map.put(ProgramTypeCode.GENERAL_EDUCATIONAL_DEVELOPMEN, "Title I-Academic"); map.put(ProgramTypeCode.GIFTED_AND_TALENTED, "Special Education"); map.put(ProgramTypeCode.HEAD_START, "Special Education"); map.put(ProgramTypeCode.HEALTH, "Title I-Non-Academic"); map.put(ProgramTypeCode.HEALTH_SERVICES, "Title I-Non-Academic"); map.put(ProgramTypeCode.HEARING_IMPAIRMENT, "Special Education"); map.put(ProgramTypeCode.IMMIGRANT_EDUCATION, "Special Education"); map.put(ProgramTypeCode.INDIAN_EDUCATION, "Special Education"); map.put(ProgramTypeCode.INTERNATIONAL_BACCALAUREATE, "Special Education"); map.put(ProgramTypeCode.LEARNING_DISABILITIES, "Special Education"); map.put(ProgramTypeCode.LIBRARY_MEDIA_SERVICES, "Title I-Non-Academic"); map.put(ProgramTypeCode.LIFE_ENRICHMENT, "Title I-Non-Academic"); map.put(ProgramTypeCode.MAGNET_SPECIAL_PROGRAM, "Special Education"); map.put(ProgramTypeCode.MARKETING, "Title I-Non-Academic"); map.put(ProgramTypeCode.MENTAL_RETARDATION, "Special Education"); map.put(ProgramTypeCode.MIGRANT_EDUCATION, "Special Education"); map.put(ProgramTypeCode.MULTIPLE_DISABILITIES, "Special Education"); map.put(ProgramTypeCode.NATIVE_LANGUAGE_SUPPORT, "Title I-Academic"); map.put(ProgramTypeCode.OCCUPATIONAL, "Special Education"); map.put(ProgramTypeCode.OCCUPATIONAL_HOME_ECONOMICS, "Special Education"); map.put(ProgramTypeCode.ORTH_IMPAIRMENT, "Special Education"); map.put(ProgramTypeCode.OTHER, "Special Education"); map.put(ProgramTypeCode.OTHER_ADULT_CONTINUING, "Special Education"); map.put(ProgramTypeCode.OTHER_COMMUNITY_SERVICES, "Special Education"); map.put(ProgramTypeCode.OTHER_SP_ED, "Special Education"); map.put(ProgramTypeCode.OTHER_VOCATIONAL_EDUCATION, "Special Education"); map.put(ProgramTypeCode.PSYCHOLOGICAL_SERVICE, "Title I-Non-Academic"); map.put(ProgramTypeCode.PUBLIC_LIBRARY_SERVICES, "Title I-Non-Academic"); map.put(ProgramTypeCode.REGULAR_EDUCATION, "Regular Education"); map.put(ProgramTypeCode.REMEDIAL_EDUCATION, "Special Education"); map.put(ProgramTypeCode.RETRAINING_FOR_NEW_OCCUPATION, "Title I-Non-Academic"); map.put(ProgramTypeCode.SCHOOL_TO_WORK_OPPORTUNITIES, "Special Education"); map.put(ProgramTypeCode.SERVICE_LEARNING, "Title I-Non-Academic"); map.put(ProgramTypeCode.SPECIAL_EDUCATION_SERVICES, "Special Education"); map.put(ProgramTypeCode.SPECIAL_INTEREST, "Special Education"); map.put(ProgramTypeCode.SPEECH_IMPAIREMENT, "Special Education"); map.put(ProgramTypeCode.STUDENT_RETENTION, "Special Education"); map.put(ProgramTypeCode.SUBSTANCE_ABUSE_EDUCATION, "Special Education"); map.put(ProgramTypeCode.TECHNICAL, "Title I-Non-Academic"); map.put(ProgramTypeCode.TECHNICAL_PREPARATORY, "Title I-Non-Academic"); map.put(ProgramTypeCode.TECHNOLOGY_INDUSTRIAL, "Title I-Non-Academic"); map.put(ProgramTypeCode.TRADE_AND_INDUSTRIAL, "Title I-Non-Academic"); map.put(ProgramTypeCode.TWO_WAY_BILINGUAL_EDUCATION, "Bilingual/English as a Second Language"); map.put(ProgramTypeCode.UPGRADING_IN_CURRENT_OCCUPATIO, "Title I-Non-Academic"); map.put(ProgramTypeCode.VISUAL_IMPAIRMENT, "Special Education"); map.put(ProgramTypeCode.VOCATIONAL_EDUCATION, "Regular Education"); map.put(ProgramTypeCode.WELFARE_ACTIVITIES, "Title I-Non-Academic"); List<HRProgramType> list = getHRProgramTypes(); for (HRProgramType hrt : list) { testMapping(hrt.getCode(), converter.convert(hrt)); } }
|
public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } String convert(HRProgramType hrProgramType); }
|
HRProgramTypeConverter { public String convert(HRProgramType hrProgramType) { if (hrProgramType == null) { return null; } return toSliProgramAssignment(ProgramTypeCode.wrap(hrProgramType.getCode())); } String convert(HRProgramType hrProgramType); }
|
@Test public void testNullObject() { String result = converter.convert(null); Assert.assertNull("Race list should be null", result); }
|
public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
@Test public void testMale() { String result = converter.convert("M"); Assert.assertEquals("Male", result); }
|
public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
@Test public void testFemale() { String result = converter.convert("F"); Assert.assertEquals("Female", result); }
|
public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
@Test public void testUnknown() { String result = converter.convert("U"); Assert.assertNull(result); }
|
public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
GenderConverter { public String convert(String gender) { return GENDER_TYPE_MAP.get(gender); } String convert(String gender); }
|
@Test public void testNull() { String result = converter.convert(null); Assert.assertNull("Operational status should be null", result); }
|
public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
@Test public void testEmpty() { OperationalStatus status = OperationalStatus.wrap(""); String result = converter.convert(status); Assert.assertNull("Operational status should be null", result); }
|
public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
@Test public void testMappings() { map.clear(); map.put(OperationalStatus.AGENCY_CHANGED, "Changed Agency"); map.put(OperationalStatus.AGENCY_CLOSED, "Closed"); map.put(OperationalStatus.AGENCY_FUTURE, "Future"); map.put(OperationalStatus.AGENCY_INACTIVE, "Inactive"); map.put(OperationalStatus.AGENCY_NEW, "New"); map.put(OperationalStatus.AGENCY_OPEN, "Active"); map.put(OperationalStatus.CHANGED_BOUNDARY, null); map.put(OperationalStatus.SCHOOL_CLOSED, "Closed"); map.put(OperationalStatus.SCHOOL_FUTURE, "Future"); map.put(OperationalStatus.SCHOOL_INACTIVE, "Inactive"); map.put(OperationalStatus.SCHOOL_NEW, "New"); map.put(OperationalStatus.SCHOOL_OPEN, "Active"); for (OperationalStatus status : map.keySet()) { String expected = map.get(status); String result = converter.convert(status); Assert.assertEquals(expected, result); } String result = converter.convert(OperationalStatus.wrap("something else")); Assert.assertNull(result); }
|
public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
OperationalStatusConverter { public String convert(OperationalStatus operationalStatus) { if (operationalStatus == null || operationalStatus.getValue() == null || operationalStatus.getValue().isEmpty()) { return null; } return OPERATIONAL_STATUS_MAP.get(operationalStatus); } String convert(OperationalStatus operationalStatus); }
|
@Test public void testNull() { String result = converter.convert(null); Assert.assertNull("School category should be null", result); }
|
public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
@Test public void testshouldExtractBeginDate() { Map<String, Object> body = new HashMap<String, Object>(); body.put(ParameterConstants.BEGIN_DATE, "2001-01-01"); Entity studentProgramAssociation = new MongoEntity(EntityNames.STUDENT_PROGRAM_ASSOCIATION, body); Assert.assertEquals(true, simpleExtractVerifier.shouldExtract(studentProgramAssociation, DateTime.parse("2001-01-01", DateHelper.getDateTimeFormat()))); Assert.assertEquals(true, simpleExtractVerifier.shouldExtract(studentProgramAssociation, null)); Assert.assertEquals(false, simpleExtractVerifier.shouldExtract(studentProgramAssociation, DateTime.parse("2000-01-01", DateHelper.getDateTimeFormat()))); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
SimpleExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String entityDate = EntityDateHelper.retrieveDate(entity); return EntityDateHelper.isPastOrCurrentDate(entityDate, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void testListNull() { List<String> result = converter.convertAsList(null); Assert.assertNull("School category should be null", result); }
|
public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
@Test public void testEmpty() { SchoolLevelType type = SchoolLevelType.wrap(""); String result = converter.convert(type); Assert.assertNull(result); }
|
public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
SchoolLevelTypeConverter { public String convert(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } return SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
@Test public void testListEmpty() { SchoolLevelType type = SchoolLevelType.wrap(""); List<String> result = converter.convertAsList(type); Assert.assertEquals(0, result.size()); }
|
public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
SchoolLevelTypeConverter { public List<String> convertAsList(SchoolLevelType schoolLevelType) { if (schoolLevelType == null) { return null; } ArrayList<String> list = new ArrayList<String>(); String category = SCHOOL_LEVEL_TYPE_MAP.get(schoolLevelType); if (category != null) { list.add(category); } return list; } String convert(SchoolLevelType schoolLevelType); List<String> convertAsList(SchoolLevelType schoolLevelType); }
|
@Test public void testNullObject() { List<StaffIdentificationCode> result = converter.convert((HrOtherIdList) null); Assert.assertNull("StaffIdentificationCode list should be null", result); result = converter.convert((OtherIdList) null); Assert.assertNull("StaffIdentificationCode list should be null", result); }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testEmptyHrOtherIdList() { HrOtherIdList list = new HrOtherIdList(); list.setOtherIds(new OtherId[0]); List<StaffIdentificationCode> result = converter.convert(list); Assert.assertEquals(0, result.size()); }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testEmptyOtherIdList() { OtherIdList list = new OtherIdList(); list.setOtherIds(new OtherId[0]); List<StaffIdentificationCode> result = converter.convert(list); Assert.assertEquals(0, result.size()); }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testEmptyOtherId4HrOtherIdList() { HrOtherIdList list = new HrOtherIdList(); OtherId original = new OtherId(); list.add(original); List<StaffIdentificationCode> result = converter.convert(list); Assert.assertEquals(1, result.size()); StaffIdentificationCode it = result.get(0); Assert.assertEquals(original.getValue(), it.getID()); Assert.assertEquals("Other", it.getIdentificationSystem()); }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testEmptyOtherId4OtherIdList() { OtherIdList list = new OtherIdList(); OtherId original = new OtherId(); list.add(original); List<StaffIdentificationCode> result = converter.convert(list); Assert.assertEquals(1, result.size()); StaffIdentificationCode it = result.get(0); Assert.assertEquals(original.getValue(), it.getID()); Assert.assertEquals("Other", it.getIdentificationSystem()); }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testMappings() { map.clear(); map.put(OtherIdType.ACT_INST, "Other"); map.put(OtherIdType.ACT_PROG, "Other"); map.put(OtherIdType.ATP, "Other"); map.put(OtherIdType.CA_SIN, "Canadian SIN"); map.put(OtherIdType.CERTIFICATE, "Professional Certificate"); map.put(OtherIdType.CONTRACTOR, "Other"); map.put(OtherIdType.DISTRICT_ASSIGNED, "District"); map.put(OtherIdType.DRIVERS_LICENSE, "Drivers License"); map.put(OtherIdType.DUNS, "Other"); map.put(OtherIdType.FAMILY_UNIT, "Other"); map.put(OtherIdType.FEDERAL, "Federal"); map.put(OtherIdType.HEALTH_RECORD, "Health Record"); map.put(OtherIdType.IPEDS, "Other"); map.put(OtherIdType.LEA_SCHOOL, "School"); map.put(OtherIdType.MEDICAID, "Medicaid"); map.put(OtherIdType.MIGRANT, "Other"); map.put(OtherIdType.NCES_LEA, "Other"); map.put(OtherIdType.NCES_LEA, "Other"); map.put(OtherIdType.OTHER, "Other"); map.put(OtherIdType.OTHER_AGENCY, "Other"); map.put(OtherIdType.OTHER_FEDERAL, "Other Federal"); map.put(OtherIdType.PERSONAL, "Other"); map.put(OtherIdType.SCHOOL_ASSIGNED, "School"); map.put(OtherIdType.SEA_LEA, "State"); map.put(OtherIdType.SEA_SCHOOL, "State"); map.put(OtherIdType.SELECTIVE_SERVICE, "Other"); map.put(OtherIdType.SIF1x_DISTRICT_ASSIGNED_NUM, "District"); map.put(OtherIdType.SIF1x_DRIVERS_LICENSE, "Drivers License"); map.put(OtherIdType.SIF1x_FAMILY_UNIT, "Other"); map.put(OtherIdType.SIF1x_HEATH_RECORD, "Health Record"); map.put(OtherIdType.SIF1x_MEDICAID, "Medicaid"); map.put(OtherIdType.SIF1x_MIGRANT, "Other"); map.put(OtherIdType.SIF1x_OTHER, "Other"); map.put(OtherIdType.SIF1x_PIN, "PIN"); map.put(OtherIdType.SIF1x_PROFESSIONAL_LICENSE, "Professional Certificate"); map.put(OtherIdType.SIF1x_SCHOOL_ASSIGNED_NUM, "School"); map.put(OtherIdType.SIF1x_SELECTIVE_SERVICE, "Selective Service"); map.put(OtherIdType.SIF1x_SSN, "SSN"); map.put(OtherIdType.SIF1x_STATE_ASSIGNED_NUM, "State"); map.put(OtherIdType.SIF1x_VISA, "US Visa"); HrOtherIdList list = getHrOtherIdList(); List<StaffIdentificationCode> results = converter.convert(list); Assert.assertEquals(list.size(), results.size()); int newCounter = 0; for (StaffIdentificationCode it : results) { Assert.assertNotNull(it); OtherId original = list.get(newCounter++); testMapping(original, it); } OtherIdList list2 = getOtherIdList(); List<StaffIdentificationCode> results2 = converter.convert(list2); Assert.assertEquals(list2.size(), results2.size()); newCounter = 0; for (StaffIdentificationCode it : results2) { Assert.assertNotNull(it); OtherId original = list2.get(newCounter++); testMapping(original, it); } }
|
public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
HrOtherIdListConverter { public List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList) { if (hrOtherIdList == null) { return null; } return toSliStaffIdentificationCodeList(hrOtherIdList.getOtherIds()); } List<StaffIdentificationCode> convert(HrOtherIdList hrOtherIdList); List<StaffIdentificationCode> convert(OtherIdList otherIdList); }
|
@Test public void testNullObject() { List<String> result = converter.convert(null); Assert.assertNull("Address list should be null", result); }
|
public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
@Test public void testSholdExtractEntities() { List<Entity> seaos = new ArrayList<Entity>(); Map<String, Object> body = new HashMap<String, Object>(); body.put(ParameterConstants.BEGIN_DATE, "2001-05-24"); Entity entity1 = new MongoEntity(EntityNames.STUDENT_PROGRAM_ASSOCIATION, body); Map<String, Object> body2 = new HashMap<String, Object>(); body2.put(ParameterConstants.BEGIN_DATE, "2009-01-01"); Entity entity2 = new MongoEntity(EntityNames.STUDENT_PROGRAM_ASSOCIATION, body); seaos.add(entity1); seaos.add(entity2); seaos.add(createSEOA("2002-01-01", "2003-01-01")); seaos.add(createSEOA("2005-01-01", "2008-01-01")); Assert.assertFalse(tsaev.shouldExtract(seaos, DateTime.parse("2001-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(tsaev.shouldExtract(seaos, DateTime.parse("2010-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(tsaev.shouldExtract(seaos, DateTime.parse("2006-05-23", DateHelper.getDateTimeFormat()))); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void testEmptyList() { List<String> result = converter.convert(new LanguageList()); Assert.assertEquals(0, result.size()); }
|
public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
@Test public void testEmptyLanguage() { LanguageList list = new LanguageList(); openadk.library.common.Language original = new openadk.library.common.Language(); list.add(original); List<String> result = converter.convert(list); Assert.assertEquals(1, result.size()); String language = result.get(0); Assert.assertEquals("Other", language); }
|
public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
@Test public void testConversion() { map.clear(); map.put(LanguageCode.CHECHEN, "Other languages"); map.put(LanguageCode.CHEROKEE, "Cherokee"); map.put(LanguageCode.CHINESE, "Mandarin (Chinese)"); map.put(LanguageCode.ENGLISH, "English"); map.put(LanguageCode.FRENCH, "French"); map.put(LanguageCode.GERMAN, "German"); map.put(LanguageCode.HAWAIIAN, "Other languages"); map.put(LanguageCode.HEBREW, "Hebrew"); map.put(LanguageCode.ITALIAN, "Italian"); map.put(LanguageCode.JAPANESE, "Japanese"); map.put(LanguageCode.KOREAN, "Korean"); map.put(LanguageCode.MOHAWK, "Other languages"); map.put(LanguageCode.MULTIPLE, "Other languages"); map.put(LanguageCode.SPANISH, "Spanish"); map.put(LanguageCode.wrap("something else"), "Other"); List<LanguageCode> languageCodes = new ArrayList<LanguageCode>(); languageCodes.addAll(map.keySet()); LanguageList originalList = new LanguageList(); for (LanguageCode languageCode : languageCodes) { originalList.add(new Language(languageCode)); } List<String> convertedList = converter.convert(originalList); Assert.assertEquals(originalList.size(), convertedList.size()); int i = 0; for (String converted : convertedList) { LanguageCode original = languageCodes.get(i++); Assert.assertEquals(converted, map.get(original)); } }
|
public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
LanguageListConverter { public List<String> convert(LanguageList languageList) { if (languageList == null) { return null; } return toSliLanguageList(languageList.getLanguages()); } List<String> convert(LanguageList languageList); }
|
@Test public void shouldCreateAckMessages() throws ADKException, IOException { String ackString = mockZis.createAckString(); SIFParser parser = SIFParser.newInstance(); SIFElement sifElem = parser.parse(ackString); Assert.assertTrue("Should create a SIF message", (sifElem instanceof SIF_Ack)); }
|
public String createAckString() { SIF_Message message = new SIF_Message(); SIF_Ack ack = message.ackStatus(0); return sifElementToString(ack); }
|
MockZis { public String createAckString() { SIF_Message message = new SIF_Message(); SIF_Ack ack = message.ackStatus(0); return sifElementToString(ack); } }
|
MockZis { public String createAckString() { SIF_Message message = new SIF_Message(); SIF_Ack ack = message.ackStatus(0); return sifElementToString(ack); } }
|
MockZis { public String createAckString() { SIF_Message message = new SIF_Message(); SIF_Ack ack = message.ackStatus(0); return sifElementToString(ack); } void parseSIFMessage(String sifString); void broadcastMessage(String xmlMessage); @PostConstruct void setup(); String createAckString(); void getAgentUrls(Set<String> agentCallbackUrls); Set<String> getAgentUrls(); }
|
MockZis { public String createAckString() { SIF_Message message = new SIF_Message(); SIF_Ack ack = message.ackStatus(0); return sifElementToString(ack); } void parseSIFMessage(String sifString); void broadcastMessage(String xmlMessage); @PostConstruct void setup(); String createAckString(); void getAgentUrls(Set<String> agentCallbackUrls); Set<String> getAgentUrls(); }
|
@Test public void testGenerateStudentPersonalDefaultEvent() throws ADKException { String messageFile = getPathForFile("/element_xml/StudentPersonal.xml"); Event studentPersonalEvent = CustomEventGenerator.generateEvent(messageFile, EventAction.ADD); EventAction eventAction = studentPersonalEvent.getAction(); Assert.assertEquals(EventAction.ADD, eventAction); checkStudentPersonal(studentPersonalEvent); }
|
public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } static Event generateEvent(String messageFile, EventAction eventAction); }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } static Event generateEvent(String messageFile, EventAction eventAction); }
|
@Test public void testGenerateLeaInfoDefaultEvent() throws ADKException { String messageFile = getPathForFile("/element_xml/LEAInfo.xml"); Event leaInfoEvent = CustomEventGenerator.generateEvent(messageFile, EventAction.ADD); EventAction eventAction = leaInfoEvent.getAction(); Assert.assertEquals(EventAction.ADD, eventAction); checkLeaInfo(leaInfoEvent); }
|
public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } static Event generateEvent(String messageFile, EventAction eventAction); }
|
CustomEventGenerator { public static Event generateEvent(String messageFile, EventAction eventAction) { FileReader in = null; Event event = null; try { SIFParser p = SIFParser.newInstance(); in = new FileReader(messageFile); StringBuffer xml = new StringBuffer(); int bufSize = 4096; char[] buf = new char[bufSize]; while (in.ready()) { bufSize = in.read(buf, 0, buf.length); xml.append(buf, 0, bufSize); } SIFDataObject generic = (SIFDataObject) p.parse(xml.toString(), null, 0, SIFVersion.SIF23); event = new Event(generic, eventAction); } catch (SIFException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKParsingException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (ADKException e) { LOG.error("Caught exception trying to load entity from file", e); } catch (IOException e) { LOG.error("Caught exception trying to load entity from file", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.warn("Unable to close file", e); } } } return event; } static Event generateEvent(String messageFile, EventAction eventAction); }
|
@Test public void testGenerateTestSchoolInfo() { SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); Assert.assertEquals(SifEntityGenerator.TEST_SCHOOLINFO_REFID, schoolInfo.getRefId()); Assert.assertEquals("Daybreak West High", schoolInfo.getStateProvinceId()); Assert.assertEquals("421575003045", schoolInfo.getNCESId()); Assert.assertEquals("Daybreak West High", schoolInfo.getSchoolName()); Assert.assertEquals(SifEntityGenerator.TEST_LEAINFO_REFID, schoolInfo.getLEAInfoRefId()); Assert.assertEquals("http: Assert.assertEquals(OperationalStatus.SCHOOL_CLOSED.getValue(), schoolInfo.getOperationalStatus()); Assert.assertEquals(SchoolLevelType._0031_2402_HIGH_SCHOOL.getValue(), schoolInfo.getSchoolType()); SchoolFocusList schoolFocusList = schoolInfo.getSchoolFocusList(); Assert.assertEquals(1, schoolFocusList.size()); SchoolFocus schoolFocus = schoolFocusList.get(0); Assert.assertEquals(SchoolFocusType.REGULAR.getValue(), schoolFocus.getValue()); GradeLevels gradeLevels = schoolInfo.getGradeLevels(); Assert.assertEquals(4, gradeLevels.size()); GradeLevel gradeLevel1 = gradeLevels.get(0); Assert.assertEquals(GradeLevelCode._09.getValue(), gradeLevel1.getCode()); GradeLevel gradeLevel2 = gradeLevels.get(1); Assert.assertEquals(GradeLevelCode._10.getValue(), gradeLevel2.getCode()); GradeLevel gradeLevel3 = gradeLevels.get(2); Assert.assertEquals(GradeLevelCode._11.getValue(), gradeLevel3.getCode()); GradeLevel gradeLevel4 = gradeLevels.get(3); Assert.assertEquals(GradeLevelCode._12.getValue(), gradeLevel4.getCode()); AddressList addressList = schoolInfo.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals("Salt Lake City", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("84102", address.getPostalCode()); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Street street = address.getStreet(); Assert.assertEquals("1 IBM Plaza", street.getLine1()); Assert.assertEquals("2000", street.getApartmentNumber()); Assert.assertEquals("Suite 2000", street.getLine2()); Assert.assertEquals("Salt Lake City, IL 84102", street.getLine3()); Assert.assertEquals("IBM way", street.getStreetName()); Assert.assertEquals("1", street.getStreetNumber()); Assert.assertEquals("Plaza", street.getStreetType()); Assert.assertEquals("Suite", street.getApartmentType()); PhoneNumberList phoneNumberList = schoolInfo.getPhoneNumberList(); Assert.assertEquals(2, phoneNumberList.size()); PhoneNumber phoneNumber1 = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber1.getType()); Assert.assertEquals("(312) 555-1234", phoneNumber1.getNumber()); PhoneNumber phoneNumber2 = phoneNumberList.get(1); Assert.assertEquals(PhoneNumberType.FAX.getValue(), phoneNumber2.getType()); Assert.assertEquals("(312) 555-2364", phoneNumber2.getNumber()); }
|
public static SchoolInfo generateTestSchoolInfo() { SchoolInfo info = new SchoolInfo(); info.setRefId(TEST_SCHOOLINFO_REFID); info.setStateProvinceId("Daybreak West High"); info.setNCESId("421575003045"); info.setSchoolName("Daybreak West High"); info.setLEAInfoRefId(TEST_LEAINFO_REFID); SchoolFocusList schoolFocusList = new SchoolFocusList(); schoolFocusList.add(new SchoolFocus(SchoolFocusType.REGULAR)); info.setSchoolFocusList(schoolFocusList); info.setSchoolURL("http: info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); info.setSchoolType(SchoolLevelType._0031_2402_HIGH_SCHOOL); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; }
|
SifEntityGenerator { public static SchoolInfo generateTestSchoolInfo() { SchoolInfo info = new SchoolInfo(); info.setRefId(TEST_SCHOOLINFO_REFID); info.setStateProvinceId("Daybreak West High"); info.setNCESId("421575003045"); info.setSchoolName("Daybreak West High"); info.setLEAInfoRefId(TEST_LEAINFO_REFID); SchoolFocusList schoolFocusList = new SchoolFocusList(); schoolFocusList.add(new SchoolFocus(SchoolFocusType.REGULAR)); info.setSchoolFocusList(schoolFocusList); info.setSchoolURL("http: info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); info.setSchoolType(SchoolLevelType._0031_2402_HIGH_SCHOOL); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static SchoolInfo generateTestSchoolInfo() { SchoolInfo info = new SchoolInfo(); info.setRefId(TEST_SCHOOLINFO_REFID); info.setStateProvinceId("Daybreak West High"); info.setNCESId("421575003045"); info.setSchoolName("Daybreak West High"); info.setLEAInfoRefId(TEST_LEAINFO_REFID); SchoolFocusList schoolFocusList = new SchoolFocusList(); schoolFocusList.add(new SchoolFocus(SchoolFocusType.REGULAR)); info.setSchoolFocusList(schoolFocusList); info.setSchoolURL("http: info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); info.setSchoolType(SchoolLevelType._0031_2402_HIGH_SCHOOL); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static SchoolInfo generateTestSchoolInfo() { SchoolInfo info = new SchoolInfo(); info.setRefId(TEST_SCHOOLINFO_REFID); info.setStateProvinceId("Daybreak West High"); info.setNCESId("421575003045"); info.setSchoolName("Daybreak West High"); info.setLEAInfoRefId(TEST_LEAINFO_REFID); SchoolFocusList schoolFocusList = new SchoolFocusList(); schoolFocusList.add(new SchoolFocus(SchoolFocusType.REGULAR)); info.setSchoolFocusList(schoolFocusList); info.setSchoolURL("http: info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); info.setSchoolType(SchoolLevelType._0031_2402_HIGH_SCHOOL); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static SchoolInfo generateTestSchoolInfo() { SchoolInfo info = new SchoolInfo(); info.setRefId(TEST_SCHOOLINFO_REFID); info.setStateProvinceId("Daybreak West High"); info.setNCESId("421575003045"); info.setSchoolName("Daybreak West High"); info.setLEAInfoRefId(TEST_LEAINFO_REFID); SchoolFocusList schoolFocusList = new SchoolFocusList(); schoolFocusList.add(new SchoolFocus(SchoolFocusType.REGULAR)); info.setSchoolFocusList(schoolFocusList); info.setSchoolURL("http: info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); info.setSchoolType(SchoolLevelType._0031_2402_HIGH_SCHOOL); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestLeaInfo() { LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); Assert.assertEquals(SifEntityGenerator.TEST_LEAINFO_REFID, leaInfo.getRefId()); Assert.assertEquals("IL-DAYBREAK", leaInfo.getStateProvinceId()); Assert.assertEquals("4215750", leaInfo.getNCESId()); Assert.assertEquals("Daybreak School District 4530", leaInfo.getLEAName()); Assert.assertEquals("http: Assert.assertEquals(OperationalStatus.SCHOOL_CLOSED.getValue(), leaInfo.getOperationalStatus()); Assert.assertEquals(EducationAgencyTypeCode.REG_DISTRICT.getValue(), leaInfo.getEducationAgencyType().getCode()); GradeLevels gradeLevels = leaInfo.getGradeLevels(); Assert.assertEquals(4, gradeLevels.size()); GradeLevel gradeLevel1 = gradeLevels.get(0); Assert.assertEquals(GradeLevelCode._09.getValue(), gradeLevel1.getCode()); GradeLevel gradeLevel2 = gradeLevels.get(1); Assert.assertEquals(GradeLevelCode._10.getValue(), gradeLevel2.getCode()); GradeLevel gradeLevel3 = gradeLevels.get(2); Assert.assertEquals(GradeLevelCode._11.getValue(), gradeLevel3.getCode()); GradeLevel gradeLevel4 = gradeLevels.get(3); Assert.assertEquals(GradeLevelCode._12.getValue(), gradeLevel4.getCode()); AddressList addressList = leaInfo.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals("Salt Lake City", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("84102", address.getPostalCode()); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Street street = address.getStreet(); Assert.assertEquals("1 IBM Plaza", street.getLine1()); Assert.assertEquals("2000", street.getApartmentNumber()); Assert.assertEquals("Suite 2000", street.getLine2()); Assert.assertEquals("Salt Lake City, IL 84102", street.getLine3()); Assert.assertEquals("IBM way", street.getStreetName()); Assert.assertEquals("1", street.getStreetNumber()); Assert.assertEquals("Plaza", street.getStreetType()); Assert.assertEquals("Suite", street.getApartmentType()); PhoneNumberList phoneNumberList = leaInfo.getPhoneNumberList(); Assert.assertEquals(2, phoneNumberList.size()); PhoneNumber phoneNumber1 = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber1.getType()); Assert.assertEquals("(312) 555-1234", phoneNumber1.getNumber()); PhoneNumber phoneNumber2 = phoneNumberList.get(1); Assert.assertEquals(PhoneNumberType.FAX.getValue(), phoneNumber2.getType()); Assert.assertEquals("(312) 555-2364", phoneNumber2.getNumber()); }
|
public static LEAInfo generateTestLEAInfo() { LEAInfo info = new LEAInfo(); info.setRefId(TEST_LEAINFO_REFID); info.setStateProvinceId("IL-DAYBREAK"); info.setNCESId("4215750"); info.setLEAName("Daybreak School District 4530"); info.setLEAURL("http: info.setEducationAgencyType(EducationAgencyTypeCode.REG_DISTRICT); info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; }
|
SifEntityGenerator { public static LEAInfo generateTestLEAInfo() { LEAInfo info = new LEAInfo(); info.setRefId(TEST_LEAINFO_REFID); info.setStateProvinceId("IL-DAYBREAK"); info.setNCESId("4215750"); info.setLEAName("Daybreak School District 4530"); info.setLEAURL("http: info.setEducationAgencyType(EducationAgencyTypeCode.REG_DISTRICT); info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static LEAInfo generateTestLEAInfo() { LEAInfo info = new LEAInfo(); info.setRefId(TEST_LEAINFO_REFID); info.setStateProvinceId("IL-DAYBREAK"); info.setNCESId("4215750"); info.setLEAName("Daybreak School District 4530"); info.setLEAURL("http: info.setEducationAgencyType(EducationAgencyTypeCode.REG_DISTRICT); info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static LEAInfo generateTestLEAInfo() { LEAInfo info = new LEAInfo(); info.setRefId(TEST_LEAINFO_REFID); info.setStateProvinceId("IL-DAYBREAK"); info.setNCESId("4215750"); info.setLEAName("Daybreak School District 4530"); info.setLEAURL("http: info.setEducationAgencyType(EducationAgencyTypeCode.REG_DISTRICT); info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static LEAInfo generateTestLEAInfo() { LEAInfo info = new LEAInfo(); info.setRefId(TEST_LEAINFO_REFID); info.setStateProvinceId("IL-DAYBREAK"); info.setNCESId("4215750"); info.setLEAName("Daybreak School District 4530"); info.setLEAURL("http: info.setEducationAgencyType(EducationAgencyTypeCode.REG_DISTRICT); info.setOperationalStatus(OperationalStatus.SCHOOL_CLOSED); GradeLevels gradeLevels = new GradeLevels(); gradeLevels.addGradeLevel(GradeLevelCode._09); gradeLevels.addGradeLevel(GradeLevelCode._10); gradeLevels.addGradeLevel(GradeLevelCode._11); gradeLevels.addGradeLevel(GradeLevelCode._12); info.setGradeLevels(gradeLevels); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestSeaInfo() { SEAInfo seaInfo = SifEntityGenerator.generateTestSEAInfo(); Assert.assertEquals(SifEntityGenerator.TEST_SEAINFO_REFID, seaInfo.getRefId()); Assert.assertEquals("Illinois State Board of Education", seaInfo.getSEAName()); Assert.assertEquals("http: AddressList addressList = seaInfo.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals("Salt Lake City", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("84102", address.getPostalCode()); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Street street = address.getStreet(); Assert.assertEquals("1 IBM Plaza", street.getLine1()); Assert.assertEquals("2000", street.getApartmentNumber()); Assert.assertEquals("Suite 2000", street.getLine2()); Assert.assertEquals("Salt Lake City, IL 84102", street.getLine3()); Assert.assertEquals("IBM way", street.getStreetName()); Assert.assertEquals("1", street.getStreetNumber()); Assert.assertEquals("Plaza", street.getStreetType()); Assert.assertEquals("Suite", street.getApartmentType()); PhoneNumberList phoneNumberList = seaInfo.getPhoneNumberList(); Assert.assertEquals(2, phoneNumberList.size()); PhoneNumber phoneNumber1 = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber1.getType()); Assert.assertEquals("(312) 555-1234", phoneNumber1.getNumber()); PhoneNumber phoneNumber2 = phoneNumberList.get(1); Assert.assertEquals(PhoneNumberType.FAX.getValue(), phoneNumber2.getType()); Assert.assertEquals("(312) 555-2364", phoneNumber2.getNumber()); }
|
public static SEAInfo generateTestSEAInfo() { SEAInfo info = new SEAInfo(); info.setRefId(TEST_SEAINFO_REFID); info.setSEAName("Illinois State Board of Education"); info.setSEAURL("http: Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; }
|
SifEntityGenerator { public static SEAInfo generateTestSEAInfo() { SEAInfo info = new SEAInfo(); info.setRefId(TEST_SEAINFO_REFID); info.setSEAName("Illinois State Board of Education"); info.setSEAURL("http: Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static SEAInfo generateTestSEAInfo() { SEAInfo info = new SEAInfo(); info.setRefId(TEST_SEAINFO_REFID); info.setSEAName("Illinois State Board of Education"); info.setSEAURL("http: Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } }
|
SifEntityGenerator { public static SEAInfo generateTestSEAInfo() { SEAInfo info = new SEAInfo(); info.setRefId(TEST_SEAINFO_REFID); info.setSEAName("Illinois State Board of Education"); info.setSEAURL("http: Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static SEAInfo generateTestSEAInfo() { SEAInfo info = new SEAInfo(); info.setRefId(TEST_SEAINFO_REFID); info.setSEAName("Illinois State Board of Education"); info.setSEAURL("http: Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); AddressList addressList = new AddressList(); addressList.add(address); info.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); phoneNumberList.addPhoneNumber(PhoneNumberType.FAX, "(312) 555-2364"); info.setPhoneNumberList(phoneNumberList); return info; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestStudentSchoolEnrollment() { StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); Assert.assertEquals(SifEntityGenerator.TEST_STUDENTSCHOOLENROLLMENT_REFID, studentSchoolEnrollment.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_SCHOOLINFO_REFID, studentSchoolEnrollment.getSchoolInfoRefId()); Assert.assertEquals(SifEntityGenerator.TEST_STUDENTPERSONAL_REFID, studentSchoolEnrollment.getStudentPersonalRefId()); Assert.assertEquals(MembershipType.HOME.getValue(), studentSchoolEnrollment.getMembershipType()); Assert.assertEquals(TimeFrame.CURRENT.getValue(), studentSchoolEnrollment.getTimeFrame()); Assert.assertEquals(2012, studentSchoolEnrollment.getSchoolYear().intValue()); Assert.assertEquals(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO.getValue(), studentSchoolEnrollment.getExitType().getCode()); Assert.assertEquals(EntryTypeCode._0619_1838.getValue(), studentSchoolEnrollment.getEntryType().getCode()); Assert.assertEquals(GradeLevelCode._10.getValue(), studentSchoolEnrollment.getGradeLevel().getCode()); Assert.assertEquals(new BigDecimal(1.00), studentSchoolEnrollment.getFTE()); Assert.assertEquals(FTPTStatus.FULLTIME.getValue(), studentSchoolEnrollment.getFTPTStatus()); Assert.assertEquals(PublicSchoolResidenceStatus._0598_1653.getValue(), studentSchoolEnrollment.getResidencyStatus().getCode()); Assert.assertEquals(NonResidentAttendRationale.VOCATIONAL.getValue(), studentSchoolEnrollment.getNonResidentAttendReason()); Calendar exitDate = studentSchoolEnrollment.getExitDate(); Assert.assertEquals(2012, exitDate.get(Calendar.YEAR)); Assert.assertEquals(9, exitDate.get(Calendar.MONTH)); Assert.assertEquals(17, exitDate.get(Calendar.DATE)); Calendar entryDate = studentSchoolEnrollment.getEntryDate(); Assert.assertEquals(2012, entryDate.get(Calendar.YEAR)); Assert.assertEquals(8, entryDate.get(Calendar.MONTH)); Assert.assertEquals(16, entryDate.get(Calendar.DATE)); }
|
public static StudentSchoolEnrollment generateTestStudentSchoolEnrollment() { StudentSchoolEnrollment retVal = new StudentSchoolEnrollment(); retVal.setRefId(TEST_STUDENTSCHOOLENROLLMENT_REFID); retVal.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setMembershipType(MembershipType.HOME); retVal.setTimeFrame(TimeFrame.CURRENT); retVal.setSchoolYear(2012); retVal.setExitType(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO); retVal.setExitDate(new GregorianCalendar(2012, 9, 17)); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); retVal.setFTE(new BigDecimal(1.00)); retVal.setFTPTStatus(FTPTStatus.FULLTIME); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus._0598_1653); retVal.setResidencyStatus(rs); retVal.setNonResidentAttendReason(NonResidentAttendRationale.VOCATIONAL); return retVal; }
|
SifEntityGenerator { public static StudentSchoolEnrollment generateTestStudentSchoolEnrollment() { StudentSchoolEnrollment retVal = new StudentSchoolEnrollment(); retVal.setRefId(TEST_STUDENTSCHOOLENROLLMENT_REFID); retVal.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setMembershipType(MembershipType.HOME); retVal.setTimeFrame(TimeFrame.CURRENT); retVal.setSchoolYear(2012); retVal.setExitType(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO); retVal.setExitDate(new GregorianCalendar(2012, 9, 17)); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); retVal.setFTE(new BigDecimal(1.00)); retVal.setFTPTStatus(FTPTStatus.FULLTIME); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus._0598_1653); retVal.setResidencyStatus(rs); retVal.setNonResidentAttendReason(NonResidentAttendRationale.VOCATIONAL); return retVal; } }
|
SifEntityGenerator { public static StudentSchoolEnrollment generateTestStudentSchoolEnrollment() { StudentSchoolEnrollment retVal = new StudentSchoolEnrollment(); retVal.setRefId(TEST_STUDENTSCHOOLENROLLMENT_REFID); retVal.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setMembershipType(MembershipType.HOME); retVal.setTimeFrame(TimeFrame.CURRENT); retVal.setSchoolYear(2012); retVal.setExitType(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO); retVal.setExitDate(new GregorianCalendar(2012, 9, 17)); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); retVal.setFTE(new BigDecimal(1.00)); retVal.setFTPTStatus(FTPTStatus.FULLTIME); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus._0598_1653); retVal.setResidencyStatus(rs); retVal.setNonResidentAttendReason(NonResidentAttendRationale.VOCATIONAL); return retVal; } }
|
SifEntityGenerator { public static StudentSchoolEnrollment generateTestStudentSchoolEnrollment() { StudentSchoolEnrollment retVal = new StudentSchoolEnrollment(); retVal.setRefId(TEST_STUDENTSCHOOLENROLLMENT_REFID); retVal.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setMembershipType(MembershipType.HOME); retVal.setTimeFrame(TimeFrame.CURRENT); retVal.setSchoolYear(2012); retVal.setExitType(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO); retVal.setExitDate(new GregorianCalendar(2012, 9, 17)); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); retVal.setFTE(new BigDecimal(1.00)); retVal.setFTPTStatus(FTPTStatus.FULLTIME); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus._0598_1653); retVal.setResidencyStatus(rs); retVal.setNonResidentAttendReason(NonResidentAttendRationale.VOCATIONAL); return retVal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static StudentSchoolEnrollment generateTestStudentSchoolEnrollment() { StudentSchoolEnrollment retVal = new StudentSchoolEnrollment(); retVal.setRefId(TEST_STUDENTSCHOOLENROLLMENT_REFID); retVal.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setMembershipType(MembershipType.HOME); retVal.setTimeFrame(TimeFrame.CURRENT); retVal.setSchoolYear(2012); retVal.setExitType(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO); retVal.setExitDate(new GregorianCalendar(2012, 9, 17)); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); retVal.setFTE(new BigDecimal(1.00)); retVal.setFTPTStatus(FTPTStatus.FULLTIME); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus._0598_1653); retVal.setResidencyStatus(rs); retVal.setNonResidentAttendReason(NonResidentAttendRationale.VOCATIONAL); return retVal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testshouldExtractTeacherSchoolAssociation() { Entity mSeoa = Mockito.mock(Entity.class); Map<String, Object> body = new HashMap<String, Object>(); body.put(ParameterConstants.BEGIN_DATE, "2009-09-02"); body.put(ParameterConstants.END_DATE, "2010-05-31"); Mockito.when(mSeoa.getBody()).thenReturn(body); Mockito.when(mSeoa.getType()).thenReturn(EntityNames.STAFF_ED_ORG_ASSOCIATION); Mockito.when(edOrgExtractHelper.retrieveSEOAS(Matchers.eq("Staff1"), Matchers.eq("LEA"))).thenReturn(Arrays.asList(mSeoa)); Map<String, Object> tsaBody = new HashMap<String, Object>(); tsaBody.put(ParameterConstants.TEACHER_ID, "Staff1"); tsaBody.put(ParameterConstants.SCHOOL_ID, "LEA"); Entity tsa = Mockito.mock(Entity.class); Mockito.when(tsa.getBody()).thenReturn(tsaBody); Mockito.when(tsa.getType()).thenReturn(EntityNames.TEACHER_SCHOOL_ASSOCIATION); Assert.assertTrue(tsaev.shouldExtract(tsa, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(tsaev.shouldExtract(tsa, DateTime.parse("2009-09-02", DateHelper.getDateTimeFormat()))); Assert.assertTrue(tsaev.shouldExtract(tsa, null)); Assert.assertFalse(tsaev.shouldExtract(tsa, DateTime.parse("2009-09-01", DateHelper.getDateTimeFormat()))); Assert.assertFalse(tsaev.shouldExtract(tsa, DateTime.parse("2008-05-24", DateHelper.getDateTimeFormat()))); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
TeacherSchoolAssociationExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { Iterable<Entity> seaos = edOrgExtractHelper.retrieveSEOAS((String) entity.getBody().get(ParameterConstants.TEACHER_ID), (String) entity.getBody().get(ParameterConstants.SCHOOL_ID)); return shouldExtract(seaos, upToDate); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void testGenerateTestStudentLeaRelationship() { StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); Assert.assertEquals(SifEntityGenerator.TEST_STUDENTLEARELATIONSHIP_REFID, studentLeaRelationship.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_LEAINFO_REFID, studentLeaRelationship.getLEAInfoRefId()); Assert.assertEquals(SifEntityGenerator.TEST_STUDENTPERSONAL_REFID, studentLeaRelationship.getStudentPersonalRefId()); Assert.assertEquals(2012, studentLeaRelationship.getSchoolYear().intValue()); Assert.assertEquals(MembershipType.HOME.getValue(), studentLeaRelationship.getMembershipType()); Assert.assertEquals(EntryTypeCode._0619_1838.getValue(), studentLeaRelationship.getEntryType().getCode()); Assert.assertEquals(GradeLevelCode._10.getValue(), studentLeaRelationship.getGradeLevel().getCode()); OrganizationRelationshipType organizationRelationshipType = studentLeaRelationship.getLEARelationshipType(); Assert.assertEquals(PublicSchoolResidenceStatus.RESIDENT.getValue(), organizationRelationshipType.getResidencyStatus().getCode()); Assert.assertTrue(organizationRelationshipType.getProvidingInstruction().booleanValue()); Assert.assertTrue(organizationRelationshipType.getProvidingServices().booleanValue()); Assert.assertTrue(organizationRelationshipType.getFinanciallyResponsible().booleanValue()); Calendar entryDate = studentLeaRelationship.getEntryDate(); Assert.assertEquals(2012, entryDate.get(Calendar.YEAR)); Assert.assertEquals(8, entryDate.get(Calendar.MONTH)); Assert.assertEquals(16, entryDate.get(Calendar.DATE)); }
|
public static StudentLEARelationship generateTestStudentLeaRelationship() { StudentLEARelationship retVal = new StudentLEARelationship(); retVal.setRefId(TEST_STUDENTLEARELATIONSHIP_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setLEAInfoRefId(TEST_LEAINFO_REFID); retVal.setSchoolYear(2012); retVal.setMembershipType(MembershipType.HOME); OrganizationRelationshipType ort = new OrganizationRelationshipType(); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus.RESIDENT); ort.setResidencyStatus(rs); ort.setProvidingInstruction(true); ort.setProvidingServices(true); ort.setFinanciallyResponsible(true); retVal.setLEARelationshipType(ort); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); return retVal; }
|
SifEntityGenerator { public static StudentLEARelationship generateTestStudentLeaRelationship() { StudentLEARelationship retVal = new StudentLEARelationship(); retVal.setRefId(TEST_STUDENTLEARELATIONSHIP_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setLEAInfoRefId(TEST_LEAINFO_REFID); retVal.setSchoolYear(2012); retVal.setMembershipType(MembershipType.HOME); OrganizationRelationshipType ort = new OrganizationRelationshipType(); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus.RESIDENT); ort.setResidencyStatus(rs); ort.setProvidingInstruction(true); ort.setProvidingServices(true); ort.setFinanciallyResponsible(true); retVal.setLEARelationshipType(ort); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); return retVal; } }
|
SifEntityGenerator { public static StudentLEARelationship generateTestStudentLeaRelationship() { StudentLEARelationship retVal = new StudentLEARelationship(); retVal.setRefId(TEST_STUDENTLEARELATIONSHIP_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setLEAInfoRefId(TEST_LEAINFO_REFID); retVal.setSchoolYear(2012); retVal.setMembershipType(MembershipType.HOME); OrganizationRelationshipType ort = new OrganizationRelationshipType(); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus.RESIDENT); ort.setResidencyStatus(rs); ort.setProvidingInstruction(true); ort.setProvidingServices(true); ort.setFinanciallyResponsible(true); retVal.setLEARelationshipType(ort); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); return retVal; } }
|
SifEntityGenerator { public static StudentLEARelationship generateTestStudentLeaRelationship() { StudentLEARelationship retVal = new StudentLEARelationship(); retVal.setRefId(TEST_STUDENTLEARELATIONSHIP_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setLEAInfoRefId(TEST_LEAINFO_REFID); retVal.setSchoolYear(2012); retVal.setMembershipType(MembershipType.HOME); OrganizationRelationshipType ort = new OrganizationRelationshipType(); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus.RESIDENT); ort.setResidencyStatus(rs); ort.setProvidingInstruction(true); ort.setProvidingServices(true); ort.setFinanciallyResponsible(true); retVal.setLEARelationshipType(ort); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); return retVal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static StudentLEARelationship generateTestStudentLeaRelationship() { StudentLEARelationship retVal = new StudentLEARelationship(); retVal.setRefId(TEST_STUDENTLEARELATIONSHIP_REFID); retVal.setStudentPersonalRefId(TEST_STUDENTPERSONAL_REFID); retVal.setLEAInfoRefId(TEST_LEAINFO_REFID); retVal.setSchoolYear(2012); retVal.setMembershipType(MembershipType.HOME); OrganizationRelationshipType ort = new OrganizationRelationshipType(); ResidencyStatus rs = new ResidencyStatus(); rs.setCode(PublicSchoolResidenceStatus.RESIDENT); ort.setResidencyStatus(rs); ort.setProvidingInstruction(true); ort.setProvidingServices(true); ort.setFinanciallyResponsible(true); retVal.setLEARelationshipType(ort); retVal.setEntryDate(new GregorianCalendar(2012, 8, 16)); retVal.setEntryType(EntryTypeCode._0619_1838); retVal.setGradeLevel(GradeLevelCode._10); return retVal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestStudentPersonal() { StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); Assert.assertEquals(SifEntityGenerator.TEST_STUDENTPERSONAL_REFID, studentPersonal.getRefId()); Assert.assertEquals("1982", studentPersonal.getGraduationDate().getValue()); Assert.assertEquals(YesNoUnknown.NO.getValue(), studentPersonal.getMigrant()); Name name = studentPersonal.getName(); Assert.assertEquals(NameType.NAME_OF_RECORD.getValue(), name.getType()); Assert.assertEquals("Smith", name.getLastName()); Assert.assertEquals("Joe", name.getFirstName()); Assert.assertEquals("", name.getMiddleName()); Assert.assertEquals("Joe", name.getPreferredName()); EmailList emailList = studentPersonal.getEmailList(); Assert.assertEquals(1, emailList.size()); Email email = emailList.get(0); Assert.assertEquals(EmailType.PRIMARY.getValue(), email.getType()); Assert.assertEquals("[email protected]", email.getValue()); Demographics demographics = studentPersonal.getDemographics(); Assert.assertEquals(CitizenshipStatus.USCITIZEN.getValue(), demographics.getCitizenshipStatus()); Assert.assertEquals(CountryCode.US.getValue(), demographics.getCountryOfBirth()); Assert.assertEquals(StatePrCode.AK.getValue(), demographics.getStateOfBirth()); Calendar birthDate = demographics.getBirthDate(); Assert.assertEquals(1981, birthDate.get(Calendar.YEAR)); Assert.assertEquals(11, birthDate.get(Calendar.MONTH)); Assert.assertEquals(20, birthDate.get(Calendar.DATE)); StudentAddressList addressList = studentPersonal.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals("Salt Lake City", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("84102", address.getPostalCode()); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Street street = address.getStreet(); Assert.assertEquals("1 IBM Plaza", street.getLine1()); Assert.assertEquals("2000", street.getApartmentNumber()); Assert.assertEquals("Suite 2000", street.getLine2()); Assert.assertEquals("Salt Lake City, IL 84102", street.getLine3()); Assert.assertEquals("IBM way", street.getStreetName()); Assert.assertEquals("1", street.getStreetNumber()); Assert.assertEquals("Plaza", street.getStreetType()); Assert.assertEquals("Suite", street.getApartmentType()); PhoneNumberList phoneNumberList = studentPersonal.getPhoneNumberList(); Assert.assertEquals(1, phoneNumberList.size()); PhoneNumber phoneNumber = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber.getType()); Assert.assertEquals("(312) 555-1234", phoneNumber.getNumber()); }
|
public static StudentPersonal generateTestStudentPersonal() { StudentPersonal studentPersonal = new StudentPersonal(); studentPersonal.setRefId(TEST_STUDENTPERSONAL_REFID); studentPersonal.setStateProvinceId("IL-DAYBREAK-54321"); Name name = new Name(NameType.NAME_OF_RECORD, "Smith", "Joe"); name.setMiddleName(""); name.setPreferredName("Joe"); studentPersonal.setName(name); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); studentPersonal.setEmailList(emailList); studentPersonal.setGraduationDate("1982"); Demographics demographics = new Demographics(); Calendar calendar = Calendar.getInstance(); calendar.set(1981, 11, 20); demographics.setBirthDate(calendar); demographics.setCitizenshipStatus(CitizenshipStatus.USCITIZEN); demographics.setCountryOfBirth(CountryCode.US); demographics.setStateOfBirth(StatePrCode.AK); demographics.setGender(Gender.MALE); studentPersonal.setDemographics(demographics); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); StudentAddressList addressList = new StudentAddressList(); addressList.add(address); studentPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); studentPersonal.setPhoneNumberList(phoneNumberList); studentPersonal.setMigrant(YesNoUnknown.NO); return studentPersonal; }
|
SifEntityGenerator { public static StudentPersonal generateTestStudentPersonal() { StudentPersonal studentPersonal = new StudentPersonal(); studentPersonal.setRefId(TEST_STUDENTPERSONAL_REFID); studentPersonal.setStateProvinceId("IL-DAYBREAK-54321"); Name name = new Name(NameType.NAME_OF_RECORD, "Smith", "Joe"); name.setMiddleName(""); name.setPreferredName("Joe"); studentPersonal.setName(name); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); studentPersonal.setEmailList(emailList); studentPersonal.setGraduationDate("1982"); Demographics demographics = new Demographics(); Calendar calendar = Calendar.getInstance(); calendar.set(1981, 11, 20); demographics.setBirthDate(calendar); demographics.setCitizenshipStatus(CitizenshipStatus.USCITIZEN); demographics.setCountryOfBirth(CountryCode.US); demographics.setStateOfBirth(StatePrCode.AK); demographics.setGender(Gender.MALE); studentPersonal.setDemographics(demographics); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); StudentAddressList addressList = new StudentAddressList(); addressList.add(address); studentPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); studentPersonal.setPhoneNumberList(phoneNumberList); studentPersonal.setMigrant(YesNoUnknown.NO); return studentPersonal; } }
|
SifEntityGenerator { public static StudentPersonal generateTestStudentPersonal() { StudentPersonal studentPersonal = new StudentPersonal(); studentPersonal.setRefId(TEST_STUDENTPERSONAL_REFID); studentPersonal.setStateProvinceId("IL-DAYBREAK-54321"); Name name = new Name(NameType.NAME_OF_RECORD, "Smith", "Joe"); name.setMiddleName(""); name.setPreferredName("Joe"); studentPersonal.setName(name); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); studentPersonal.setEmailList(emailList); studentPersonal.setGraduationDate("1982"); Demographics demographics = new Demographics(); Calendar calendar = Calendar.getInstance(); calendar.set(1981, 11, 20); demographics.setBirthDate(calendar); demographics.setCitizenshipStatus(CitizenshipStatus.USCITIZEN); demographics.setCountryOfBirth(CountryCode.US); demographics.setStateOfBirth(StatePrCode.AK); demographics.setGender(Gender.MALE); studentPersonal.setDemographics(demographics); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); StudentAddressList addressList = new StudentAddressList(); addressList.add(address); studentPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); studentPersonal.setPhoneNumberList(phoneNumberList); studentPersonal.setMigrant(YesNoUnknown.NO); return studentPersonal; } }
|
SifEntityGenerator { public static StudentPersonal generateTestStudentPersonal() { StudentPersonal studentPersonal = new StudentPersonal(); studentPersonal.setRefId(TEST_STUDENTPERSONAL_REFID); studentPersonal.setStateProvinceId("IL-DAYBREAK-54321"); Name name = new Name(NameType.NAME_OF_RECORD, "Smith", "Joe"); name.setMiddleName(""); name.setPreferredName("Joe"); studentPersonal.setName(name); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); studentPersonal.setEmailList(emailList); studentPersonal.setGraduationDate("1982"); Demographics demographics = new Demographics(); Calendar calendar = Calendar.getInstance(); calendar.set(1981, 11, 20); demographics.setBirthDate(calendar); demographics.setCitizenshipStatus(CitizenshipStatus.USCITIZEN); demographics.setCountryOfBirth(CountryCode.US); demographics.setStateOfBirth(StatePrCode.AK); demographics.setGender(Gender.MALE); studentPersonal.setDemographics(demographics); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); StudentAddressList addressList = new StudentAddressList(); addressList.add(address); studentPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); studentPersonal.setPhoneNumberList(phoneNumberList); studentPersonal.setMigrant(YesNoUnknown.NO); return studentPersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static StudentPersonal generateTestStudentPersonal() { StudentPersonal studentPersonal = new StudentPersonal(); studentPersonal.setRefId(TEST_STUDENTPERSONAL_REFID); studentPersonal.setStateProvinceId("IL-DAYBREAK-54321"); Name name = new Name(NameType.NAME_OF_RECORD, "Smith", "Joe"); name.setMiddleName(""); name.setPreferredName("Joe"); studentPersonal.setName(name); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); studentPersonal.setEmailList(emailList); studentPersonal.setGraduationDate("1982"); Demographics demographics = new Demographics(); Calendar calendar = Calendar.getInstance(); calendar.set(1981, 11, 20); demographics.setBirthDate(calendar); demographics.setCitizenshipStatus(CitizenshipStatus.USCITIZEN); demographics.setCountryOfBirth(CountryCode.US); demographics.setStateOfBirth(StatePrCode.AK); demographics.setGender(Gender.MALE); studentPersonal.setDemographics(demographics); Address address = new Address(); address.setCity("Salt Lake City"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("84102"); Street street = new Street(); street.setLine1("1 IBM Plaza"); street.setApartmentNumber("2000"); street.setLine2("Suite 2000"); street.setLine3("Salt Lake City, IL 84102"); street.setStreetName("IBM way"); street.setStreetNumber("1"); street.setStreetType("Plaza"); street.setApartmentType("Suite"); address.setStreet(street); address.setType(AddressType.MAILING); StudentAddressList addressList = new StudentAddressList(); addressList.add(address); studentPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); studentPersonal.setPhoneNumberList(phoneNumberList); studentPersonal.setMigrant(YesNoUnknown.NO); return studentPersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestStaffPersonal() { StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); Assert.assertEquals(SifEntityGenerator.TEST_STAFFPERSONAL_REFID, staffPersonal.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYEEPERSONAL_REFID, staffPersonal.getEmployeePersonalRefId()); Assert.assertEquals("946379881", staffPersonal.getLocalId()); Assert.assertEquals("C2345681", staffPersonal.getStateProvinceId()); Assert.assertEquals("Principal", staffPersonal.getTitle()); ElectronicIdList electronicIdList = staffPersonal.getElectronicIdList(); Assert.assertEquals(1, electronicIdList.size()); ElectronicId electronicId = electronicIdList.get(0); Assert.assertEquals(ElectronicIdType.BARCODE.getValue(), electronicId.getType()); Assert.assertEquals("206655", electronicId.getValue()); OtherIdList otherIdList = staffPersonal.getOtherIdList(); Assert.assertEquals(1, otherIdList.size()); OtherId otherId = otherIdList.get(0); Assert.assertEquals(OtherIdType.SOCIALSECURITY.getValue(), otherId.getType()); Assert.assertEquals("333333333", otherId.getValue()); Name name = staffPersonal.getName(); Assert.assertEquals(NameType.NAME_OF_RECORD.getValue(), name.getType()); Assert.assertEquals("Mr.", name.getPrefix()); Assert.assertEquals("Woodall", name.getLastName()); Assert.assertEquals("Charles", name.getFirstName()); Assert.assertEquals("William", name.getMiddleName()); Assert.assertEquals("Chuck", name.getPreferredName()); Demographics demographics = staffPersonal.getDemographics(); Assert.assertEquals(Gender.M.getValue(), demographics.getGender()); AddressList addressList = staffPersonal.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Assert.assertEquals("Chicago", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("60660", address.getPostalCode()); Street street = address.getStreet(); Assert.assertEquals("6799 33rd Ave.", street.getLine1()); Assert.assertEquals("6799", street.getStreetNumber()); Assert.assertEquals("33rd", street.getStreetName()); Assert.assertEquals("Ave.", street.getStreetType()); PhoneNumberList phoneNumberList = staffPersonal.getPhoneNumberList(); Assert.assertEquals(1, phoneNumberList.size()); PhoneNumber phoneNumber = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber.getType()); Assert.assertEquals("(312) 555-1234", phoneNumber.getNumber()); EmailList emailList = staffPersonal.getEmailList(); Assert.assertEquals(1, emailList.size()); Email email = emailList.get(0); Assert.assertEquals(EmailType.PRIMARY.getValue(), email.getType()); Assert.assertEquals("[email protected]", email.getValue()); }
|
public static StaffPersonal generateTestStaffPersonal() { StaffPersonal staffPersonal = new StaffPersonal(); staffPersonal.setRefId(TEST_STAFFPERSONAL_REFID); staffPersonal.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffPersonal.setLocalId("946379881"); staffPersonal.setStateProvinceId("C2345681"); staffPersonal.setTitle("Principal"); ElectronicId electronicId = new ElectronicId(ElectronicIdType.BARCODE, "206655"); ElectronicIdList electronicIdList = new ElectronicIdList(electronicId); staffPersonal.setElectronicIdList(electronicIdList); OtherId otherId = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherIdList otherIdList = new OtherIdList(otherId); staffPersonal.setOtherIdList(otherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setPrefix("Mr."); name.setLastName("Woodall"); name.setFirstName("Charles"); name.setMiddleName("William"); name.setPreferredName("Chuck"); staffPersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); staffPersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); street.setStreetNumber("6799"); street.setStreetName("33rd"); street.setStreetType("Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); staffPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); staffPersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); staffPersonal.setEmailList(emailList); return staffPersonal; }
|
SifEntityGenerator { public static StaffPersonal generateTestStaffPersonal() { StaffPersonal staffPersonal = new StaffPersonal(); staffPersonal.setRefId(TEST_STAFFPERSONAL_REFID); staffPersonal.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffPersonal.setLocalId("946379881"); staffPersonal.setStateProvinceId("C2345681"); staffPersonal.setTitle("Principal"); ElectronicId electronicId = new ElectronicId(ElectronicIdType.BARCODE, "206655"); ElectronicIdList electronicIdList = new ElectronicIdList(electronicId); staffPersonal.setElectronicIdList(electronicIdList); OtherId otherId = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherIdList otherIdList = new OtherIdList(otherId); staffPersonal.setOtherIdList(otherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setPrefix("Mr."); name.setLastName("Woodall"); name.setFirstName("Charles"); name.setMiddleName("William"); name.setPreferredName("Chuck"); staffPersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); staffPersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); street.setStreetNumber("6799"); street.setStreetName("33rd"); street.setStreetType("Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); staffPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); staffPersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); staffPersonal.setEmailList(emailList); return staffPersonal; } }
|
SifEntityGenerator { public static StaffPersonal generateTestStaffPersonal() { StaffPersonal staffPersonal = new StaffPersonal(); staffPersonal.setRefId(TEST_STAFFPERSONAL_REFID); staffPersonal.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffPersonal.setLocalId("946379881"); staffPersonal.setStateProvinceId("C2345681"); staffPersonal.setTitle("Principal"); ElectronicId electronicId = new ElectronicId(ElectronicIdType.BARCODE, "206655"); ElectronicIdList electronicIdList = new ElectronicIdList(electronicId); staffPersonal.setElectronicIdList(electronicIdList); OtherId otherId = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherIdList otherIdList = new OtherIdList(otherId); staffPersonal.setOtherIdList(otherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setPrefix("Mr."); name.setLastName("Woodall"); name.setFirstName("Charles"); name.setMiddleName("William"); name.setPreferredName("Chuck"); staffPersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); staffPersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); street.setStreetNumber("6799"); street.setStreetName("33rd"); street.setStreetType("Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); staffPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); staffPersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); staffPersonal.setEmailList(emailList); return staffPersonal; } }
|
SifEntityGenerator { public static StaffPersonal generateTestStaffPersonal() { StaffPersonal staffPersonal = new StaffPersonal(); staffPersonal.setRefId(TEST_STAFFPERSONAL_REFID); staffPersonal.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffPersonal.setLocalId("946379881"); staffPersonal.setStateProvinceId("C2345681"); staffPersonal.setTitle("Principal"); ElectronicId electronicId = new ElectronicId(ElectronicIdType.BARCODE, "206655"); ElectronicIdList electronicIdList = new ElectronicIdList(electronicId); staffPersonal.setElectronicIdList(electronicIdList); OtherId otherId = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherIdList otherIdList = new OtherIdList(otherId); staffPersonal.setOtherIdList(otherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setPrefix("Mr."); name.setLastName("Woodall"); name.setFirstName("Charles"); name.setMiddleName("William"); name.setPreferredName("Chuck"); staffPersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); staffPersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); street.setStreetNumber("6799"); street.setStreetName("33rd"); street.setStreetType("Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); staffPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); staffPersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); staffPersonal.setEmailList(emailList); return staffPersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static StaffPersonal generateTestStaffPersonal() { StaffPersonal staffPersonal = new StaffPersonal(); staffPersonal.setRefId(TEST_STAFFPERSONAL_REFID); staffPersonal.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffPersonal.setLocalId("946379881"); staffPersonal.setStateProvinceId("C2345681"); staffPersonal.setTitle("Principal"); ElectronicId electronicId = new ElectronicId(ElectronicIdType.BARCODE, "206655"); ElectronicIdList electronicIdList = new ElectronicIdList(electronicId); staffPersonal.setElectronicIdList(electronicIdList); OtherId otherId = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherIdList otherIdList = new OtherIdList(otherId); staffPersonal.setOtherIdList(otherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setPrefix("Mr."); name.setLastName("Woodall"); name.setFirstName("Charles"); name.setMiddleName("William"); name.setPreferredName("Chuck"); staffPersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); staffPersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); street.setStreetNumber("6799"); street.setStreetName("33rd"); street.setStreetType("Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); staffPersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-1234"); staffPersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); staffPersonal.setEmailList(emailList); return staffPersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestEmployeePersonal() { EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYEEPERSONAL_REFID, employeePersonal.getRefId()); HrOtherIdList hrOtherIdList = employeePersonal.getOtherIdList(); Assert.assertEquals(2, hrOtherIdList.size()); OtherId otherId1 = hrOtherIdList.get(0); Assert.assertEquals(OtherIdType.SOCIALSECURITY.getValue(), otherId1.getType()); Assert.assertEquals("333333333", otherId1.getValue()); OtherId otherId2 = hrOtherIdList.get(1); Assert.assertEquals(OtherIdType.OTHER.getValue(), otherId2.getType()); Assert.assertEquals("3333", otherId2.getValue()); Name name = employeePersonal.getName(); Assert.assertEquals(NameType.NAME_OF_RECORD.getValue(), name.getType()); Assert.assertEquals("Woodall", name.getLastName()); Assert.assertEquals("Charles", name.getFirstName()); Demographics demographics = employeePersonal.getDemographics(); Assert.assertEquals(Gender.M.getValue(), demographics.getGender()); AddressList addressList = employeePersonal.getAddressList(); Assert.assertEquals(1, addressList.size()); Address address = addressList.get(0); Assert.assertEquals(AddressType.MAILING.getValue(), address.getType()); Assert.assertEquals("Chicago", address.getCity()); Assert.assertEquals(StatePrCode.IL.getValue(), address.getStateProvince()); Assert.assertEquals(CountryCode.US.getValue(), address.getCountry()); Assert.assertEquals("60660", address.getPostalCode()); Street street = address.getStreet(); Assert.assertEquals("6799 33rd Ave.", street.getLine1()); PhoneNumberList phoneNumberList = employeePersonal.getPhoneNumberList(); Assert.assertEquals(1, phoneNumberList.size()); PhoneNumber phoneNumber = phoneNumberList.get(0); Assert.assertEquals(PhoneNumberType.PRIMARY.getValue(), phoneNumber.getType()); Assert.assertEquals("(312) 555-9876", phoneNumber.getNumber()); EmailList emailList = employeePersonal.getEmailList(); Assert.assertEquals(1, emailList.size()); Email email = emailList.get(0); Assert.assertEquals(EmailType.PRIMARY.getValue(), email.getType()); Assert.assertEquals("[email protected]", email.getValue()); }
|
public static EmployeePersonal generateTestEmployeePersonal() { EmployeePersonal employeePersonal = new EmployeePersonal(); employeePersonal.setRefId(TEST_EMPLOYEEPERSONAL_REFID); employeePersonal.setStateProvinceId("C2345681"); OtherId otherId1 = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherId otherId2 = new OtherId(OtherIdType.OTHER, "3333"); HrOtherIdList hrOtherIdList = new HrOtherIdList(); hrOtherIdList.add(otherId1); hrOtherIdList.add(otherId2); employeePersonal.setOtherIdList(hrOtherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setLastName("Woodall"); name.setFirstName("Charles"); employeePersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); employeePersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); employeePersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-9876"); employeePersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); employeePersonal.setEmailList(emailList); return employeePersonal; }
|
SifEntityGenerator { public static EmployeePersonal generateTestEmployeePersonal() { EmployeePersonal employeePersonal = new EmployeePersonal(); employeePersonal.setRefId(TEST_EMPLOYEEPERSONAL_REFID); employeePersonal.setStateProvinceId("C2345681"); OtherId otherId1 = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherId otherId2 = new OtherId(OtherIdType.OTHER, "3333"); HrOtherIdList hrOtherIdList = new HrOtherIdList(); hrOtherIdList.add(otherId1); hrOtherIdList.add(otherId2); employeePersonal.setOtherIdList(hrOtherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setLastName("Woodall"); name.setFirstName("Charles"); employeePersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); employeePersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); employeePersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-9876"); employeePersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); employeePersonal.setEmailList(emailList); return employeePersonal; } }
|
SifEntityGenerator { public static EmployeePersonal generateTestEmployeePersonal() { EmployeePersonal employeePersonal = new EmployeePersonal(); employeePersonal.setRefId(TEST_EMPLOYEEPERSONAL_REFID); employeePersonal.setStateProvinceId("C2345681"); OtherId otherId1 = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherId otherId2 = new OtherId(OtherIdType.OTHER, "3333"); HrOtherIdList hrOtherIdList = new HrOtherIdList(); hrOtherIdList.add(otherId1); hrOtherIdList.add(otherId2); employeePersonal.setOtherIdList(hrOtherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setLastName("Woodall"); name.setFirstName("Charles"); employeePersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); employeePersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); employeePersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-9876"); employeePersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); employeePersonal.setEmailList(emailList); return employeePersonal; } }
|
SifEntityGenerator { public static EmployeePersonal generateTestEmployeePersonal() { EmployeePersonal employeePersonal = new EmployeePersonal(); employeePersonal.setRefId(TEST_EMPLOYEEPERSONAL_REFID); employeePersonal.setStateProvinceId("C2345681"); OtherId otherId1 = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherId otherId2 = new OtherId(OtherIdType.OTHER, "3333"); HrOtherIdList hrOtherIdList = new HrOtherIdList(); hrOtherIdList.add(otherId1); hrOtherIdList.add(otherId2); employeePersonal.setOtherIdList(hrOtherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setLastName("Woodall"); name.setFirstName("Charles"); employeePersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); employeePersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); employeePersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-9876"); employeePersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); employeePersonal.setEmailList(emailList); return employeePersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static EmployeePersonal generateTestEmployeePersonal() { EmployeePersonal employeePersonal = new EmployeePersonal(); employeePersonal.setRefId(TEST_EMPLOYEEPERSONAL_REFID); employeePersonal.setStateProvinceId("C2345681"); OtherId otherId1 = new OtherId(OtherIdType.SOCIALSECURITY, "333333333"); OtherId otherId2 = new OtherId(OtherIdType.OTHER, "3333"); HrOtherIdList hrOtherIdList = new HrOtherIdList(); hrOtherIdList.add(otherId1); hrOtherIdList.add(otherId2); employeePersonal.setOtherIdList(hrOtherIdList); Name name = new Name(); name.setType(NameType.NAME_OF_RECORD); name.setLastName("Woodall"); name.setFirstName("Charles"); employeePersonal.setName(name); Demographics demographics = new Demographics(); demographics.setGender(Gender.M); employeePersonal.setDemographics(demographics); Address address = new Address(); address.setType(AddressType.MAILING); address.setCity("Chicago"); address.setStateProvince(StatePrCode.IL); address.setCountry(CountryCode.US); address.setPostalCode("60660"); Street street = new Street(); street.setLine1("6799 33rd Ave."); address.setStreet(street); AddressList addressList = new AddressList(address); employeePersonal.setAddressList(addressList); PhoneNumberList phoneNumberList = new PhoneNumberList(); phoneNumberList.addPhoneNumber(PhoneNumberType.PRIMARY, "(312) 555-9876"); employeePersonal.setPhoneNumberList(phoneNumberList); EmailList emailList = new EmailList(); emailList.addEmail(EmailType.PRIMARY, "[email protected]"); employeePersonal.setEmailList(emailList); return employeePersonal; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestStaffAssignment() { StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); Assert.assertEquals(SifEntityGenerator.TEST_STAFFASSIGNMENT_REFID, staffAssignment.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_SCHOOLINFO_REFID, staffAssignment.getSchoolInfoRefId()); Assert.assertEquals(SifEntityGenerator.TEST_STAFFPERSONAL_REFID, staffAssignment.getStaffPersonalRefId()); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYEEPERSONAL_REFID, staffAssignment.getEmployeePersonalRefId()); Assert.assertEquals(2013, staffAssignment.getSchoolYear().intValue()); Assert.assertEquals("Twelfth grade computer science teacher", staffAssignment.getDescription()); Assert.assertEquals(YesNo.YES.getValue(), staffAssignment.getPrimaryAssignment()); Calendar jobStartDate = staffAssignment.getJobStartDate(); Assert.assertEquals(2010, jobStartDate.get(Calendar.YEAR)); Assert.assertEquals(7, jobStartDate.get(Calendar.MONTH)); Assert.assertEquals(1, jobStartDate.get(Calendar.DATE)); Calendar jobEndDate = staffAssignment.getJobEndDate(); Assert.assertEquals(2013, jobEndDate.get(Calendar.YEAR)); Assert.assertEquals(6, jobEndDate.get(Calendar.MONTH)); Assert.assertEquals(31, jobEndDate.get(Calendar.DATE)); Assert.assertEquals(new BigDecimal(1.00), staffAssignment.getJobFTE()); JobFunction jobFunction = staffAssignment.getJobFunction(); Assert.assertEquals(JobFunctionCode.INSTRUCTION.getValue(), jobFunction.getCode()); TeachingAssignment teachingAssignment = staffAssignment.getTeachingAssignment(); Assert.assertEquals(TeachingArea.COMPUTER_SCIENCE.getValue(), teachingAssignment.getCode()); GradeLevels gradeLevels = staffAssignment.getGradeLevels(); Assert.assertEquals(1, gradeLevels.size()); GradeLevel gradeLevel1 = gradeLevels.get(0); Assert.assertEquals(GradeLevelCode._12.getValue(), gradeLevel1.getCode()); Assert.assertEquals(YesNo.NO.getValue(), staffAssignment.getItinerantTeacher()); InstructionalLevel instructionalLevel = staffAssignment.getInstructionalLevel(); Assert.assertEquals(InstructionalLevelCode.COLLEGE_LEVEL.getValue(), instructionalLevel.getCode()); }
|
public static StaffAssignment generateTestStaffAssignment() { StaffAssignment staffAssignment = new StaffAssignment(); staffAssignment.setRefId(TEST_STAFFASSIGNMENT_REFID); staffAssignment.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); staffAssignment.setStaffPersonalRefId(TEST_STAFFPERSONAL_REFID); staffAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffAssignment.setSchoolYear(new Integer(2013)); staffAssignment.setDescription("Twelfth grade computer science teacher"); staffAssignment.setPrimaryAssignment(YesNo.YES); staffAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); staffAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); staffAssignment.setJobFTE(new BigDecimal(1.00)); staffAssignment.setJobFunction(new JobFunction(JobFunctionCode.INSTRUCTION)); staffAssignment.setTeachingAssignment(new TeachingAssignment(TeachingArea.COMPUTER_SCIENCE)); staffAssignment.setGradeLevels(new GradeLevels(new GradeLevel(GradeLevelCode._12))); staffAssignment.setItinerantTeacher(YesNo.NO); InstructionalLevel instructionalLevel = new InstructionalLevel(); instructionalLevel.setCode(InstructionalLevelCode.COLLEGE_LEVEL); staffAssignment.setInstructionalLevel(instructionalLevel); return staffAssignment; }
|
SifEntityGenerator { public static StaffAssignment generateTestStaffAssignment() { StaffAssignment staffAssignment = new StaffAssignment(); staffAssignment.setRefId(TEST_STAFFASSIGNMENT_REFID); staffAssignment.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); staffAssignment.setStaffPersonalRefId(TEST_STAFFPERSONAL_REFID); staffAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffAssignment.setSchoolYear(new Integer(2013)); staffAssignment.setDescription("Twelfth grade computer science teacher"); staffAssignment.setPrimaryAssignment(YesNo.YES); staffAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); staffAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); staffAssignment.setJobFTE(new BigDecimal(1.00)); staffAssignment.setJobFunction(new JobFunction(JobFunctionCode.INSTRUCTION)); staffAssignment.setTeachingAssignment(new TeachingAssignment(TeachingArea.COMPUTER_SCIENCE)); staffAssignment.setGradeLevels(new GradeLevels(new GradeLevel(GradeLevelCode._12))); staffAssignment.setItinerantTeacher(YesNo.NO); InstructionalLevel instructionalLevel = new InstructionalLevel(); instructionalLevel.setCode(InstructionalLevelCode.COLLEGE_LEVEL); staffAssignment.setInstructionalLevel(instructionalLevel); return staffAssignment; } }
|
SifEntityGenerator { public static StaffAssignment generateTestStaffAssignment() { StaffAssignment staffAssignment = new StaffAssignment(); staffAssignment.setRefId(TEST_STAFFASSIGNMENT_REFID); staffAssignment.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); staffAssignment.setStaffPersonalRefId(TEST_STAFFPERSONAL_REFID); staffAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffAssignment.setSchoolYear(new Integer(2013)); staffAssignment.setDescription("Twelfth grade computer science teacher"); staffAssignment.setPrimaryAssignment(YesNo.YES); staffAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); staffAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); staffAssignment.setJobFTE(new BigDecimal(1.00)); staffAssignment.setJobFunction(new JobFunction(JobFunctionCode.INSTRUCTION)); staffAssignment.setTeachingAssignment(new TeachingAssignment(TeachingArea.COMPUTER_SCIENCE)); staffAssignment.setGradeLevels(new GradeLevels(new GradeLevel(GradeLevelCode._12))); staffAssignment.setItinerantTeacher(YesNo.NO); InstructionalLevel instructionalLevel = new InstructionalLevel(); instructionalLevel.setCode(InstructionalLevelCode.COLLEGE_LEVEL); staffAssignment.setInstructionalLevel(instructionalLevel); return staffAssignment; } }
|
SifEntityGenerator { public static StaffAssignment generateTestStaffAssignment() { StaffAssignment staffAssignment = new StaffAssignment(); staffAssignment.setRefId(TEST_STAFFASSIGNMENT_REFID); staffAssignment.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); staffAssignment.setStaffPersonalRefId(TEST_STAFFPERSONAL_REFID); staffAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffAssignment.setSchoolYear(new Integer(2013)); staffAssignment.setDescription("Twelfth grade computer science teacher"); staffAssignment.setPrimaryAssignment(YesNo.YES); staffAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); staffAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); staffAssignment.setJobFTE(new BigDecimal(1.00)); staffAssignment.setJobFunction(new JobFunction(JobFunctionCode.INSTRUCTION)); staffAssignment.setTeachingAssignment(new TeachingAssignment(TeachingArea.COMPUTER_SCIENCE)); staffAssignment.setGradeLevels(new GradeLevels(new GradeLevel(GradeLevelCode._12))); staffAssignment.setItinerantTeacher(YesNo.NO); InstructionalLevel instructionalLevel = new InstructionalLevel(); instructionalLevel.setCode(InstructionalLevelCode.COLLEGE_LEVEL); staffAssignment.setInstructionalLevel(instructionalLevel); return staffAssignment; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static StaffAssignment generateTestStaffAssignment() { StaffAssignment staffAssignment = new StaffAssignment(); staffAssignment.setRefId(TEST_STAFFASSIGNMENT_REFID); staffAssignment.setSchoolInfoRefId(TEST_SCHOOLINFO_REFID); staffAssignment.setStaffPersonalRefId(TEST_STAFFPERSONAL_REFID); staffAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); staffAssignment.setSchoolYear(new Integer(2013)); staffAssignment.setDescription("Twelfth grade computer science teacher"); staffAssignment.setPrimaryAssignment(YesNo.YES); staffAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); staffAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); staffAssignment.setJobFTE(new BigDecimal(1.00)); staffAssignment.setJobFunction(new JobFunction(JobFunctionCode.INSTRUCTION)); staffAssignment.setTeachingAssignment(new TeachingAssignment(TeachingArea.COMPUTER_SCIENCE)); staffAssignment.setGradeLevels(new GradeLevels(new GradeLevel(GradeLevelCode._12))); staffAssignment.setItinerantTeacher(YesNo.NO); InstructionalLevel instructionalLevel = new InstructionalLevel(); instructionalLevel.setCode(InstructionalLevelCode.COLLEGE_LEVEL); staffAssignment.setInstructionalLevel(instructionalLevel); return staffAssignment; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestEmploymentRecord() { EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYMENTRECORD_REFID, employmentRecord.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_STAFFPERSONAL_REFID, employmentRecord.getSIF_RefId()); Assert.assertEquals("StaffPersonal", employmentRecord.getSIF_RefObject()); Assert.assertEquals(SifEntityGenerator.TEST_LEAINFO_REFID, employmentRecord.getLEAInfoRefId()); Assert.assertTrue(employmentRecord.getActive()); Assert.assertEquals(FullTimeStatus.FULLTIME.getValue(), employmentRecord.getFullTimeStatus()); Calendar hireDate = employmentRecord.getHireDate(); Assert.assertEquals(2010, hireDate.get(Calendar.YEAR)); Assert.assertEquals(7, hireDate.get(Calendar.MONTH)); Assert.assertEquals(1, hireDate.get(Calendar.DATE)); Calendar terminationDate = employmentRecord.getTerminationDate(); Assert.assertEquals(2012, terminationDate.get(Calendar.YEAR)); Assert.assertEquals(6, terminationDate.get(Calendar.MONTH)); Assert.assertEquals(31, terminationDate.get(Calendar.DATE)); Assert.assertEquals(20, employmentRecord.getTotalYearsExperience().intValue()); Assert.assertEquals("Senior Staff", employmentRecord.getPositionTitle()); Assert.assertEquals("10", employmentRecord.getPositionNumber()); Calendar seniorityDate = employmentRecord.getSeniorityDate(); Assert.assertEquals(2011, seniorityDate.get(Calendar.YEAR)); Assert.assertEquals(1, seniorityDate.get(Calendar.MONTH)); Assert.assertEquals(1, seniorityDate.get(Calendar.DATE)); Calendar tenureDate = employmentRecord.getTenureDate(); Assert.assertEquals(2011, tenureDate.get(Calendar.YEAR)); Assert.assertEquals(7, tenureDate.get(Calendar.MONTH)); Assert.assertEquals(1, tenureDate.get(Calendar.DATE)); }
|
public static EmploymentRecord generateTestEmploymentRecord() { EmploymentRecord employmentRecord = new EmploymentRecord(); employmentRecord.setRefId(TEST_EMPLOYMENTRECORD_REFID); employmentRecord.setSIF_RefId(TEST_STAFFPERSONAL_REFID); employmentRecord.setSIF_RefObject("StaffPersonal"); employmentRecord.setLEAInfoRefId(TEST_LEAINFO_REFID); employmentRecord.setActive(true); employmentRecord.setFullTimeStatus(FullTimeStatus.FULLTIME); employmentRecord.setHireDate(new GregorianCalendar(2010, 7, 1)); employmentRecord.setTerminationDate(new GregorianCalendar(2012, 6, 31)); employmentRecord.setTotalYearsExperience(20); employmentRecord.setPositionTitle("Senior Staff"); employmentRecord.setPositionNumber("10"); employmentRecord.setSeniorityDate(new GregorianCalendar(2011, 1, 1)); employmentRecord.setTenureDate(new GregorianCalendar(2011, 7, 1)); return employmentRecord; }
|
SifEntityGenerator { public static EmploymentRecord generateTestEmploymentRecord() { EmploymentRecord employmentRecord = new EmploymentRecord(); employmentRecord.setRefId(TEST_EMPLOYMENTRECORD_REFID); employmentRecord.setSIF_RefId(TEST_STAFFPERSONAL_REFID); employmentRecord.setSIF_RefObject("StaffPersonal"); employmentRecord.setLEAInfoRefId(TEST_LEAINFO_REFID); employmentRecord.setActive(true); employmentRecord.setFullTimeStatus(FullTimeStatus.FULLTIME); employmentRecord.setHireDate(new GregorianCalendar(2010, 7, 1)); employmentRecord.setTerminationDate(new GregorianCalendar(2012, 6, 31)); employmentRecord.setTotalYearsExperience(20); employmentRecord.setPositionTitle("Senior Staff"); employmentRecord.setPositionNumber("10"); employmentRecord.setSeniorityDate(new GregorianCalendar(2011, 1, 1)); employmentRecord.setTenureDate(new GregorianCalendar(2011, 7, 1)); return employmentRecord; } }
|
SifEntityGenerator { public static EmploymentRecord generateTestEmploymentRecord() { EmploymentRecord employmentRecord = new EmploymentRecord(); employmentRecord.setRefId(TEST_EMPLOYMENTRECORD_REFID); employmentRecord.setSIF_RefId(TEST_STAFFPERSONAL_REFID); employmentRecord.setSIF_RefObject("StaffPersonal"); employmentRecord.setLEAInfoRefId(TEST_LEAINFO_REFID); employmentRecord.setActive(true); employmentRecord.setFullTimeStatus(FullTimeStatus.FULLTIME); employmentRecord.setHireDate(new GregorianCalendar(2010, 7, 1)); employmentRecord.setTerminationDate(new GregorianCalendar(2012, 6, 31)); employmentRecord.setTotalYearsExperience(20); employmentRecord.setPositionTitle("Senior Staff"); employmentRecord.setPositionNumber("10"); employmentRecord.setSeniorityDate(new GregorianCalendar(2011, 1, 1)); employmentRecord.setTenureDate(new GregorianCalendar(2011, 7, 1)); return employmentRecord; } }
|
SifEntityGenerator { public static EmploymentRecord generateTestEmploymentRecord() { EmploymentRecord employmentRecord = new EmploymentRecord(); employmentRecord.setRefId(TEST_EMPLOYMENTRECORD_REFID); employmentRecord.setSIF_RefId(TEST_STAFFPERSONAL_REFID); employmentRecord.setSIF_RefObject("StaffPersonal"); employmentRecord.setLEAInfoRefId(TEST_LEAINFO_REFID); employmentRecord.setActive(true); employmentRecord.setFullTimeStatus(FullTimeStatus.FULLTIME); employmentRecord.setHireDate(new GregorianCalendar(2010, 7, 1)); employmentRecord.setTerminationDate(new GregorianCalendar(2012, 6, 31)); employmentRecord.setTotalYearsExperience(20); employmentRecord.setPositionTitle("Senior Staff"); employmentRecord.setPositionNumber("10"); employmentRecord.setSeniorityDate(new GregorianCalendar(2011, 1, 1)); employmentRecord.setTenureDate(new GregorianCalendar(2011, 7, 1)); return employmentRecord; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static EmploymentRecord generateTestEmploymentRecord() { EmploymentRecord employmentRecord = new EmploymentRecord(); employmentRecord.setRefId(TEST_EMPLOYMENTRECORD_REFID); employmentRecord.setSIF_RefId(TEST_STAFFPERSONAL_REFID); employmentRecord.setSIF_RefObject("StaffPersonal"); employmentRecord.setLEAInfoRefId(TEST_LEAINFO_REFID); employmentRecord.setActive(true); employmentRecord.setFullTimeStatus(FullTimeStatus.FULLTIME); employmentRecord.setHireDate(new GregorianCalendar(2010, 7, 1)); employmentRecord.setTerminationDate(new GregorianCalendar(2012, 6, 31)); employmentRecord.setTotalYearsExperience(20); employmentRecord.setPositionTitle("Senior Staff"); employmentRecord.setPositionNumber("10"); employmentRecord.setSeniorityDate(new GregorianCalendar(2011, 1, 1)); employmentRecord.setTenureDate(new GregorianCalendar(2011, 7, 1)); return employmentRecord; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGenerateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYEEASSIGNMENT_REFID, employeeAssignment.getRefId()); Assert.assertEquals(SifEntityGenerator.TEST_EMPLOYEEPERSONAL_REFID, employeeAssignment.getEmployeePersonalRefId()); Assert.assertEquals("Twelfth grade computer science teacher", employeeAssignment.getDescription()); Assert.assertEquals(YesNo.YES.getValue(), employeeAssignment.getPrimaryAssignment()); Calendar jobStartDate = employeeAssignment.getJobStartDate(); Assert.assertEquals(2010, jobStartDate.get(Calendar.YEAR)); Assert.assertEquals(7, jobStartDate.get(Calendar.MONTH)); Assert.assertEquals(1, jobStartDate.get(Calendar.DATE)); Calendar jobEndDate = employeeAssignment.getJobEndDate(); Assert.assertEquals(2013, jobEndDate.get(Calendar.YEAR)); Assert.assertEquals(6, jobEndDate.get(Calendar.MONTH)); Assert.assertEquals(31, jobEndDate.get(Calendar.DATE)); Assert.assertEquals(new BigDecimal(1.00), employeeAssignment.getJobFTE()); JobClassification jobClassification = employeeAssignment.getJobClassification(); Assert.assertEquals(JobClassificationCode.TEACHER.getValue(), jobClassification.getCode()); OtherCodeList jobClassificationOtherCodeList = jobClassification.getOtherCodeList(); Assert.assertEquals(1, jobClassificationOtherCodeList.size()); OtherCode jobClassificationOtherCode = jobClassificationOtherCodeList.get(0); Assert.assertEquals("12345", jobClassificationOtherCode.getValue()); HRProgramType programType = employeeAssignment.getProgramType(); Assert.assertEquals(ProgramTypeCode.REGULAR_EDUCATION.getValue(), programType.getCode()); OtherCodeList programTypeOtherCodeList = programType.getOtherCodeList(); Assert.assertEquals(1, programTypeOtherCodeList.size()); OtherCode programTypeOtherCode = programTypeOtherCodeList.get(0); Assert.assertEquals("67890", programTypeOtherCode.getValue()); ProgramFundingSource programFundingSource = employeeAssignment.getFundingSource(); Assert.assertEquals("0617", programFundingSource.getCode()); OtherCodeList programFundingSourceOtherCodeList = programFundingSource.getOtherCodeList(); Assert.assertEquals(1, programFundingSourceOtherCodeList.size()); OtherCode programFundingSourceOtherCode = programFundingSourceOtherCodeList.get(0); Assert.assertEquals("54321", programFundingSourceOtherCode.getValue()); }
|
public static EmployeeAssignment generateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = new EmployeeAssignment(); employeeAssignment.setRefId(TEST_EMPLOYEEASSIGNMENT_REFID); employeeAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); employeeAssignment.setDescription("Twelfth grade computer science teacher"); employeeAssignment.setPrimaryAssignment(YesNo.YES); employeeAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); employeeAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); employeeAssignment.setJobFTE(new BigDecimal(1.00)); JobClassification jobClassification = new JobClassification(JobClassificationCode.TEACHER); OtherCode jobClassificationOtherCode = new OtherCode(); jobClassificationOtherCode.setValue("12345"); jobClassification.setOtherCodeList(new OtherCodeList(jobClassificationOtherCode)); employeeAssignment.setJobClassification(jobClassification); HRProgramType programType = new HRProgramType(); programType.setCode(ProgramTypeCode.REGULAR_EDUCATION); OtherCode programTypeOtherCode = new OtherCode(); programTypeOtherCode.setValue("67890"); programType.setOtherCodeList(new OtherCodeList(programTypeOtherCode)); employeeAssignment.setProgramType(programType); ProgramFundingSource programFundingSource = new ProgramFundingSource(); programFundingSource.setCode("0617"); OtherCode programFundingSourceOtherCode = new OtherCode(); programFundingSourceOtherCode.setValue("54321"); programFundingSource.setOtherCodeList(new OtherCodeList(programFundingSourceOtherCode)); employeeAssignment.setFundingSource(programFundingSource); return employeeAssignment; }
|
SifEntityGenerator { public static EmployeeAssignment generateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = new EmployeeAssignment(); employeeAssignment.setRefId(TEST_EMPLOYEEASSIGNMENT_REFID); employeeAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); employeeAssignment.setDescription("Twelfth grade computer science teacher"); employeeAssignment.setPrimaryAssignment(YesNo.YES); employeeAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); employeeAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); employeeAssignment.setJobFTE(new BigDecimal(1.00)); JobClassification jobClassification = new JobClassification(JobClassificationCode.TEACHER); OtherCode jobClassificationOtherCode = new OtherCode(); jobClassificationOtherCode.setValue("12345"); jobClassification.setOtherCodeList(new OtherCodeList(jobClassificationOtherCode)); employeeAssignment.setJobClassification(jobClassification); HRProgramType programType = new HRProgramType(); programType.setCode(ProgramTypeCode.REGULAR_EDUCATION); OtherCode programTypeOtherCode = new OtherCode(); programTypeOtherCode.setValue("67890"); programType.setOtherCodeList(new OtherCodeList(programTypeOtherCode)); employeeAssignment.setProgramType(programType); ProgramFundingSource programFundingSource = new ProgramFundingSource(); programFundingSource.setCode("0617"); OtherCode programFundingSourceOtherCode = new OtherCode(); programFundingSourceOtherCode.setValue("54321"); programFundingSource.setOtherCodeList(new OtherCodeList(programFundingSourceOtherCode)); employeeAssignment.setFundingSource(programFundingSource); return employeeAssignment; } }
|
SifEntityGenerator { public static EmployeeAssignment generateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = new EmployeeAssignment(); employeeAssignment.setRefId(TEST_EMPLOYEEASSIGNMENT_REFID); employeeAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); employeeAssignment.setDescription("Twelfth grade computer science teacher"); employeeAssignment.setPrimaryAssignment(YesNo.YES); employeeAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); employeeAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); employeeAssignment.setJobFTE(new BigDecimal(1.00)); JobClassification jobClassification = new JobClassification(JobClassificationCode.TEACHER); OtherCode jobClassificationOtherCode = new OtherCode(); jobClassificationOtherCode.setValue("12345"); jobClassification.setOtherCodeList(new OtherCodeList(jobClassificationOtherCode)); employeeAssignment.setJobClassification(jobClassification); HRProgramType programType = new HRProgramType(); programType.setCode(ProgramTypeCode.REGULAR_EDUCATION); OtherCode programTypeOtherCode = new OtherCode(); programTypeOtherCode.setValue("67890"); programType.setOtherCodeList(new OtherCodeList(programTypeOtherCode)); employeeAssignment.setProgramType(programType); ProgramFundingSource programFundingSource = new ProgramFundingSource(); programFundingSource.setCode("0617"); OtherCode programFundingSourceOtherCode = new OtherCode(); programFundingSourceOtherCode.setValue("54321"); programFundingSource.setOtherCodeList(new OtherCodeList(programFundingSourceOtherCode)); employeeAssignment.setFundingSource(programFundingSource); return employeeAssignment; } }
|
SifEntityGenerator { public static EmployeeAssignment generateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = new EmployeeAssignment(); employeeAssignment.setRefId(TEST_EMPLOYEEASSIGNMENT_REFID); employeeAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); employeeAssignment.setDescription("Twelfth grade computer science teacher"); employeeAssignment.setPrimaryAssignment(YesNo.YES); employeeAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); employeeAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); employeeAssignment.setJobFTE(new BigDecimal(1.00)); JobClassification jobClassification = new JobClassification(JobClassificationCode.TEACHER); OtherCode jobClassificationOtherCode = new OtherCode(); jobClassificationOtherCode.setValue("12345"); jobClassification.setOtherCodeList(new OtherCodeList(jobClassificationOtherCode)); employeeAssignment.setJobClassification(jobClassification); HRProgramType programType = new HRProgramType(); programType.setCode(ProgramTypeCode.REGULAR_EDUCATION); OtherCode programTypeOtherCode = new OtherCode(); programTypeOtherCode.setValue("67890"); programType.setOtherCodeList(new OtherCodeList(programTypeOtherCode)); employeeAssignment.setProgramType(programType); ProgramFundingSource programFundingSource = new ProgramFundingSource(); programFundingSource.setCode("0617"); OtherCode programFundingSourceOtherCode = new OtherCode(); programFundingSourceOtherCode.setValue("54321"); programFundingSource.setOtherCodeList(new OtherCodeList(programFundingSourceOtherCode)); employeeAssignment.setFundingSource(programFundingSource); return employeeAssignment; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); }
|
SifEntityGenerator { public static EmployeeAssignment generateTestEmployeeAssignment() { EmployeeAssignment employeeAssignment = new EmployeeAssignment(); employeeAssignment.setRefId(TEST_EMPLOYEEASSIGNMENT_REFID); employeeAssignment.setEmployeePersonalRefId(TEST_EMPLOYEEPERSONAL_REFID); employeeAssignment.setDescription("Twelfth grade computer science teacher"); employeeAssignment.setPrimaryAssignment(YesNo.YES); employeeAssignment.setJobStartDate(new GregorianCalendar(2010, 7, 1)); employeeAssignment.setJobEndDate(new GregorianCalendar(2013, 6, 31)); employeeAssignment.setJobFTE(new BigDecimal(1.00)); JobClassification jobClassification = new JobClassification(JobClassificationCode.TEACHER); OtherCode jobClassificationOtherCode = new OtherCode(); jobClassificationOtherCode.setValue("12345"); jobClassification.setOtherCodeList(new OtherCodeList(jobClassificationOtherCode)); employeeAssignment.setJobClassification(jobClassification); HRProgramType programType = new HRProgramType(); programType.setCode(ProgramTypeCode.REGULAR_EDUCATION); OtherCode programTypeOtherCode = new OtherCode(); programTypeOtherCode.setValue("67890"); programType.setOtherCodeList(new OtherCodeList(programTypeOtherCode)); employeeAssignment.setProgramType(programType); ProgramFundingSource programFundingSource = new ProgramFundingSource(); programFundingSource.setCode("0617"); OtherCode programFundingSourceOtherCode = new OtherCode(); programFundingSourceOtherCode.setValue("54321"); programFundingSource.setOtherCodeList(new OtherCodeList(programFundingSourceOtherCode)); employeeAssignment.setFundingSource(programFundingSource); return employeeAssignment; } static SchoolInfo generateTestSchoolInfo(); static LEAInfo generateTestLEAInfo(); static SEAInfo generateTestSEAInfo(); static StudentSchoolEnrollment generateTestStudentSchoolEnrollment(); static StudentLEARelationship generateTestStudentLeaRelationship(); static StudentPersonal generateTestStudentPersonal(); static StaffPersonal generateTestStaffPersonal(); static EmployeePersonal generateTestEmployeePersonal(); static StaffAssignment generateTestStaffAssignment(); static EmploymentRecord generateTestEmploymentRecord(); static EmployeeAssignment generateTestEmployeeAssignment(); static final String TEST_SCHOOLINFO_REFID; static final String TEST_LEAINFO_REFID; static final String TEST_SEAINFO_REFID; static final String TEST_STUDENTPERSONAL_REFID; static final String TEST_STUDENTSCHOOLENROLLMENT_REFID; static final String TEST_STUDENTLEARELATIONSHIP_REFID; static final String TEST_STAFFPERSONAL_REFID; static final String TEST_EMPLOYEEPERSONAL_REFID; static final String TEST_STAFFASSIGNMENT_REFID; static final String TEST_EMPLOYMENTRECORD_REFID; static final String TEST_EMPLOYEEASSIGNMENT_REFID; }
|
@Test public void testGetPropertiesDefault() throws ParseException { String[] args = {}; Properties props = PropertyUtils.getProperties(args); Assert.assertEquals("test.publisher.agent", props.getProperty(PropertyUtils.KEY_AGENT_ID)); Assert.assertEquals("http: Assert.assertEquals("TestZone", props.getProperty(PropertyUtils.KEY_ZONE_ID)); Assert.assertEquals("LEAInfoAdd", props.getProperty(PropertyUtils.KEY_SCRIPT)); Assert.assertEquals(5000, ((Long) props.get(PropertyUtils.KEY_WAIT_TIME)).longValue()); Assert.assertEquals("", props.getProperty(PropertyUtils.KEY_MESSAGE_FILE)); Assert.assertEquals("ADD", props.getProperty(PropertyUtils.KEY_EVENT_ACTION)); }
|
public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } static Properties getProperties(String[] args); }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } static Properties getProperties(String[] args); static final String KEY_ZONE_URL; static final String KEY_ZONE_ID; static final String KEY_AGENT_ID; static final String KEY_SCRIPT; static final String KEY_WAIT_TIME; static final String KEY_MESSAGE_FILE; static final String KEY_EVENT_ACTION; static final Options OPTIONS; }
|
@Test public void testGetPropertiesNonDefault() throws ParseException { String agentId = "agentId"; String zoneUrl = "http: String zoneId = "MyZone"; String script = "step1,step2,step3"; long waitTime = 9999; String messageFile = "path/to/file"; String eventAction = "DELETE"; String[] args = {"-a", agentId, "-u", zoneUrl, "-z", zoneId, "-s", script, "-w", String.valueOf(waitTime), "-f", messageFile, "-e", eventAction}; Properties props = PropertyUtils.getProperties(args); Assert.assertEquals(agentId, props.getProperty(PropertyUtils.KEY_AGENT_ID)); Assert.assertEquals(zoneUrl, props.getProperty(PropertyUtils.KEY_ZONE_URL)); Assert.assertEquals(zoneId, props.getProperty(PropertyUtils.KEY_ZONE_ID)); Assert.assertEquals(script, props.getProperty(PropertyUtils.KEY_SCRIPT)); Assert.assertEquals(waitTime, ((Long) props.get(PropertyUtils.KEY_WAIT_TIME)).longValue()); Assert.assertEquals(messageFile, props.getProperty(PropertyUtils.KEY_MESSAGE_FILE)); Assert.assertEquals(eventAction, props.getProperty(PropertyUtils.KEY_EVENT_ACTION)); }
|
public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } static Properties getProperties(String[] args); }
|
PropertyUtils { public static Properties getProperties(String[] args) throws ParseException { Properties props = new Properties(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(OPTIONS, args); String zoneUrl = cmd.getOptionValue(FLAG_ZONE_URL, DEFAULT_ZONE_URL); String zoneId = cmd.getOptionValue(FLAG_ZONE_ID, DEFAULT_ZONE_ID); String agentId = cmd.getOptionValue(FLAG_AGENT_ID, DEFAULT_AGENT_ID); String script = cmd.getOptionValue(FLAG_SCRIPT, DEFAULT_SCRIPT); String waitTimeStr = cmd.getOptionValue(FLAG_WAIT_TIME, "DEFAULT_WAIT_TIME"); long waitTime; try { waitTime = Long.parseLong(waitTimeStr); } catch (NumberFormatException e) { waitTime = Long.parseLong(DEFAULT_WAIT_TIME); } props.put(KEY_ZONE_URL, zoneUrl); props.put(KEY_ZONE_ID, zoneId); props.put(KEY_AGENT_ID, agentId); props.put(KEY_SCRIPT, script); props.put(KEY_WAIT_TIME, waitTime); String messageFile = cmd.getOptionValue(FLAG_MESSAGE_FILE, DEFAULT_MESSAGE_FILE); props.put(KEY_MESSAGE_FILE, messageFile); String eventAction = cmd.getOptionValue(FLAG_EVENT_ACTION, DEFAULT_EVENT_ACTION); props.put(KEY_EVENT_ACTION, eventAction); return props; } static Properties getProperties(String[] args); static final String KEY_ZONE_URL; static final String KEY_ZONE_ID; static final String KEY_AGENT_ID; static final String KEY_SCRIPT; static final String KEY_WAIT_TIME; static final String KEY_MESSAGE_FILE; static final String KEY_EVENT_ACTION; static final Options OPTIONS; }
|
@Test public void shouldCreateAndConfigureAgent() throws Exception { ZoneConfigurator mockZoneConfigurator = Mockito.mock(ZoneConfigurator.class); EventReporterAgent agent = createEventReporterAgent(mockZoneConfigurator); agent.startAgent(); AgentProperties props = agent.getProperties(); Assert.assertEquals("Push", props.getProperty("adk.messaging.mode")); Assert.assertEquals("http", props.getProperty("adk.messaging.transport")); Assert.assertEquals("30000", props.getProperty("adk.messaging.pullFrequency")); Assert.assertEquals("32000", props.getProperty("adk.messaging.maxBufferSize")); Assert.assertEquals("test.publisher.agent", agent.getId()); TransportManager transportManager = agent.getTransportManager(); Transport transport = transportManager.getTransport("http"); TransportProperties transportProperties = transport.getProperties(); Assert.assertEquals("25101", transportProperties.getProperty("port")); Zone[] allZones = agent.getZoneFactory().getAllZones(); Assert.assertNotNull("Agents zones should not be null", allZones); Assert.assertEquals("Agent should be configured with one zone", 1, allZones.length); Assert.assertNotNull("Agent's zone should not be null", allZones[0]); Assert.assertEquals("Agent's zone Id should be TestZone", "TestZone", allZones[0].getZoneId()); Assert.assertEquals("Agent's zone URL should be http: "http: Mockito.verify(mockZoneConfigurator, Mockito.times(1)).configure(Mockito.any(Zone[].class)); }
|
public void startAgent() throws Exception { super.initialize(); setProperties(); Zone[] allZones = getZoneFactory().getAllZones(); zoneConfigurator.configure(allZones); }
|
EventReporterAgent extends Agent { public void startAgent() throws Exception { super.initialize(); setProperties(); Zone[] allZones = getZoneFactory().getAllZones(); zoneConfigurator.configure(allZones); } }
|
EventReporterAgent extends Agent { public void startAgent() throws Exception { super.initialize(); setProperties(); Zone[] allZones = getZoneFactory().getAllZones(); zoneConfigurator.configure(allZones); } EventReporterAgent(); EventReporterAgent(String id); EventReporterAgent(String id, ZoneConfigurator zoneConfig, Properties agentProperties,
Properties httpProperties, Properties httpsProperties, String zoneId,
String zoneUrl, SIFVersion sifVersion); }
|
EventReporterAgent extends Agent { public void startAgent() throws Exception { super.initialize(); setProperties(); Zone[] allZones = getZoneFactory().getAllZones(); zoneConfigurator.configure(allZones); } EventReporterAgent(); EventReporterAgent(String id); EventReporterAgent(String id, ZoneConfigurator zoneConfig, Properties agentProperties,
Properties httpProperties, Properties httpsProperties, String zoneId,
String zoneUrl, SIFVersion sifVersion); void startAgent(); void setConfigFilePath(String configFilePath); String getConfigFilePath(); void setZoneConfigurator(ZoneConfigurator zoneConfigurator); ZoneConfigurator getZoneConfigurator(); void setAgentProperties(Properties agentProperties); Properties getAgentProperties(); void setHttpProperties(Properties httpProperties); Properties getHttpProperties(); void setHttpsProperties(Properties httpsProperties); Properties getHttpsProperties(); void setSifVersion(SIFVersion sifVersion); SIFVersion getSifVersion(); }
|
EventReporterAgent extends Agent { public void startAgent() throws Exception { super.initialize(); setProperties(); Zone[] allZones = getZoneFactory().getAllZones(); zoneConfigurator.configure(allZones); } EventReporterAgent(); EventReporterAgent(String id); EventReporterAgent(String id, ZoneConfigurator zoneConfig, Properties agentProperties,
Properties httpProperties, Properties httpsProperties, String zoneId,
String zoneUrl, SIFVersion sifVersion); void startAgent(); void setConfigFilePath(String configFilePath); String getConfigFilePath(); void setZoneConfigurator(ZoneConfigurator zoneConfigurator); ZoneConfigurator getZoneConfigurator(); void setAgentProperties(Properties agentProperties); Properties getAgentProperties(); void setHttpProperties(Properties httpProperties); Properties getHttpProperties(); void setHttpsProperties(Properties httpsProperties); Properties getHttpsProperties(); void setSifVersion(SIFVersion sifVersion); SIFVersion getSifVersion(); }
|
@Test public void testshouldExtract() { Entity student = Mockito.mock(Entity.class); Mockito.when(student.getType()).thenReturn(EntityNames.STUDENT); Assert.assertTrue(datelessExtractVerifier.shouldExtract(student, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(datelessExtractVerifier.shouldExtract(student, null)); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; }
|
DatelessExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; } }
|
DatelessExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; } }
|
DatelessExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
DatelessExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void testRunReportScript() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ADKException { Map<Class<? extends SIFDataObject>, List<EventAction>> testMap; testMap = new LinkedHashMap<Class<? extends SIFDataObject>, List<EventAction>>(); List<EventAction> addChangeDeleteEventActionList = new ArrayList<EventAction>(); addChangeDeleteEventActionList.add(EventAction.ADD); addChangeDeleteEventActionList.add(EventAction.CHANGE); addChangeDeleteEventActionList.add(EventAction.DELETE); testMap.put(LEAInfo.class, addChangeDeleteEventActionList); testMap.put(SchoolInfo.class, addChangeDeleteEventActionList); testMap.put(StudentPersonal.class, addChangeDeleteEventActionList); testMap.put(StudentLEARelationship.class, addChangeDeleteEventActionList); testMap.put(StudentSchoolEnrollment.class, addChangeDeleteEventActionList); String[] scriptArray = { "LEAInfoAdd", "LEAInfoChange", "LEAInfoDelete", "SchoolInfoAdd", "SchoolInfoChange", "SchoolInfoDelete", "StudentPersonalAdd", "StudentPersonalChange", "StudentPersonalDelete", "StudentLEARelationshipAdd", "StudentLEARelationshipChange", "StudentLEARelationshipDelete", "StudentSchoolEnrollmentAdd", "StudentSchoolEnrollmentChange", "StudentSchoolEnrollmentDelete", "StaffPersonalAdd", "StaffPersonalChange", "StaffPersonalDelete", "EmployeePersonalAdd", "EmployeePersonalChange", "EmployeePersonalDelete", "StaffAssignmentAdd", "StaffAssignmentChange", "StaffAssignmentDelete", "EmploymentRecordAdd", "EmploymentRecordChange", "EmploymentRecordDelete", "EmployeeAssignmentAdd", "EmployeeAssignmentChange", "EmployeeAssignmentDelete" }; String script = ""; for (String item : scriptArray) { script += item + ","; } long waitTime = 0; List<Event> eventsSent = eventReporter.runReportScript(script, waitTime); Mockito.verify(zone, Mockito.times(scriptArray.length)).reportEvent(Mockito.any(Event.class)); Assert.assertEquals(scriptArray.length, eventsSent.size()); int index = 0; for (Class<? extends SIFDataObject> expectedClass : testMap.keySet()) { for (EventAction expectedAction : testMap.get(expectedClass)) { Event event = eventsSent.get(index++); checkScriptedEvent(event, expectedClass, expectedAction); } } }
|
public List<Event> runReportScript(String script, long waitTime) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List<Event> eventsSent = new ArrayList<Event>(); LOG.info("Wait time (ms): " + waitTime); String[] eventDescriptors = script.split(","); for (String descriptor : eventDescriptors) { GeneratorScriptMethod scriptMethod = GeneratorScriptMethod.get(descriptor); if (scriptMethod == null) { LOG.error("Error retrieving scriptMethod - " + descriptor); } else { LOG.info("Executing script method - " + scriptMethod.toString()); try { Event eventSent = scriptMethod.execute(this); eventsSent.add(eventSent); Thread.sleep(waitTime); } catch (SecurityException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (NoSuchMethodException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (InterruptedException e) { LOG.error("Exception while sleeping", e); } } } return eventsSent; }
|
EventReporter implements Publisher { public List<Event> runReportScript(String script, long waitTime) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List<Event> eventsSent = new ArrayList<Event>(); LOG.info("Wait time (ms): " + waitTime); String[] eventDescriptors = script.split(","); for (String descriptor : eventDescriptors) { GeneratorScriptMethod scriptMethod = GeneratorScriptMethod.get(descriptor); if (scriptMethod == null) { LOG.error("Error retrieving scriptMethod - " + descriptor); } else { LOG.info("Executing script method - " + scriptMethod.toString()); try { Event eventSent = scriptMethod.execute(this); eventsSent.add(eventSent); Thread.sleep(waitTime); } catch (SecurityException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (NoSuchMethodException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (InterruptedException e) { LOG.error("Exception while sleeping", e); } } } return eventsSent; } }
|
EventReporter implements Publisher { public List<Event> runReportScript(String script, long waitTime) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List<Event> eventsSent = new ArrayList<Event>(); LOG.info("Wait time (ms): " + waitTime); String[] eventDescriptors = script.split(","); for (String descriptor : eventDescriptors) { GeneratorScriptMethod scriptMethod = GeneratorScriptMethod.get(descriptor); if (scriptMethod == null) { LOG.error("Error retrieving scriptMethod - " + descriptor); } else { LOG.info("Executing script method - " + scriptMethod.toString()); try { Event eventSent = scriptMethod.execute(this); eventsSent.add(eventSent); Thread.sleep(waitTime); } catch (SecurityException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (NoSuchMethodException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (InterruptedException e) { LOG.error("Exception while sleeping", e); } } } return eventsSent; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public List<Event> runReportScript(String script, long waitTime) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List<Event> eventsSent = new ArrayList<Event>(); LOG.info("Wait time (ms): " + waitTime); String[] eventDescriptors = script.split(","); for (String descriptor : eventDescriptors) { GeneratorScriptMethod scriptMethod = GeneratorScriptMethod.get(descriptor); if (scriptMethod == null) { LOG.error("Error retrieving scriptMethod - " + descriptor); } else { LOG.info("Executing script method - " + scriptMethod.toString()); try { Event eventSent = scriptMethod.execute(this); eventsSent.add(eventSent); Thread.sleep(waitTime); } catch (SecurityException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (NoSuchMethodException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (InterruptedException e) { LOG.error("Exception while sleeping", e); } } } return eventsSent; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public List<Event> runReportScript(String script, long waitTime) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { List<Event> eventsSent = new ArrayList<Event>(); LOG.info("Wait time (ms): " + waitTime); String[] eventDescriptors = script.split(","); for (String descriptor : eventDescriptors) { GeneratorScriptMethod scriptMethod = GeneratorScriptMethod.get(descriptor); if (scriptMethod == null) { LOG.error("Error retrieving scriptMethod - " + descriptor); } else { LOG.info("Executing script method - " + scriptMethod.toString()); try { Event eventSent = scriptMethod.execute(this); eventsSent.add(eventSent); Thread.sleep(waitTime); } catch (SecurityException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (NoSuchMethodException e) { LOG.error("Failed to execute method for descriptor " + descriptor, e); } catch (InterruptedException e) { LOG.error("Exception while sleeping", e); } } } return eventsSent; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportLeaInfoEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = LEAInfo.class; String expectedId = SifEntityGenerator.TEST_LEAINFO_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportLeaInfoEvent(eventAction); LEAInfo dataObject = (LEAInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("http: eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportLeaInfoEvent(eventAction); dataObject = (LEAInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals("http: eventAction = EventAction.DELETE; sentEvent = eventReporter.reportLeaInfoEvent(eventAction); dataObject = (LEAInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("http: }
|
public Event reportLeaInfoEvent(EventAction action) throws ADKException { LOG.info("LeaInfo " + action.toString()); LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); if (action == EventAction.CHANGE) { leaInfo.setChanged(); leaInfo.setLEAURL("http: } Event event = new Event(leaInfo, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportLeaInfoEvent(EventAction action) throws ADKException { LOG.info("LeaInfo " + action.toString()); LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); if (action == EventAction.CHANGE) { leaInfo.setChanged(); leaInfo.setLEAURL("http: } Event event = new Event(leaInfo, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportLeaInfoEvent(EventAction action) throws ADKException { LOG.info("LeaInfo " + action.toString()); LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); if (action == EventAction.CHANGE) { leaInfo.setChanged(); leaInfo.setLEAURL("http: } Event event = new Event(leaInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportLeaInfoEvent(EventAction action) throws ADKException { LOG.info("LeaInfo " + action.toString()); LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); if (action == EventAction.CHANGE) { leaInfo.setChanged(); leaInfo.setLEAURL("http: } Event event = new Event(leaInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportLeaInfoEvent(EventAction action) throws ADKException { LOG.info("LeaInfo " + action.toString()); LEAInfo leaInfo = SifEntityGenerator.generateTestLEAInfo(); if (action == EventAction.CHANGE) { leaInfo.setChanged(); leaInfo.setLEAURL("http: } Event event = new Event(leaInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportSchoolInfoEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = SchoolInfo.class; String expectedId = SifEntityGenerator.TEST_SCHOOLINFO_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportSchoolInfoEvent(eventAction); SchoolInfo dataObject = (SchoolInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("http: eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportSchoolInfoEvent(eventAction); dataObject = (SchoolInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals("http: eventAction = EventAction.DELETE; sentEvent = eventReporter.reportSchoolInfoEvent(eventAction); dataObject = (SchoolInfo) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("http: }
|
public Event reportSchoolInfoEvent(EventAction action) throws ADKException { LOG.info("SchoolInfo " + action.toString()); SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); if (action == EventAction.CHANGE) { schoolInfo.setChanged(); schoolInfo.setSchoolURL("http: } Event event = new Event(schoolInfo, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportSchoolInfoEvent(EventAction action) throws ADKException { LOG.info("SchoolInfo " + action.toString()); SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); if (action == EventAction.CHANGE) { schoolInfo.setChanged(); schoolInfo.setSchoolURL("http: } Event event = new Event(schoolInfo, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportSchoolInfoEvent(EventAction action) throws ADKException { LOG.info("SchoolInfo " + action.toString()); SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); if (action == EventAction.CHANGE) { schoolInfo.setChanged(); schoolInfo.setSchoolURL("http: } Event event = new Event(schoolInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportSchoolInfoEvent(EventAction action) throws ADKException { LOG.info("SchoolInfo " + action.toString()); SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); if (action == EventAction.CHANGE) { schoolInfo.setChanged(); schoolInfo.setSchoolURL("http: } Event event = new Event(schoolInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportSchoolInfoEvent(EventAction action) throws ADKException { LOG.info("SchoolInfo " + action.toString()); SchoolInfo schoolInfo = SifEntityGenerator.generateTestSchoolInfo(); if (action == EventAction.CHANGE) { schoolInfo.setChanged(); schoolInfo.setSchoolURL("http: } Event event = new Event(schoolInfo, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportStudentPersonalEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = StudentPersonal.class; String expectedId = SifEntityGenerator.TEST_STUDENTPERSONAL_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportStudentPersonalEvent(eventAction); StudentPersonal dataObject = (StudentPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNoUnknown.NO.getValue(), dataObject.getMigrant()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportStudentPersonalEvent(eventAction); dataObject = (StudentPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals(YesNoUnknown.UNKNOWN.getValue(), dataObject.getMigrant()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportStudentPersonalEvent(eventAction); dataObject = (StudentPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNoUnknown.NO.getValue(), dataObject.getMigrant()); }
|
public Event reportStudentPersonalEvent(EventAction action) throws ADKException { LOG.info("StudentPersonal " + action.toString()); StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); if (action == EventAction.CHANGE) { studentPersonal.setChanged(); studentPersonal.setMigrant(YesNoUnknown.UNKNOWN); } Event event = new Event(studentPersonal, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportStudentPersonalEvent(EventAction action) throws ADKException { LOG.info("StudentPersonal " + action.toString()); StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); if (action == EventAction.CHANGE) { studentPersonal.setChanged(); studentPersonal.setMigrant(YesNoUnknown.UNKNOWN); } Event event = new Event(studentPersonal, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportStudentPersonalEvent(EventAction action) throws ADKException { LOG.info("StudentPersonal " + action.toString()); StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); if (action == EventAction.CHANGE) { studentPersonal.setChanged(); studentPersonal.setMigrant(YesNoUnknown.UNKNOWN); } Event event = new Event(studentPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportStudentPersonalEvent(EventAction action) throws ADKException { LOG.info("StudentPersonal " + action.toString()); StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); if (action == EventAction.CHANGE) { studentPersonal.setChanged(); studentPersonal.setMigrant(YesNoUnknown.UNKNOWN); } Event event = new Event(studentPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportStudentPersonalEvent(EventAction action) throws ADKException { LOG.info("StudentPersonal " + action.toString()); StudentPersonal studentPersonal = SifEntityGenerator.generateTestStudentPersonal(); if (action == EventAction.CHANGE) { studentPersonal.setChanged(); studentPersonal.setMigrant(YesNoUnknown.UNKNOWN); } Event event = new Event(studentPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportStudentLeaRelationshipEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = StudentLEARelationship.class; String expectedId = SifEntityGenerator.TEST_STUDENTLEARELATIONSHIP_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportStudentLeaRelationshipEvent(eventAction); StudentLEARelationship dataObject = (StudentLEARelationship) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(GradeLevelCode._10.getValue(), dataObject.getGradeLevel().getCode()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportStudentLeaRelationshipEvent(eventAction); dataObject = (StudentLEARelationship) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals(GradeLevelCode._09.getValue(), dataObject.getGradeLevel().getCode()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportStudentLeaRelationshipEvent(eventAction); dataObject = (StudentLEARelationship) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(GradeLevelCode._10.getValue(), dataObject.getGradeLevel().getCode()); }
|
public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE) { studentLeaRelationship.setChanged(); studentLeaRelationship.setGradeLevel(GradeLevelCode._09); } Event event = new Event(studentLeaRelationship, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE) { studentLeaRelationship.setChanged(); studentLeaRelationship.setGradeLevel(GradeLevelCode._09); } Event event = new Event(studentLeaRelationship, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE) { studentLeaRelationship.setChanged(); studentLeaRelationship.setGradeLevel(GradeLevelCode._09); } Event event = new Event(studentLeaRelationship, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE) { studentLeaRelationship.setChanged(); studentLeaRelationship.setGradeLevel(GradeLevelCode._09); } Event event = new Event(studentLeaRelationship, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE) { studentLeaRelationship.setChanged(); studentLeaRelationship.setGradeLevel(GradeLevelCode._09); } Event event = new Event(studentLeaRelationship, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportStudentSchoolEnrollmentEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = StudentSchoolEnrollment.class; String expectedId = SifEntityGenerator.TEST_STUDENTSCHOOLENROLLMENT_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportStudentSchoolEnrollmentEvent(eventAction); StudentSchoolEnrollment dataObject = (StudentSchoolEnrollment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO.getValue(), dataObject.getExitType().getCode()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportStudentSchoolEnrollmentEvent(eventAction); dataObject = (StudentSchoolEnrollment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals(ExitTypeCode._1923_DIED_OR_INCAPACITATED.getValue(), dataObject.getExitType().getCode()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportStudentSchoolEnrollmentEvent(eventAction); dataObject = (StudentSchoolEnrollment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(ExitTypeCode._3502_NOT_ENROLLED_ELIGIBLE_TO.getValue(), dataObject.getExitType().getCode()); }
|
public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.CHANGE) { studentSchoolEnrollment.setChanged(); studentSchoolEnrollment.setExitType(ExitTypeCode._1923_DIED_OR_INCAPACITATED); } Event event = new Event(studentSchoolEnrollment, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.CHANGE) { studentSchoolEnrollment.setChanged(); studentSchoolEnrollment.setExitType(ExitTypeCode._1923_DIED_OR_INCAPACITATED); } Event event = new Event(studentSchoolEnrollment, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.CHANGE) { studentSchoolEnrollment.setChanged(); studentSchoolEnrollment.setExitType(ExitTypeCode._1923_DIED_OR_INCAPACITATED); } Event event = new Event(studentSchoolEnrollment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.CHANGE) { studentSchoolEnrollment.setChanged(); studentSchoolEnrollment.setExitType(ExitTypeCode._1923_DIED_OR_INCAPACITATED); } Event event = new Event(studentSchoolEnrollment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.CHANGE) { studentSchoolEnrollment.setChanged(); studentSchoolEnrollment.setExitType(ExitTypeCode._1923_DIED_OR_INCAPACITATED); } Event event = new Event(studentSchoolEnrollment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportStaffPersonalEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = StaffPersonal.class; String expectedId = SifEntityGenerator.TEST_STAFFPERSONAL_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportStaffPersonalEvent(eventAction); StaffPersonal dataObject = (StaffPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); String emailAddress = dataObject.getEmailList().get(0).getValue(); Assert.assertEquals("[email protected]", emailAddress); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportStaffPersonalEvent(eventAction); dataObject = (StaffPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); emailAddress = dataObject.getEmailList().get(0).getValue(); Assert.assertEquals("[email protected]", emailAddress); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportStaffPersonalEvent(eventAction); dataObject = (StaffPersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); emailAddress = dataObject.getEmailList().get(0).getValue(); Assert.assertEquals("[email protected]", emailAddress); }
|
public Event reportStaffPersonalEvent(EventAction action) throws ADKException { LOG.info("StaffPersonal " + action.toString()); StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); if (action == EventAction.CHANGE) { staffPersonal.setChanged(); staffPersonal.setEmailList(new EmailList(new Email(EmailType.PRIMARY, "[email protected]"))); } Event event = new Event(staffPersonal, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportStaffPersonalEvent(EventAction action) throws ADKException { LOG.info("StaffPersonal " + action.toString()); StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); if (action == EventAction.CHANGE) { staffPersonal.setChanged(); staffPersonal.setEmailList(new EmailList(new Email(EmailType.PRIMARY, "[email protected]"))); } Event event = new Event(staffPersonal, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportStaffPersonalEvent(EventAction action) throws ADKException { LOG.info("StaffPersonal " + action.toString()); StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); if (action == EventAction.CHANGE) { staffPersonal.setChanged(); staffPersonal.setEmailList(new EmailList(new Email(EmailType.PRIMARY, "[email protected]"))); } Event event = new Event(staffPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportStaffPersonalEvent(EventAction action) throws ADKException { LOG.info("StaffPersonal " + action.toString()); StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); if (action == EventAction.CHANGE) { staffPersonal.setChanged(); staffPersonal.setEmailList(new EmailList(new Email(EmailType.PRIMARY, "[email protected]"))); } Event event = new Event(staffPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportStaffPersonalEvent(EventAction action) throws ADKException { LOG.info("StaffPersonal " + action.toString()); StaffPersonal staffPersonal = SifEntityGenerator.generateTestStaffPersonal(); if (action == EventAction.CHANGE) { staffPersonal.setChanged(); staffPersonal.setEmailList(new EmailList(new Email(EmailType.PRIMARY, "[email protected]"))); } Event event = new Event(staffPersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportEmployeePersonalEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = EmployeePersonal.class; String expectedId = SifEntityGenerator.TEST_EMPLOYEEPERSONAL_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportEmployeePersonalEvent(eventAction); EmployeePersonal dataObject = (EmployeePersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); OtherId otherId = dataObject.getOtherIdList().get(0); Assert.assertEquals(OtherIdType.SOCIALSECURITY.getValue(), otherId.getType()); Assert.assertEquals("333333333", otherId.getValue()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportEmployeePersonalEvent(eventAction); dataObject = (EmployeePersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); otherId = dataObject.getOtherIdList().get(0); Assert.assertEquals(OtherIdType.CERTIFICATE.getValue(), otherId.getType()); Assert.assertEquals("certificate", otherId.getValue()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportEmployeePersonalEvent(eventAction); dataObject = (EmployeePersonal) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); otherId = dataObject.getOtherIdList().get(0); Assert.assertEquals(OtherIdType.SOCIALSECURITY.getValue(), otherId.getType()); Assert.assertEquals("333333333", otherId.getValue()); }
|
public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChanged(); employeePersonal.setOtherIdList(new HrOtherIdList(new OtherId(OtherIdType.CERTIFICATE, "certificate"))); } Event event = new Event(employeePersonal, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChanged(); employeePersonal.setOtherIdList(new HrOtherIdList(new OtherId(OtherIdType.CERTIFICATE, "certificate"))); } Event event = new Event(employeePersonal, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChanged(); employeePersonal.setOtherIdList(new HrOtherIdList(new OtherId(OtherIdType.CERTIFICATE, "certificate"))); } Event event = new Event(employeePersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChanged(); employeePersonal.setOtherIdList(new HrOtherIdList(new OtherId(OtherIdType.CERTIFICATE, "certificate"))); } Event event = new Event(employeePersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChanged(); employeePersonal.setOtherIdList(new HrOtherIdList(new OtherId(OtherIdType.CERTIFICATE, "certificate"))); } Event event = new Event(employeePersonal, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportStaffAssignmentEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = StaffAssignment.class; String expectedId = SifEntityGenerator.TEST_STAFFASSIGNMENT_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportStaffAssignmentEvent(eventAction); StaffAssignment dataObject = (StaffAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNo.YES.getValue(), dataObject.getPrimaryAssignment()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportStaffAssignmentEvent(eventAction); dataObject = (StaffAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals(YesNo.NO.getValue(), dataObject.getPrimaryAssignment()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportStaffAssignmentEvent(eventAction); dataObject = (StaffAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNo.YES.getValue(), dataObject.getPrimaryAssignment()); }
|
public Event reportStaffAssignmentEvent(EventAction action) throws ADKException { LOG.info("StaffAssignment " + action.toString()); StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); if (action == EventAction.CHANGE) { staffAssignment.setChanged(); staffAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(staffAssignment, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportStaffAssignmentEvent(EventAction action) throws ADKException { LOG.info("StaffAssignment " + action.toString()); StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); if (action == EventAction.CHANGE) { staffAssignment.setChanged(); staffAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(staffAssignment, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportStaffAssignmentEvent(EventAction action) throws ADKException { LOG.info("StaffAssignment " + action.toString()); StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); if (action == EventAction.CHANGE) { staffAssignment.setChanged(); staffAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(staffAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportStaffAssignmentEvent(EventAction action) throws ADKException { LOG.info("StaffAssignment " + action.toString()); StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); if (action == EventAction.CHANGE) { staffAssignment.setChanged(); staffAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(staffAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportStaffAssignmentEvent(EventAction action) throws ADKException { LOG.info("StaffAssignment " + action.toString()); StaffAssignment staffAssignment = SifEntityGenerator.generateTestStaffAssignment(); if (action == EventAction.CHANGE) { staffAssignment.setChanged(); staffAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(staffAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void runReportEmploymentRecordEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = EmploymentRecord.class; String expectedId = SifEntityGenerator.TEST_EMPLOYMENTRECORD_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportEmploymentRecordEvent(eventAction); EmploymentRecord dataObject = (EmploymentRecord) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("10", dataObject.getPositionNumber()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportEmploymentRecordEvent(eventAction); dataObject = (EmploymentRecord) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals("15", dataObject.getPositionNumber()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportEmploymentRecordEvent(eventAction); dataObject = (EmploymentRecord) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals("10", dataObject.getPositionNumber()); }
|
public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChanged(); employmentRecord.setPositionNumber("15"); } Event event = new Event(employmentRecord, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChanged(); employmentRecord.setPositionNumber("15"); } Event event = new Event(employmentRecord, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChanged(); employmentRecord.setPositionNumber("15"); } Event event = new Event(employmentRecord, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChanged(); employmentRecord.setPositionNumber("15"); } Event event = new Event(employmentRecord, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChanged(); employmentRecord.setPositionNumber("15"); } Event event = new Event(employmentRecord, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void testshouldExtractEntityBeforeAndAfterTreatment() { Map<String, Object> entityBody = new HashMap<String, Object>(); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2009-2010"); Entity attendance = Mockito.mock(Entity.class); Mockito.when(attendance.getType()).thenReturn(EntityNames.ATTENDANCE); Mockito.when(attendance.getBody()).thenReturn(entityBody); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); entityBody.clear(); List<Map<String, Object>> schoolYearAttendances = new ArrayList<Map<String, Object>>(); Map<String, Object> schoolYearAttendance = new HashMap<String, Object>(); schoolYearAttendance.put(ParameterConstants.SCHOOL_YEAR, "2009-2010"); schoolYearAttendances.add(schoolYearAttendance); entityBody.put("schoolYearAttendance", schoolYearAttendances); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2010-05-23", DateHelper.getDateTimeFormat()))); Assert.assertFalse(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2009-05-24", DateHelper.getDateTimeFormat()))); Assert.assertFalse(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2008-05-24", DateHelper.getDateTimeFormat()))); }
|
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); }
|
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); } }
|
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); } }
|
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); } @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
|
@Test public void runReportEmployeeAssignmentEventTests() throws ADKException { Class<? extends SIFDataObject> expectedClass = EmployeeAssignment.class; String expectedId = SifEntityGenerator.TEST_EMPLOYEEASSIGNMENT_REFID; EventAction eventAction = EventAction.ADD; Event sentEvent = eventReporter.reportEmployeeAssignmentEvent(eventAction); EmployeeAssignment dataObject = (EmployeeAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNo.YES.getValue(), dataObject.getPrimaryAssignment()); eventAction = EventAction.CHANGE; sentEvent = eventReporter.reportEmployeeAssignmentEvent(eventAction); dataObject = (EmployeeAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, true); Assert.assertEquals(YesNo.NO.getValue(), dataObject.getPrimaryAssignment()); eventAction = EventAction.DELETE; sentEvent = eventReporter.reportEmployeeAssignmentEvent(eventAction); dataObject = (EmployeeAssignment) runDataObjectEventTest(sentEvent, eventAction, expectedClass, expectedId, false); Assert.assertEquals(YesNo.YES.getValue(), dataObject.getPrimaryAssignment()); }
|
public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignment.setChanged(); employeeAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(employeeAssignment, action); zone.reportEvent(event); return event; }
|
EventReporter implements Publisher { public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignment.setChanged(); employeeAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(employeeAssignment, action); zone.reportEvent(event); return event; } }
|
EventReporter implements Publisher { public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignment.setChanged(); employeeAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(employeeAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignment.setChanged(); employeeAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(employeeAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignment.setChanged(); employeeAssignment.setPrimaryAssignment(YesNo.NO); } Event event = new Event(employeeAssignment, action); zone.reportEvent(event); return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void testReportEventValidFile() throws ADKException { URL url = getClass().getResource("/element_xml/StudentPersonal.xml"); String validFilename = url.getPath(); String eventActionStr = EventAction.ADD.toString(); Event event = eventReporter.reportEvent(validFilename, eventActionStr); Assert.assertNotNull(event); EventAction eventAction = event.getAction(); Assert.assertEquals(eventActionStr, eventAction.toString()); Mockito.verify(zone, Mockito.times(1)).reportEvent(Mockito.eq(event)); eventActionStr = EventAction.CHANGE.toString(); event = eventReporter.reportEvent(validFilename, eventActionStr); Assert.assertNotNull(event); eventAction = event.getAction(); Assert.assertEquals(eventActionStr, eventAction.toString()); Mockito.verify(zone, Mockito.times(1)).reportEvent(Mockito.eq(event)); eventActionStr = EventAction.DELETE.toString(); event = eventReporter.reportEvent(validFilename, eventActionStr); Assert.assertNotNull(event); eventAction = event.getAction(); Assert.assertEquals(eventActionStr, eventAction.toString()); Mockito.verify(zone, Mockito.times(1)).reportEvent(Mockito.eq(event)); Mockito.when(zone.isConnected()).thenReturn(false); event = eventReporter.reportEvent(validFilename, EventAction.ADD.toString()); Assert.assertNull(event); Mockito.verify(zone, Mockito.times(0)).reportEvent(Mockito.eq(event)); }
|
public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void testReportEventInvalidFile() throws ADKException { String invalidFilename = "doesntexist.xml"; Event event = eventReporter.reportEvent(invalidFilename, EventAction.ADD.toString()); Assert.assertNull(event); Mockito.verify(zone, Mockito.times(0)).reportEvent(Mockito.eq(event)); }
|
public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); }
|
EventReporter implements Publisher { public Event reportEvent(String messageFile, String eventAction) throws ADKException { Event event = CustomEventGenerator.generateEvent(messageFile, EventAction.valueOf(eventAction)); if (event == null) { LOG.error("Null event can not be reported"); return null; } if (zone.isConnected()) { zone.reportEvent(event); } else { LOG.error("Zone is not connected"); return null; } return event; } EventReporter(Zone zone); static void main(String[] args); List<Event> runReportScript(String script, long waitTime); Event reportLeaInfoEvent(EventAction action); Event reportSchoolInfoEvent(EventAction action); Event reportStudentPersonalEvent(EventAction action); Event reportStudentLeaRelationshipEvent(EventAction action); Event reportStudentSchoolEnrollmentEvent(EventAction action); Event reportStaffPersonalEvent(EventAction action); Event reportEmployeePersonalEvent(EventAction action); Event reportStaffAssignmentEvent(EventAction action); Event reportEmploymentRecordEvent(EventAction action); Event reportEmployeeAssignmentEvent(EventAction action); Event reportEvent(String messageFile, String eventAction); @Override void onRequest(DataObjectOutputStream out, Query query, Zone zone, MessageInfo info); static final Logger LOG; }
|
@Test public void testIsValid() { AbstractBlacklistStrategy strategy = new CharacterBlacklistStrategy(); List<String> badStringList = createBadStringList(); List<Character> badCharList = createCharacterListFromStringList(badStringList); strategy.setInputCollection(badStringList); strategy.init(); runTestLoop(badCharList, strategy, false); List<String> goodStringList = createGoodStringList(); List<Character> goodCharList = createCharacterListFromStringList(goodStringList); runTestLoop(goodCharList, strategy, true); }
|
@Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (char c : input.toCharArray()) { if (characterSet.contains(c)) { return false; } } return true; }
|
CharacterBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (char c : input.toCharArray()) { if (characterSet.contains(c)) { return false; } } return true; } }
|
CharacterBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (char c : input.toCharArray()) { if (characterSet.contains(c)) { return false; } } return true; } CharacterBlacklistStrategy(); }
|
CharacterBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (char c : input.toCharArray()) { if (characterSet.contains(c)) { return false; } } return true; } CharacterBlacklistStrategy(); @Override boolean isValid(String context, String input); }
|
CharacterBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (char c : input.toCharArray()) { if (characterSet.contains(c)) { return false; } } return true; } CharacterBlacklistStrategy(); @Override boolean isValid(String context, String input); }
|
@Test public void testIsValid() { AbstractBlacklistStrategy strategy = new RegexBlacklistStrategy(); List<String> badRegexStringList = createBadRegexStringList(); strategy.setInputCollection(badRegexStringList); strategy.init(); List<String> badStringList = createBadStringList(); runTestLoop(badStringList, strategy, false); List<String> goodStringList = createGoodStringList(); runTestLoop(goodStringList, strategy, true); }
|
@Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return false; } } return true; }
|
RegexBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return false; } } return true; } }
|
RegexBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return false; } } return true; } RegexBlacklistStrategy(); }
|
RegexBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return false; } } return true; } RegexBlacklistStrategy(); @Override boolean isValid(String context, String input); }
|
RegexBlacklistStrategy extends AbstractBlacklistStrategy { @Override public boolean isValid(String context, String input) { if (input == null) { return false; } for (Pattern pattern : patternList) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return false; } } return true; } RegexBlacklistStrategy(); @Override boolean isValid(String context, String input); }
|
@Test public void testGetSelfReferenceFields() { Entity srEntity = Mockito.mock(Entity.class); Mockito.when(srEntity.getType()).thenReturn(SELF_REFERENCE_COLLECTION); Entity nonSrEntity = Mockito.mock(Entity.class); Mockito.when(nonSrEntity.getType()).thenReturn(NON_SELF_REFERENCE_COLLECTION); String selfReferenceField = selfReferenceExtractor.getSelfReferenceFields(srEntity); Assert.assertEquals("field2", selfReferenceField); selfReferenceField = selfReferenceExtractor.getSelfReferenceFields(nonSrEntity); Assert.assertEquals(null, selfReferenceField); }
|
public String getSelfReferenceFields(Entity entity) { String selfReferenceField = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { selfReferenceField = getSelfReferenceFields(schema, ""); } } return selfReferenceField; }
|
SelfReferenceExtractor { public String getSelfReferenceFields(Entity entity) { String selfReferenceField = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { selfReferenceField = getSelfReferenceFields(schema, ""); } } return selfReferenceField; } }
|
SelfReferenceExtractor { public String getSelfReferenceFields(Entity entity) { String selfReferenceField = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { selfReferenceField = getSelfReferenceFields(schema, ""); } } return selfReferenceField; } }
|
SelfReferenceExtractor { public String getSelfReferenceFields(Entity entity) { String selfReferenceField = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { selfReferenceField = getSelfReferenceFields(schema, ""); } } return selfReferenceField; } String getSelfReferenceFields(Entity entity); Map<String, NeutralSchema> getSchemaFields(NeutralSchema schema); }
|
SelfReferenceExtractor { public String getSelfReferenceFields(Entity entity) { String selfReferenceField = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { selfReferenceField = getSelfReferenceFields(schema, ""); } } return selfReferenceField; } String getSelfReferenceFields(Entity entity); Map<String, NeutralSchema> getSchemaFields(NeutralSchema schema); }
|
@Test public void testTokenValidation() throws IllegalArgumentException { List<String> tokens = new ArrayList<String>(); tokens.add("validToken"); schema.getProperties().put(TokenSchema.TOKENS, tokens); String tokenEntity = "validToken"; assertTrue("Token entity validation failed", schema.validate(tokenEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }
|
@Test public void testTokenValidationFailure() throws IllegalArgumentException { List<String> tokens = new ArrayList<String>(); tokens.add("validToken"); schema.getProperties().put(TokenSchema.TOKENS, tokens); String tokenEntity = "invalidToken"; assertFalse("Expected TokenSchema invalid token validation failure did not succeed", schema.validate(tokenEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }
|
@Test public void testValidationOfBooleanFailure() { Boolean booleanEntity = true; assertFalse("Expected TokenSchema boolean validation failure did not succeed", schema.validate(booleanEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }
|
@Test public void testRetrieveDate() { Map<String, Object> body = new HashMap<String, Object>(); body.put(ParameterConstants.BEGIN_DATE, "01-01-01"); Entity studentProgramAssociation = new MongoEntity(EntityNames.STUDENT_PROGRAM_ASSOCIATION, body); Assert.assertEquals("01-01-01", EntityDateHelper.retrieveDate(studentProgramAssociation)); }
|
public static String retrieveDate(Entity entity) { return (String) entity.getBody().get(EntityDates.ENTITY_DATE_FIELDS.get(entity.getType())); }
|
EntityDateHelper { public static String retrieveDate(Entity entity) { return (String) entity.getBody().get(EntityDates.ENTITY_DATE_FIELDS.get(entity.getType())); } }
|
EntityDateHelper { public static String retrieveDate(Entity entity) { return (String) entity.getBody().get(EntityDates.ENTITY_DATE_FIELDS.get(entity.getType())); } }
|
EntityDateHelper { public static String retrieveDate(Entity entity) { return (String) entity.getBody().get(EntityDates.ENTITY_DATE_FIELDS.get(entity.getType())); } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
EntityDateHelper { public static String retrieveDate(Entity entity) { return (String) entity.getBody().get(EntityDates.ENTITY_DATE_FIELDS.get(entity.getType())); } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
@SuppressWarnings("unchecked") @Test public void testMapIdFieldKey() throws Exception { String[] fields = { "data.element.id" }; BSONObject elem = new BasicBSONObject("value", 7631); BSONObject data = new BasicBSONObject("element", elem); BSONObject entry = new BasicBSONObject("data", data); final BSONWritable entity = new BSONWritable(entry); IDMapper<IdFieldEmittableKey> mapper = new IDMapper<IdFieldEmittableKey>(); IDMapper<IdFieldEmittableKey>.Context context = Mockito.mock(IDMapper.Context.class); PowerMockito.when(context, "write", Matchers.any(EmittableKey.class), Matchers.any(BSONObject.class)).thenAnswer(new Answer<BSONObject>() { @Override public BSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); assertNotNull(args); assertEquals(args.length, 2); assertTrue(args[0] instanceof IdFieldEmittableKey); assertTrue(args[1] instanceof BSONWritable); IdFieldEmittableKey id = (IdFieldEmittableKey) args[0]; assertEquals(id.getIdField().toString(), "data.element.id"); Text idValue = id.getId(); assertEquals(Long.parseLong(idValue.toString()), 3697); BSONWritable e = (BSONWritable) args[1]; assertEquals(e, entity); return null; } }); IdFieldEmittableKey id = new IdFieldEmittableKey(); id.setFieldNames(fields); id.setId(new Text("3697")); mapper.map(id, entity, context); }
|
@Override public void map(T id, BSONWritable entity, Context context) throws IOException, InterruptedException { for (String field : idFields.values()) { BSONUtilities.removeField(entity, field); } context.write(id, entity); }
|
IDMapper extends Mapper<T, BSONWritable, T, BSONWritable> { @Override public void map(T id, BSONWritable entity, Context context) throws IOException, InterruptedException { for (String field : idFields.values()) { BSONUtilities.removeField(entity, field); } context.write(id, entity); } }
|
IDMapper extends Mapper<T, BSONWritable, T, BSONWritable> { @Override public void map(T id, BSONWritable entity, Context context) throws IOException, InterruptedException { for (String field : idFields.values()) { BSONUtilities.removeField(entity, field); } context.write(id, entity); } }
|
IDMapper extends Mapper<T, BSONWritable, T, BSONWritable> { @Override public void map(T id, BSONWritable entity, Context context) throws IOException, InterruptedException { for (String field : idFields.values()) { BSONUtilities.removeField(entity, field); } context.write(id, entity); } @Override void map(T id, BSONWritable entity, Context context); }
|
IDMapper extends Mapper<T, BSONWritable, T, BSONWritable> { @Override public void map(T id, BSONWritable entity, Context context) throws IOException, InterruptedException { for (String field : idFields.values()) { BSONUtilities.removeField(entity, field); } context.write(id, entity); } @Override void map(T id, BSONWritable entity, Context context); }
|
@Test public void testValidationOfIntegerFailure() { Integer integerEntity = 0; assertFalse("Expected TokenSchema integer validation failure did not succeed", schema.validate(integerEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }
|
@Test public void testValidationOfFloatFailure() { Float floatEntity = new Float(0); assertFalse("Expected TokenSchema float validation failure did not succeed", schema.validate(floatEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); }
|
TokenSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return addError(this.matchesToken(entity), fieldName, entity, getQuotedTokens(), ErrorType.ENUMERATION_MISMATCH, errors); } TokenSchema(); TokenSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override Object convert(Object value); static final String TOKENS; }
|
@Test public void testReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertTrue("Reference entity validation failed", spySchema.validate(REFERENCE_FIELDNAME, UUID, errors, repo)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
@Test public void testInvalidReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Invalid Reference entity validation failed", spySchema.validate(REFERENCE_FIELDNAME, "45679", errors, repo)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
@Test public void testNullReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Null reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, null, errors, repo)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
@Test public void testNonStringReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Non-string reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, new Integer(0), errors, repo)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
@Test public void testEmptyStringReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertFalse("Non-string reference should not be valid", spySchema.validate(REFERENCE_FIELDNAME, "", errors, repo)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
ReferenceSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValidReference = isValidReference(entity); if (!addError(isValidReference, fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } boolean found = false; String collectionType = getEntityType(); try { found = repo.exists(collectionType, (String) entity); } catch (Exception e) { LOG.error("Exception when looking up reference in repository. ", e); } if (!found) { LOG.debug("Broken reference in {}, {}, {}", new Object[] { entity, fieldName, errors }); addError(false, fieldName, entity, "Valid reference", ErrorType.REFERENTIAL_INFO_MISSING, errors); return false; } return true; } ReferenceSchema(String xsdType, SchemaRepository schemaRepository); @Override NeutralSchemaType getSchemaType(); String getEntityType(); @Override Object convert(Object value); }
|
@Test public void testConvert() throws Exception { long value = 10L; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Long); Long convertedInput = (Long) convertedValue; assertTrue(convertedInput.longValue() == value); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test(expected = IllegalArgumentException.class) public void testBadConvert() { this.schema.convert("INVALID INPUT"); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test public void testNonConvert() { Object convertedValue = this.schema.convert(12345L); assertTrue(convertedValue instanceof Long); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test public void testIsPastOrCurrentDateWithDate() { Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-05-23", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2011-05-23", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now(), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2012-11-11", DateTime.parse("2012-11-11T00:00:00"), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2012-11-11", DateTime.parse("2012-11-11T23:59:59.999"), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now().minusMillis(1), EntityNames.DISCIPLINE_INCIDENT)); DateTimeFormatter datefrmt = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral('-').appendMonthOfYear(2).appendLiteral('-').appendDayOfMonth(2).toFormatter(); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(datefrmt.print(DateTime.now().plusDays(1)), DateTime.now(), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now().minusDays(1), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(null, DateTime.parse("2012-11-11"), EntityNames.DISCIPLINE_INCIDENT)); }
|
public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
@Test public void testLongConverter() { long data = 12345L; int intData = (int) data; assertTrue("Failure returning same object", this.schema.convert(data).equals(data)); assertTrue("Failure parsing long from integer", this.schema.convert(intData).equals(data)); assertTrue("Failure parsing long data", this.schema.convert("" + data).equals(data)); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test(expected = IllegalArgumentException.class) public void testInvalidStringThrowsException() throws IllegalArgumentException { this.schema.convert("INVALID INPUT"); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test(expected = IllegalArgumentException.class) public void testUnsupportedObjectTypeThrowsException() throws IllegalArgumentException { this.schema.convert(new Object()); }
|
@Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value); }
|
@Test public void testStringValidation() throws IllegalArgumentException { String stringEntity = "test"; assertTrue("String entity validation failed", schema.validate(stringEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testValidationOfBooleanFailure() { Boolean booleanEntity = true; assertFalse("Expected StringSchema boolean validation failure did not succeed", schema.validate(booleanEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testValidationOfIntegerFailure() { Integer integerEntity = 0; assertFalse("Expected StringSchema integer validation failure did not succeed", schema.validate(integerEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testValidationOfFloatFailure() { Float floatEntity = new Float(0); assertFalse("Expected StringSchema float validation failure did not succeed", schema.validate(floatEntity)); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testRestrictions() { schema.getProperties().put(Restriction.MIN_LENGTH.getValue(), "2"); schema.getProperties().put(Restriction.MAX_LENGTH.getValue(), "4"); assertTrue(schema.validate("12")); assertTrue(schema.validate("1234")); assertFalse(schema.validate("1")); assertFalse(schema.validate("12345")); schema.getProperties().put(Restriction.LENGTH.getValue(), "4"); assertTrue(schema.validate("1234")); assertFalse(schema.validate("123")); assertFalse(schema.validate("12345")); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testStrictBlacklist() { AppInfo info = Mockito.mock(AppInfo.class); Mockito.when(info.isRelaxedBlacklisted()).thenReturn(false); Mockito.when(info.getType()).thenReturn(AnnotationType.APPINFO); AbstractBlacklistStrategy mockStrictStrategy = Mockito.mock(AbstractBlacklistStrategy.class); Mockito.when(mockStrictStrategy.isValid(Mockito.anyString(), Mockito.eq("input1"))).thenReturn(true); Mockito.when(mockStrictStrategy.isValid(Mockito.anyString(), Mockito.eq("input2"))).thenReturn(false); AbstractBlacklistStrategy mockRelaxedStrategy = Mockito.mock(AbstractBlacklistStrategy.class); Mockito.when(mockRelaxedStrategy.isValid(Mockito.anyString(), Mockito.eq("input2"))).thenReturn(true); Mockito.when(mockRelaxedStrategy.isValid(Mockito.anyString(), Mockito.eq("input1"))).thenReturn(false); List<AbstractBlacklistStrategy> strictList = new ArrayList<AbstractBlacklistStrategy>(); strictList.add(mockStrictStrategy); List<AbstractBlacklistStrategy> relaxedList = new ArrayList<AbstractBlacklistStrategy>(); relaxedList.add(mockRelaxedStrategy); StringSchema testSchema = new StringSchema("string", strictList, relaxedList); testSchema.addAnnotation(info); assertFalse("Error in setup, schema should not be relax-blacklisted", testSchema.isRelaxedBlacklisted()); boolean isValid = testSchema.validate("input1"); assertTrue("Based on strict strategy, input1 should have passed validation", isValid); isValid = testSchema.validate("input2"); assertFalse("Based on strict strategy, input2 should have failed validation", isValid); Mockito.verify(mockRelaxedStrategy, Mockito.times(0)).isValid(Mockito.anyString(), Mockito.anyString()); Mockito.verify(mockStrictStrategy, Mockito.times(2)).isValid(Mockito.anyString(), Mockito.anyString()); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testRelaxedBlacklist() { AppInfo info = Mockito.mock(AppInfo.class); Mockito.when(info.isRelaxedBlacklisted()).thenReturn(true); Mockito.when(info.getType()).thenReturn(AnnotationType.APPINFO); AbstractBlacklistStrategy mockStrictStrategy = Mockito.mock(AbstractBlacklistStrategy.class); Mockito.when(mockStrictStrategy.isValid(Mockito.anyString(), Mockito.eq("input1"))).thenReturn(true); Mockito.when(mockStrictStrategy.isValid(Mockito.anyString(), Mockito.eq("input2"))).thenReturn(false); AbstractBlacklistStrategy mockRelaxedStrategy = Mockito.mock(AbstractBlacklistStrategy.class); Mockito.when(mockRelaxedStrategy.isValid(Mockito.anyString(), Mockito.eq("input2"))).thenReturn(true); Mockito.when(mockRelaxedStrategy.isValid(Mockito.anyString(), Mockito.eq("input1"))).thenReturn(false); List<AbstractBlacklistStrategy> strictList = new ArrayList<AbstractBlacklistStrategy>(); strictList.add(mockStrictStrategy); List<AbstractBlacklistStrategy> relaxedList = new ArrayList<AbstractBlacklistStrategy>(); relaxedList.add(mockRelaxedStrategy); StringSchema testSchema = new StringSchema("string", strictList, relaxedList); testSchema.addAnnotation(info); assertTrue("Error in setup, schema should be relax-blacklisted", testSchema.isRelaxedBlacklisted()); boolean isValid = testSchema.validate("input1"); assertFalse("Based on relaxed strategy, input1 should have failed validation", isValid); isValid = testSchema.validate("input2"); assertTrue("Based on relaxed strategy, input2 should have passed validation", isValid); Mockito.verify(mockRelaxedStrategy, Mockito.times(2)).isValid(Mockito.anyString(), Mockito.anyString()); Mockito.verify(mockStrictStrategy, Mockito.times(0)).isValid(Mockito.anyString(), Mockito.anyString()); }
|
@Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
StringSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { if (!addError(String.class.isInstance(entity), fieldName, entity, "String", ErrorType.INVALID_DATATYPE, errors)) { return false; } String data = (String) entity; if (this.getProperties() != null) { for (Entry<String, Object> entry : this.getProperties().entrySet()) { if (Restriction.isRestriction(entry.getKey())) { String restrictionValue = (String) entry.getValue(); switch (Restriction.fromValue(entry.getKey())) { case PATTERN: if (!addError(data.matches(restrictionValue), fieldName, entity, "pattern=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case LENGTH: if (!addError(data.length() == Integer.parseInt(restrictionValue), fieldName, entity, "length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MIN_LENGTH: if (!addError(data.length() >= Integer.parseInt(restrictionValue), fieldName, entity, "min-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; case MAX_LENGTH: if (!addError(data.length() <= Integer.parseInt(restrictionValue), fieldName, entity, "max-length=" + restrictionValue, ErrorType.INVALID_VALUE, errors)) { return false; } break; } } } } if (isRelaxedBlacklisted()) { for (AbstractBlacklistStrategy validationRule : relaxedValidationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by relaxed blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } else { for (AbstractBlacklistStrategy validationRule : validationRuleList) { boolean isValid = validationRule.isValid("StringSchemaContext", data); if (!addError(isValid, fieldName, entity, "Invalid value caught by strict blacklisting strategy: " + validationRule.getIdentifier(), ErrorType.INVALID_VALUE, errors)) { return false; } } } return true; } StringSchema(); StringSchema(String xsdType); StringSchema(List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); StringSchema(String xsdType, List<AbstractBlacklistStrategy> validationRuleList, List<AbstractBlacklistStrategy> relaxedValidationRuleList); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testIsPastOrCurrentDateWithYear() { DateTime dt = DateTime.now(); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-2011", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate((DateTime.now().getYear() - 1) + "-" + DateTime.now().getYear(), null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2011-2012", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2012-2013", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(DateTime.now().getYear() + "-" + (DateTime.now().getYear() + 1), null, EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(dt.getYear()-1 + "-" + dt.getYear(), null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(dt.getYear() + "-" + dt.getYear() + 1, null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2011-2012", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2012-2013", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-2009", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2008, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2009, 1, 1, 0, 0).minusMillis(1), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0).minusMillis(1), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2010-2011", new DateTime(2009, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2007-2008", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2008-2009", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); }
|
public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
|
@Test public void testRequiredValue() { ChoiceSchema choice = new ChoiceSchema(1, 1); choice.addField("aString", new StringSchema()); choice.addField("aLong", new LongSchema()); choice.addField("aDouble", new DoubleSchema()); Map<String, Object> data = new HashMap<String, Object>(); data.put("aString", "abc"); assertTrue(choice.validate(data)); data.put("aLong", 1L); assertFalse(choice.validate(data)); data.remove("aString"); assertTrue(choice.validate(data)); data.put("aLong", "abc"); assertFalse(choice.validate(data)); }
|
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); static final long UNBOUNDED; }
|
@Test public void testListValue() { ChoiceSchema choice = new ChoiceSchema(1, 5); choice.addField("aString", new StringSchema()); choice.addField("aLong", new LongSchema()); choice.addField("aDouble", new DoubleSchema()); List<Map<String, Object>> data = new ArrayList<Map<String, Object>>(); assertFalse(choice.validate(data)); data.add(createMap("aString", "abc")); assertTrue(choice.validate(data)); data.add(createMap("aLong", 1L)); assertTrue(choice.validate(data)); data.add(createMap("aDouble", 1.0D)); assertTrue(choice.validate(data)); data.add(createMap("aString", "def")); assertTrue(choice.validate(data)); data.add(createMap("invalid", "abc")); assertFalse(choice.validate(data)); data.remove(data.size() - 1); data.add(createMap("aString", "hij")); assertTrue(choice.validate(data)); data.add(createMap("aString", "hij")); assertFalse(choice.validate(data)); }
|
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); static final long UNBOUNDED; }
|
@Test public void testComplexSchemas() { ComplexSchema c1 = new ComplexSchema(); c1.addField("s1", new StringSchema()); c1.addField("l1", new LongSchema()); ComplexSchema c2 = new ComplexSchema(); c2.addField("s2", new StringSchema()); c2.addField("l2", new LongSchema()); ChoiceSchema choice = new ChoiceSchema(0, 1); choice.addField("c1", c1); choice.addField("c2", c2); choice.addField("s3", new StringSchema()); Map<String, Object> c1data = new HashMap<String, Object>(); c1data.put("s1", "abc"); c1data.put("l1", 1L); Map<String, Object> c2data = new HashMap<String, Object>(); c2data.put("s2", "efg"); c2data.put("l2", 1L); assertTrue(choice.validate(createMap("s3", "abc"))); assertTrue(choice.validate(createMap("c1", c1data))); assertTrue(choice.validate(createMap("c2", c2data))); assertFalse(choice.validate(createMap("c2", "abc"))); assertFalse(choice.validate(createMap("s3", c1data))); assertFalse(choice.validate(createMap("c1", c2data))); }
|
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); }
|
ChoiceSchema extends NeutralSchema { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected boolean validate(String fieldName, Object entity_in, List<ValidationError> errors, Repository<Entity> repo) { Object entity = entity_in; if (entity instanceof Set) { entity = new ArrayList<Object>((Set) entity); } if (getMaxOccurs() == 1) { if (getMinOccurs() == 0 && entity == null) { return true; } if (!(entity instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) entity; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (fieldSchema.validate(key, value, errors, repo)) { return true; } } else if (getMaxOccurs() > 1) { if (!(entity instanceof List)) { return addError(false, fieldName, entity, "List", ErrorType.INVALID_DATATYPE, errors); } if (((List) entity).size() < getMinOccurs()) { return addError(false, fieldName, entity, "min-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } else if (((List) entity).size() > getMaxOccurs()) { return addError(false, fieldName, entity, "max-length=" + this.getMinOccurs(), ErrorType.INVALID_VALUE, errors); } List<Object> data = (List<Object>) entity; for (Object uncastedDatum : data) { if (!(uncastedDatum instanceof Map)) { return addError(false, fieldName, entity, "Map", ErrorType.INVALID_DATATYPE, errors); } Map<?, ?> datum = (Map<?, ?>) uncastedDatum; if (datum.size() != 1) { return addError(false, fieldName, entity, "Single Entry", ErrorType.INVALID_DATATYPE, errors); } Entry<?, ?> datumValue = datum.entrySet().iterator().next(); if (!(datumValue.getKey() instanceof String)) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } String key = (String) datumValue.getKey(); Object value = datumValue.getValue(); NeutralSchema fieldSchema = this.getFields().get(key); if (fieldSchema == null) { return addError(false, fieldName, entity, this.getFields().keySet().toArray(new String[0]), ErrorType.INVALID_CHOICE_TYPE, errors); } if (!fieldSchema.validate(key, value, errors, repo)) { return false; } } return true; } return false; } ChoiceSchema(long minOccurs, long maxOccurs); ChoiceSchema(String name); void setMinOccurs(long i); void setMaxOccurs(long i); long getMinOccurs(); long getMaxOccurs(); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); @Override boolean isSimple(); static final long UNBOUNDED; }
|
@Test public void testDateTimeStringValidation() throws IllegalArgumentException { String dateTimeString = "2012-01-01T12:00:00-05:00"; assertTrue("DateTime entity validation failed", schema.validate(dateTimeString)); }
|
protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testDateTimeValidation() { Calendar calendar = Calendar.getInstance(); String dateTimeString = javax.xml.bind.DatatypeConverter.printTime(calendar); assertTrue("DateTime entity validation failed", schema.validate(dateTimeString)); }
|
protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testValidationOfStringFailure() { String stringEntity = ""; assertFalse("Expected DateTimeSchema string validation failure did not succeed", schema.validate(stringEntity)); }
|
protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
DateTimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDateTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } return addError(isValid, fieldName, entity, "RFC 3339 DateTime", ErrorType.INVALID_DATE_FORMAT, errors); } DateTimeSchema(); DateTimeSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override Object convert(Object value); }
|
@Test public void testGetNaturalKeyFields() throws NoNaturalKeysDefinedException { Entity e = setup(); Map<String, Boolean> naturalKeyFields = naturalKeyExtractor.getNaturalKeyFields(e); Assert.assertEquals(1, naturalKeyFields.size()); Assert.assertEquals("someField", naturalKeyFields.entrySet().iterator().next().getKey()); Mockito.verify(entitySchemaRegistry, Mockito.times(1)).getSchema(Mockito.anyString()); }
|
@Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; } }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; } }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; } @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity); }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, Boolean> getNaturalKeyFields(Entity entity) throws NoNaturalKeysDefinedException { Map<String, Boolean> naturalKeyFields = null; NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { if (appInfo.applyNaturalKeys()) { naturalKeyFields = new HashMap<String, Boolean>(); getNaturalKeyFields(naturalKeyFields, schema, false, ""); if (naturalKeyFields.isEmpty()) { LOG.error("Failed to find natural key definitions for the " + entity.getType() + " entity"); throw new NoNaturalKeysDefinedException(entity.getType()); } } } } return naturalKeyFields; } @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity); }
|
@Test public void testGetNaturalKeyDescriptor() throws NoNaturalKeysDefinedException { Entity e = setup(); TenantContext.setTenantId("someTenant"); NaturalKeyDescriptor desc = naturalKeyExtractor.getNaturalKeyDescriptor(e); Map<String, String> naturalKeys = desc.getNaturalKeys(); Assert.assertEquals(COLLECTION_TYPE, desc.getEntityType()); Assert.assertEquals("someTenant", desc.getTenantId()); Assert.assertEquals(1, naturalKeys.size()); Assert.assertEquals("someValue", naturalKeys.get("someField")); Mockito.verify(entitySchemaRegistry, Mockito.times(2)).getSchema(Mockito.anyString()); }
|
@Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeysNotNeeded(true); return naturalKeyDescriptor; } String entityType = getCollectionName(entity); String tenantId = TenantContext.getTenantId(); String parentId = retrieveParentId(entity); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(map, tenantId, entityType, parentId); return naturalKeyDescriptor; }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeysNotNeeded(true); return naturalKeyDescriptor; } String entityType = getCollectionName(entity); String tenantId = TenantContext.getTenantId(); String parentId = retrieveParentId(entity); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(map, tenantId, entityType, parentId); return naturalKeyDescriptor; } }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeysNotNeeded(true); return naturalKeyDescriptor; } String entityType = getCollectionName(entity); String tenantId = TenantContext.getTenantId(); String parentId = retrieveParentId(entity); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(map, tenantId, entityType, parentId); return naturalKeyDescriptor; } }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeysNotNeeded(true); return naturalKeyDescriptor; } String entityType = getCollectionName(entity); String tenantId = TenantContext.getTenantId(); String parentId = retrieveParentId(entity); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(map, tenantId, entityType, parentId); return naturalKeyDescriptor; } @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity); }
|
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeysNotNeeded(true); return naturalKeyDescriptor; } String entityType = getCollectionName(entity); String tenantId = TenantContext.getTenantId(); String parentId = retrieveParentId(entity); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(map, tenantId, entityType, parentId); return naturalKeyDescriptor; } @Override Map<String, String> getNaturalKeys(Entity entity); @Override Map<String, Boolean> getNaturalKeyFields(Entity entity); @Override NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity); String getCollectionName(Entity entity); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.