src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
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.getOpt... | @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(Property... |
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, ... | @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", pro... |
DatelessExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { return true; } @Override boolean shouldExtract(Entity entity, DateTime upToDate); } | @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... |
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(",... | @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> addChangeDeleteEv... |
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 Even... | @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 = (... |
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: ... | @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... |
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(); s... | @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(even... |
EventReporter implements Publisher { public Event reportStudentLeaRelationshipEvent(EventAction action) throws ADKException { LOG.info("StudentLeaRelationship " + action.toString()); StudentLEARelationship studentLeaRelationship = SifEntityGenerator.generateTestStudentLeaRelationship(); if (action == EventAction.CHANGE... | @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.reportStud... |
EventReporter implements Publisher { public Event reportStudentSchoolEnrollmentEvent(EventAction action) throws ADKException { LOG.info("StudentSchoolEnrollment " + action.toString()); StudentSchoolEnrollment studentSchoolEnrollment = SifEntityGenerator.generateTestStudentSchoolEnrollment(); if (action == EventAction.C... | @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.reportS... |
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... | @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)... |
EventReporter implements Publisher { public Event reportEmployeePersonalEvent(EventAction action) throws ADKException { LOG.info("EmployeePersonal " + action.toString()); EmployeePersonal employeePersonal = SifEntityGenerator.generateTestEmployeePersonal(); if (action == EventAction.CHANGE) { employeePersonal.setChange... | @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(... |
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(); s... | @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(even... |
EventReporter implements Publisher { public Event reportEmploymentRecordEvent(EventAction action) throws ADKException { LOG.info("EmploymentRecord " + action.toString()); EmploymentRecord employmentRecord = SifEntityGenerator.generateTestEmploymentRecord(); if (action == EventAction.CHANGE) { employmentRecord.setChange... | @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(... |
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).... | @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... |
EventReporter implements Publisher { public Event reportEmployeeAssignmentEvent(EventAction action) throws ADKException { LOG.info("EmployeeAssignment " + action.toString()); EmployeeAssignment employeeAssignment = SifEntityGenerator.generateTestEmployeeAssignment(); if (action == EventAction.CHANGE) { employeeAssignme... | @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.reportEmployeeAssignme... |
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.isConnect... | @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(... |
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 isVal... | @Test public void testIsValid() { AbstractBlacklistStrategy strategy = new CharacterBlacklistStrategy(); List<String> badStringList = createBadStringList(); List<Character> badCharList = createCharacterListFromStringList(badStringList); strategy.setInputCollection(badStringList); strategy.init(); runTestLoop(badCharLis... |
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()... | @Test public void testIsValid() { AbstractBlacklistStrategy strategy = new RegexBlacklistStrategy(); List<String> badRegexStringList = createBadRegexStringList(); strategy.setInputCollection(badRegexStringList); strategy.init(); List<String> badStringList = createBadStringList(); runTestLoop(badStringList, strategy, fa... |
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... | @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... |
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(Strin... | @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)); }
@Tes... |
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 entity... | @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(studentPr... |
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, BSONWri... | @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 =... |
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)) { ... | @Test public void testReferenceValidation() throws IllegalArgumentException { List<ValidationError> errors = new ArrayList<ValidationError>(); assertTrue("Reference entity validation failed", spySchema.validate(REFERENCE_FIELDNAME, UUID, errors, repo)); }
@Test public void testInvalidReferenceValidation() throws Illega... |
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 (Num... | @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); }
@Test(expected = IllegalArgumentException.class) publi... |
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 isBefor... | @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", Da... |
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) en... | @Test public void testStringValidation() throws IllegalArgumentException { String stringEntity = "test"; assertTrue("String entity validation failed", schema.validate(stringEntity)); }
@Test public void testValidationOfBooleanFailure() { Boolean booleanEntity = true; assertFalse("Expected StringSchema boolean validatio... |
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... | @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"); assertTr... |
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; } r... | @Test public void testDateTimeStringValidation() throws IllegalArgumentException { String dateTimeString = "2012-01-01T12:00:00-05:00"; assertTrue("DateTime entity validation failed", schema.validate(dateTimeString)); }
@Test public void testDateTimeValidation() { Calendar calendar = Calendar.getInstance(); String date... |
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 appIn... | @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().getKe... |
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public NaturalKeyDescriptor getNaturalKeyDescriptor(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = getNaturalKeys(entity); if (map == null) { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKe... | @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, de... |
NaturalKeyExtractor implements INaturalKeyExtractor { @Override public Map<String, String> getNaturalKeys(Entity entity) throws NoNaturalKeysDefinedException { Map<String, String> map = new HashMap<String, String>(); List<String> missingKeys = new ArrayList<String>(); Map<String, Boolean> naturalKeyFields = getNaturalK... | @Test public void testGetNaturalKeys() throws NoNaturalKeysDefinedException { Entity e = setup(); Map<String, String> naturalKeys = naturalKeyExtractor.getNaturalKeys(e); Assert.assertEquals(1, naturalKeys.size()); Assert.assertEquals("someValue", naturalKeys.get("someField")); Mockito.verify(entitySchemaRegistry, Mock... |
EntityDateHelper { protected static boolean isBeforeOrEqualYear(String yearSpan, int upToYear) { int fromYear = Integer.parseInt(yearSpan.split("-")[0]); int toYear = Integer.parseInt(yearSpan.split("-")[1]); return ((upToYear >= toYear) && (upToYear > fromYear)); } static boolean shouldExtract(Entity entity, DateTime... | @Test public void testIsBeforeOrEqualYear() { Assert.assertTrue(EntityDateHelper.isBeforeOrEqualYear("2008-2009", 2011)); Assert.assertTrue(EntityDateHelper.isBeforeOrEqualYear("2008-2008", 2011)); Assert.assertTrue(EntityDateHelper.isBeforeOrEqualYear("2009-2008", 2011)); Assert.assertTrue(EntityDateHelper.isBeforeOrE... |
NaturalKeyExtractor implements INaturalKeyExtractor { public String getCollectionName(Entity entity) { NeutralSchema schema = entitySchemaRegistry.getSchema(entity.getType()); if (schema != null) { AppInfo appInfo = schema.getAppInfo(); if (appInfo != null) { return appInfo.getCollectionType(); } } LOG.error("No collec... | @Test public void shouldLookupEntityCollection() { Entity e = setup(); AppInfo mockAppInfo = Mockito.mock(AppInfo.class); mockSchema.addAnnotation(mockAppInfo); String collectionName = naturalKeyExtractor.getCollectionName(e); Assert.assertEquals(COLLECTION_TYPE, collectionName); } |
IntegerSchema extends PrimitiveNumericSchema<Integer> { @Override public Object convert(Object value) { if (value instanceof Integer) { return (Integer) value; } else if (value instanceof String) { try { return Integer.parseInt((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException)new I... | @Test public void testConvert() throws Exception { int value = 12345; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Integer); Integer convertedInput = (Integer) convertedValue; assertTrue(convertedInput.intValue() == value); }
@Test(expected = IllegalArgumentException.cla... |
SecurityEventUtil implements MessageSourceAware { public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + app... | @Test public void testSEValues() { SecurityEventUtil spyObject = Mockito.spy(securityEventUtil); SecurityEvent event = spyObject.createSecurityEvent("class", "Action Description", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0001); String appId = null; Mockito.verify(spyObject, Mockito.atMost(1)).createSecurityEven... |
BooleanSchema extends PrimitiveSchema { @Override public Object convert(Object value) { if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof String) { String stringData = (String) value; stringData = stringData.toLowerCase(); if (stringData.equals("true")) { return Boolean.TRUE; } else if... | @Test public void testConvert() throws Exception { boolean value = true; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Boolean); Boolean convertedInput = (Boolean) convertedValue; assertTrue(convertedInput.booleanValue() == value); }
@Test(expected = IllegalArgumentExcept... |
DateSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid; try { javax.xml.bind.DatatypeConverter.parseDate((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; }... | @Test public void testDateStringValidation() throws IllegalArgumentException { String dateString = "2012-01-01T12:00:00-05:00"; assertTrue("DateTime entity validation failed", schema.validate(dateString)); }
@Test public void testDateValidation() { Calendar calendar = Calendar.getInstance(); String dateString = javax.x... |
ListSchema extends NeutralSchema { public List<NeutralSchema> getList() { return list; } ListSchema(); ListSchema(String xsdType); @Override NeutralSchemaType getSchemaType(); @Override boolean isPrimitive(); void setList(List<NeutralSchema> list); List<NeutralSchema> getList(); @Override boolean isSimple(); void upda... | @Test public void testAnnotations() throws IllegalArgumentException { schema.clearFields(); complexSchema.clearFields(); AppInfo d = new AppInfo(null); d.put(AppInfo.READ_ENFORCEMENT_ELEMENT_NAME, new HashSet<String>(Arrays.asList(Right.READ_RESTRICTED.toString()))); complexSchema.addAnnotation(d); schema.getList().add... |
ListSchema extends NeutralSchema { @Override protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid = true; Object convertedEntity = convert(entity); if (convertedEntity instanceof Set) { convertedEntity = new ArrayList<Object>((Set) converte... | @Test public void testValidationOfBooleanFailure() { Boolean booleanEntity = true; assertFalse("Expected ListSchema boolean validation failure did not succeed", schema.validate(booleanEntity)); }
@Test public void testValidationOfIntegerFailure() { Integer integerEntity = 0; assertFalse("Expected ListSchema integer val... |
EdOrgExtractHelper implements InitializingBean { @SuppressWarnings("unchecked") public Set<String> getBulkExtractApps() { TenantContext.setIsSystemCall(true); Iterable<Entity> apps = repository.findAll("application", new NeutralQuery()); TenantContext.setIsSystemCall(false); Set<String> appIds = new HashSet<String>(); ... | @Test public void getBulkExtractAppsTest() { when(repository.findAll("application", new NeutralQuery())).thenReturn( Arrays.asList( buildAppEntity("1", true, true), buildAppEntity("2", false, false), buildAppEntity("3", true, false), buildAppEntity("4", false, true), buildAppEntity("5", true, true) ) ); Set<String> bul... |
TimeSchema extends NeutralSchema { protected boolean validate(String fieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { boolean isValid = false; try { javax.xml.bind.DatatypeConverter.parseTime((String) entity); isValid = true; } catch (IllegalArgumentException e2) { isValid = false; } r... | @Test public void testTimeStringValidation() throws IllegalArgumentException { String timeString = "12:00:00-05:00"; assertTrue("Time entity validation failed", schema.validate(timeString)); }
@Test public void testTimeValidation() { Calendar calendar = Calendar.getInstance(); String timeString = javax.xml.bind.Datatyp... |
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstanc... | @Test public void testGetValueOneLevel() { Map<String, Object> data = new HashMap<String, Object>(); data.put("key1", "value1"); data.put("key2", "value2"); data.put("key3", "value3"); assertEquals("Should match", "value1", apiNeutralSchemaValidator.getValue("key1", data)); assertEquals("Should match", "value2", apiNeu... |
DoubleSchema extends PrimitiveNumericSchema<Double> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).doubleValue(); } else if (value instanceof Long) { return ((Long) value).doubleValue(); } else if (value instanceof Float) { return ((Float) value).doubleValue()... | @Test public void testConvert() throws Exception { double value = 1.2; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Double); Double convertedInput = (Double) convertedValue; assertTrue(convertedInput.doubleValue() == value); }
@Test(expected = IllegalArgumentException.cl... |
EdOrgExtractHelper implements InitializingBean { public Map<String, Set<String>> getBulkExtractEdOrgsPerApp() { NeutralQuery appQuery = new NeutralQuery(new NeutralCriteria("applicationId", NeutralCriteria.CRITERIA_IN, getBulkExtractApps())); Iterable<Entity> apps = repository.findAll("applicationAuthorization", appQue... | @Test public void getBulkExtractEdOrgsPerAppTest() { getBulkExtractAppsTest(); Map<String, Object> edorg1 = new HashMap<String, Object>(); edorg1.put("authorizedEdorg", "edOrg1"); Map<String, Object> edorg2 = new HashMap<String, Object>(); edorg2.put("authorizedEdorg", "edOrg2"); @SuppressWarnings("unchecked") Entity a... |
ComplexSchema extends NeutralSchema { @Override protected boolean validate(String validateFieldName, Object entity, List<ValidationError> errors, Repository<Entity> repo) { return this.validate(validateFieldName, entity, errors, repo, true); } ComplexSchema(); ComplexSchema(String xsdType); @Override boolean isPrimiti... | @Test public void testComplexValidation() throws IllegalArgumentException { schema.clearFields(); schema.addField("booleanField", booleanSchema); schema.addField("longField", longSchema); schema.addField("doubleField", doubleSchema); schema.addField("stringField", stringSchema); schema.addField("tokenField", tokenSchem... |
Launcher { public void execute(String tenant, boolean isDelta) { audit(securityEventUtil.createSecurityEvent(Launcher.class.getName(), "Bulk extract execution", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0001)); Entity tenantEntity = bulkExtractMongoDA.getTenant(tenant); if (tenantEntity != null) { DateTime start... | @Test public void testInvalidTenant() { String tenantId = "testTenant"; Mockito.when(bulkExtractMongoDA.getTenant(tenantId)).thenReturn(null); launcher.execute(tenantId, false); Mockito.verify(localEdOrgExtractor, Mockito.never()).execute(Mockito.eq("tenant"), Mockito.any(File.class), Mockito.any(DateTime.class)); }
@T... |
SelfReferenceValidator { public boolean validate(Entity entity, List<ValidationError> errors) { String selfReferencePath = selfReferenceExtractor.getSelfReferenceFields(entity); if (selfReferencePath != null) { Map<String, Object> body = entity.getBody(); if (body != null) { String property = (String) body.get(selfRefe... | @Test public void testValidate() { Entity entity = Mockito.mock(Entity.class); Map<String, Object> body = new HashMap<String, Object>(); body.put(REFERENCE_FIELD, UUID); Mockito.when(entity.getBody()).thenReturn(body); Mockito.when(entity.getEntityId()).thenReturn(UUID); List<ValidationError> errors = new ArrayList<Val... |
NeutralQuery { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!exclu... | @Test public void testEquals() { String includeFields = "field1,field2"; String excludeFields = "field3,field4"; String sortBy = "field5"; int offset = 4; int limit = 5; NeutralQuery.SortOrder sortOrderAscending = NeutralQuery.SortOrder.ascending; NeutralQuery.SortOrder sortOrderDescending = NeutralQuery.SortOrder.desc... |
NeutralQuery { @Override public String toString() { return "NeutralQuery [includeFields=" + includeFields + ", excludeFields=" + excludeFields + ", offset=" + offset + ", limit=" + limit + ", sortBy=" + sortBy + ", sortOrder=" + sortOrder + ", queryCriteria=" + queryCriteria + ", orQueries=" + orQueries + "]"; } Neutra... | @Test public void testToString() { assertNotNull(new NeutralQuery().toString()); } |
NeutralCriteria { @Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc... | @Test public void testEqualsComparison() { NeutralCriteria neutralCriteria1 = new NeutralCriteria("key", "=", "value"); NeutralCriteria neutralCriteria2 = new NeutralCriteria("key", "=", "value"); NeutralCriteria neutralCriteria3 = new NeutralCriteria("differentKey", "=", "value"); NeutralCriteria neutralCriteria4 = ne... |
EdOrgHierarchyHelper { public Set<Entity> getAncestorsOfEdOrg(Entity entity) { if (isSEA(entity)) { return null; } Set<String> visitedIds = new HashSet<String>(); Set<Entity> ancestors = new HashSet<Entity>(); List<Entity> stack = new ArrayList<Entity>(10); ancestors.add(entity); stack.add(entity); while (!stack.isEmpt... | @Test public void testGetAncestorsOfEdOrgWithCycle() { Entity sea = buildEntityType(SEA); Entity lea = buildEntityType(LEA); Entity school = buildEntityType(SCHOOL); school.getBody().put(PARENT_ED_ORG_REF, Arrays.asList(lea.getEntityId())); lea.getBody().put(PARENT_ED_ORG_REF, Arrays.asList(sea.getEntityId(), school.ge... |
TypeResolver { public Set<String> resolveType(String type) { if (typeMaps.containsKey(type)) { return typeMaps.get(type); } return new HashSet<String>(Arrays.asList(type)); } Set<String> resolveType(String type); } | @Test public void educationOrganzationCollectionAlsoContainsSchools() { Set<String> types = resolver.resolveType("educationOrganization"); assertTrue(types.size() == 2); assertTrue(types.contains("school")); assertTrue(types.contains("educationOrganization")); types = resolver.resolveType("staff"); assertTrue(types.siz... |
EdOrgContextResolverFactory { public ContextResolver getResolver(String entityType) { return resolverMap.get(entityType); } ContextResolver getResolver(String entityType); } | @Test public void test() { assertNull(factory.getResolver("doesn't exist")); ContextResolver resolver = factory.getResolver("educationOrganization"); assertTrue(resolver instanceof SimpleEntityTypeContextResolver); }
@Test public void testStudentParent() { assertTrue(factory.getResolver("studentParentAssociation") inst... |
StaffTeacherDirectRelatedContextResolver extends RelatedContextResolver { @Override protected String getReferenceProperty(String entityType) { if (EntityNames.TEACHER_SCHOOL_ASSOCIATION.equals(entityType) || EntityNames.TEACHER_SECTION_ASSOCIATION.equals(entityType)) { return ParameterConstants.TEACHER_ID; } if (Entity... | @Test public void canResolveTeacherAndStaffRelatedEntities() { assertEquals(ParameterConstants.TEACHER_ID, resolver.getReferenceProperty(EntityNames.TEACHER_SCHOOL_ASSOCIATION)); assertEquals(ParameterConstants.TEACHER_ID, resolver.getReferenceProperty(EntityNames.TEACHER_SECTION_ASSOCIATION)); assertEquals(ParameterCo... |
StudentCompetencyContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { if (entity == null) { return Collections.emptySet(); } String studentSectionAssociationId = (String) entity.getBody().get(ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); Entity studentSect... | @Test public void noStudentSectionAssociation() { Entity studentCompetency = buildStudentCompetency(); when(repo.findById(EntityNames.STUDENT_SECTION_ASSOCIATION, "association123")).thenReturn(null); assertEquals(Collections.<String> emptySet(), underTest.findGoverningEdOrgs(studentCompetency)); }
@Test public void sho... |
CourseTranscriptContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentRe... | @Test public void returnEmptySetIfNoStudent() { Entity courseTranscript = buildCourseTranscript(); courseTranscript.getBody().remove(STUDENT_ID); courseTranscript.getBody().remove(STUDENT_ACADEMIC_RECORD_ID); assertEquals(Collections.emptySet(), underTest.findGoverningEdOrgs(courseTranscript)); }
@Test public void foll... |
GradebookEntryContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); Iterator<Entity> studentGradebookEntries = repo.findEach(EntityNames.STUDENT_GRADEBOOK_ENTRY, Query.query(Criteria.where("body.gradebookEntryId").is(en... | @Test public void test() { Entity gradebookEntry = Mockito.mock(Entity.class); Mockito.when(gradebookEntry.getEntityId()).thenReturn("123_id"); Mockito.when(gradebookEntry.getType()).thenReturn(EntityNames.GRADEBOOK_ENTRY); Entity sgbe1 = Mockito.mock(Entity.class); Map<String, Object> body1 = new HashMap<String, Objec... |
ParentContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> leas = new HashSet<String>(); Iterator<Entity> kids = repo.findEach(EntityNames.STUDENT, Query.query(Criteria.where(PATH_TO_PARENT).is(entity.getEntityId()))); while(kids.hasNext()) { Entity ... | @Test public void test() { Entity parent = mock(Entity.class); Entity kid1 = mock(Entity.class); when(kid1.getEntityId()).thenReturn("kid1"); Entity kid2 = mock(Entity.class); when(kid2.getEntityId()).thenReturn("kid2"); when(parent.getEntityId()).thenReturn("parentId"); when(repo.findEach(eq("student"), argThat(new Ba... |
LongValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new LongWritable(Long.parseLong(value.toString())); } } catch (NumberFormatExcepti... | @Test public void testGetValue() { BSONObject field = new BasicBSONObject("field", 123L); BSONObject entry = new BasicBSONObject("long", field); BSONWritable entity = new BSONWritable(entry); LongValueMapper mapper = new LongValueMapper("long.field"); Writable value = mapper.getValue(entity); assertFalse(value instance... |
RelatedContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { if (entity.getBody() == null) { return Collections.emptySet(); } String referredId = getReferredId(entity.getType(), entity.getBody()); if (referredId == null) { return Collections.emptySet(); } return ... | @Test public void testfindGoverningEdOrgs() { Mockito.when(mockEntity.getType()).thenReturn(EntityNames.TEACHER_SCHOOL_ASSOCIATION); Mockito.when(mockEntity.getBody()).thenReturn(body); Set<String> edOrgs = new HashSet<String>(Arrays.asList("springfieldElementary", "springfieldHigh")); Mockito.when(staffTeacherResolver... |
RelatedContextResolver implements ContextResolver { protected String getReferredId(String type, Map<String, Object> body) { String reference = getReferenceProperty(type); if (reference == null) { return null; } String referredId = (String) body.get(reference); return referredId; } RelatedContextResolver(); @Override Se... | @Test public void testgetReferredId() { assertTrue(resolver.getReferredId(EntityNames.TEACHER_SCHOOL_ASSOCIATION, body).equals(REFERRED_ID)); } |
DisciplineIncidentContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); Iterator<Entity> students = repo.findEach(EntityNames.STUDENT, Query.query(Criteria.where(DISCIPLINE_INCIDENT_ID).is(entity.getEntityId()))); while... | @Test public void testSingleStudent() { setFindEachReturn(Arrays.asList(student1)); Assert.assertEquals(new HashSet<String>(Arrays.asList("school1")), resolver.findGoverningEdOrgs(disciplineIncident)); }
@Test public void testMultipleStudents() { setFindEachReturn(Arrays.asList(student1, student2, student3)); Assert.as... |
DisciplineActionContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); List<String> studentIds = (List<String>) entity.getBody().get(ParameterConstants.STUDENT_ID); for(String studentId: studentIds){ edOrgs.addAll(studen... | @Test public void testSingleStudent() { Entity disciplineAction = Mockito.mock(Entity.class); Map<String, Object> body = new HashMap<String, Object>(); body.put(ParameterConstants.STUDENT_ID, Arrays.asList("student1")); Mockito.when(disciplineAction.getBody()).thenReturn(body); Mockito.when(studentResolver.findGovernin... |
AllPublicDataExtractor implements PublicDataExtractor { @Override public void extract(ExtractFile file) { extractor.setExtractionQuery(new NeutralQuery()); for (PublicEntityDefinition entity : PublicEntityDefinition.values()) { extractor.extractEntities(file, entity.getEntityName(), new Predicate<Entity>() { @Override ... | @Test public void testExtract() { publicDataExtractor.extract(file); for (PublicEntityDefinition definition : PublicEntityDefinition.values()) { Mockito.verify(extractor, Mockito.times(1)).extractEntities(Mockito.eq(file), Mockito.eq(definition.getEntityName()), Mockito.any(Predicate.class)); } } |
PublicDataFactory { public PublicDataExtractor buildAllPublicDataExtractor(EntityExtractor extractor) { return new AllPublicDataExtractor(extractor); } PublicDataExtractor buildAllPublicDataExtractor(EntityExtractor extractor); List<PublicDataExtractor> buildPublicDataExtracts(EntityExtractor extractor); } | @Test public void buildUnfilteredPublicDataExtractor() { Assert.assertTrue(factory.buildAllPublicDataExtractor(null) != null); Assert.assertTrue(factory.buildAllPublicDataExtractor(null).getClass() == AllPublicDataExtractor.class); } |
PublicDataFactory { public List<PublicDataExtractor> buildPublicDataExtracts(EntityExtractor extractor) { List<PublicDataExtractor> list = new ArrayList<PublicDataExtractor>(); list.add(buildAllPublicDataExtractor(extractor)); return list; } PublicDataExtractor buildAllPublicDataExtractor(EntityExtractor extractor); L... | @Test public void testBuildAllPublicDataExtracts() { Assert.assertTrue(factory.buildPublicDataExtracts(null) != null); List<PublicDataExtractor> extractors = factory.buildPublicDataExtracts(null); Assert.assertEquals(extractors.size(), 1); Assert.assertTrue(extractors.get(0).getClass() == AllPublicDataExtractor.class);... |
SectionEmbeddedDocsExtractor implements EntityDatedExtract { @SuppressWarnings("unchecked") @Override public void extractEntities(final EntityToEdOrgDateCache gradebookEntryCache) { Iterator<Entity> sections = this.repository.findEach(EntityNames.SECTION, new NeutralQuery()); while (sections.hasNext()) { Entity section... | @Test public void testExtractValidTSA() throws Exception { List<Entity> list = Arrays.asList(AccessibleVia.VALIDTSA.generate(), AccessibleVia.VALIDTSA.generate(), AccessibleVia.VALIDTSA.generate(), AccessibleVia.NONE.generate()); Mockito.when(repo.findEach(Mockito.eq(EntityNames.SECTION), Mockito.any(NeutralQuery.class... |
StudentGradebookEntryExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_GRADEBOOK_ENTRY, this.getClass().getName()); Iterator<Entity> studentGradebookEntries = repo.findEach(Entit... | @Test public void testExtractNoEntityBecauseOfIdMiss() { entityBody.put(ParameterConstants.STUDENT_ID, "studentId99"); Mockito.when(mockRepo.findEach(Mockito.eq("studentGradebookEntry"), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA"... |
YearlyTranscriptExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), ContainerEntityNames.YEARLY_TRANSCRIPT, this.getClass().getName()); Iterator<Entity> yearlyTranscripts = repo.findEach(Containe... | @Test public void testDoNotWriteDatedBasedEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(ContainerEntityNames.YEARLY_TRANSCRIPT), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); entityBody.put(ParameterConstants.SCHOOL_Y... |
ParentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache entityToEdorgCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.PARENT, this.getClass().getName()); Iterator<Entity> parents = repo.findEach(EntityNames.PARENT, new NeutralQuery()); Set<String> val... | @Test public void testWriteOneEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.PARENT), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity).iterator()); extractor.extractEntities(mockParentCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile)... |
StaffExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffToEdorgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF, this.getClass().getName()); Iterator<Entity> staffs = repo.findEach(EntityNames.STAFF, new NeutralQuery()); while (... | @Test public void testExtractOneEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaDateCache); Mockito.v... |
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext... | @Test public void testOneExtractedEntity() { Entity e = Mockito.mock(Entity.class); Mockito.when(mockRepo.findEach(Mockito.eq("student"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e).iterator()); Map<String, DateTime> datedEdorgs = new HashMap<String, DateTime>(); datedEdorgs.put("LEA", DateTime.now());... |
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (Ill... | @Test public void testGetValue() { BSONObject field = new BasicBSONObject("field", "TEST1"); BSONObject entry = new BasicBSONObject("enum", field); BSONWritable entity = new BSONWritable(entry); EnumValueMapper<Testing> m = new EnumValueMapper<Testing>("enum.field", Testing.class); Writable value = m.getValue(entity); ... |
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF... | @Test public void testExtractOneEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")... |
ExtractorFactory { public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventU... | @Test public void testBuildExtractFile() { Assert.assertTrue(factory.buildEdOrgExtractFile("bloop", "Bleep", "BLOO BLOO", null, null) != null); Assert.assertTrue(factory.buildEdOrgExtractFile("bloop", "Bleep", "BLOOB BLOO", null, null).getClass() == ExtractFile.class); } |
ExtractorFactory { public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extra... | @Test public void testBuildAttendanceExtractor() { Assert.assertTrue(factory.buildAttendanceExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildAttendanceExtractor(null, null, null, null).getClass() == AttendanceExtractor.class); } |
ExtractorFactory { public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); } StudentExtractor buildStude... | @Test public void testBuildStudentExtractor() { Assert.assertTrue(factory.buildStudentExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStudentExtractor(null, null, null, null).getClass() == StudentExtractor.class); } |
ExtractorFactory { public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityE... | @Test public void testBuildStudentAssessmentExtractor() { Assert.assertTrue(factory.buildStudentAssessmentExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStudentAssessmentExtractor(null, null, null, null).getClass() == StudentAssessmentExtractor.class); } |
ExtractorFactory { public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, Extr... | @Test public void testBuildStaffExtractor() { Assert.assertTrue(factory.buildStaffExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStaffExtractor(null, null, null, null).getClass() == StaffExtractor.class); } |
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String pare... | @Test public void testFetchCurrentParentsFromStudentNullChecks() { Map<String, List<Entity>> embeddedData = new HashMap<String, List<Entity>>(); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Mockito.when(mockEntity.getEmbeddedData()).thenReturn(embeddedData); Assert.assertTrue(helper... |
ExtractorHelper { public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntri... | @Test public void testBuildSubToParentEdOrgCache() { EntityToEdOrgCache cache = new EntityToEdOrgCache(); cache.addEntry("lea-1", "school-1"); cache.addEntry("lea-1", "school-2"); cache.addEntry("lea-1", "school-3"); cache.addEntry("lea-2", "school-4"); cache.addEntry("lea-2", "school-5"); cache.addEntry("lea-3", "scho... |
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_C... | @Test public void testExtractOneEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA"))... |
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while ... | @Test public void testWriteOneAttendance() { Mockito.when(mockRepo.findEach(Mockito.eq("attendance"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity).iterator()); entityBody.put("studentId", "student"); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2010-2011"); extractor.extractEntities(mockCac... |
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociatio... | @Test public void testTwoLeasOneStudent() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); edOrgDate.put("LEA-2", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Entity e = Mockito.mock(Entity.clas... |
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberForma... | @Test public void testGetValue() { BSONObject field = new BasicBSONObject("field", 1.312D); BSONObject entry = new BasicBSONObject("double", field); BSONWritable entity = new BSONWritable(entry); DoubleValueMapper mapper = new DoubleValueMapper("double.field"); Writable value = mapper.getValue(entity); assertFalse(valu... |
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId... | @Test public void testExtractDisciplineIncidentAndAction() { Entity da1 = createDisciplineAction("2009-01-01"); Entity da2 = createDisciplineAction("2010-02-13"); Mockito.when(repo.findEach(Mockito.eq("disciplineAction"), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(da1, da2).listIterator(0)); Entity di1 ... |
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUD... | @Test public void testWriteOneEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); extractor.extractEntities(mockStudentCache); Mockito.verify(m... |
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not... | @Test public void testAudit() { SecurityEvent securityEvent = new SecurityEvent(); securityEvent.setClassName(this.getClass().getName()); securityEvent.setLogMessage("Test Message"); securityEvent.setLogLevel(LogLevelType.TYPE_TRACE); audit(securityEvent); Mockito.verify(mockedEntityRepository, times(1)).create(any(Str... |
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName()... | @Test public void generateArchiveTest() throws Exception { String fileName = archiveFile.getFileName(testApp); archiveFile.generateArchive(); TarArchiveInputStream tarInputStream = null; List<String> names = new ArrayList<String>(); File decryptedFile = null; try { decryptedFile = decrypt(new File(fileName)); tarInputS... |
ErrorFile { public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); } ErrorFile(File parent); void logEntityError(Entity entity); File getFile(); static final String ERROR_FILE_NAME; } | @Test public void testErrorFile() throws IOException { File parentDir = new File("./"); parentDir.deleteOnExit(); ErrorFile error = new ErrorFile(parentDir); for (int i=0; i < 3; i++) { Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("TYPE" + i); error.logEntityError(entity); } Ent... |
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } Entity write(Entity entity, ExtractFile archiveFile); void writeDeleteFile(Entity entity, ExtractFile archiveFile); void setWriters(Defau... | @Test public void testWrite() { ExtractFile archiveFile = Mockito.mock(ExtractFile.class); JsonFileWriter jsonFile = Mockito.mock(JsonFileWriter.class); Mockito.when(archiveFile.getDataFileEntry(Mockito.anyString())).thenReturn(jsonFile); Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenRe... |
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) {... | @Test public void testWrite() { JsonFileWriter file = Mockito.mock(JsonFileWriter.class); ErrorFile errorFile = Mockito.mock(ErrorFile.class); Entity entity = Mockito.mock(Entity.class); Entity check = writer.write(entity, file, errorFile); Assert.assertEquals(treatedEntity, check); try { Mockito.verify(file, Mockito.t... |
BulkExtract { @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); f... | @Test public void testGetSampleExtract() throws Exception { injector.setEducatorContext(); ResponseImpl res = (ResponseImpl) bulkExtract.get(req); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")... |
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified());... | @Test public void testGetExtractResponse() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext context = new HttpRequestContextAdapter() { @Override public String getMethod() { return "GET"; } }; Response res = bulkExtract.getEd... |
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta b... | @Test public void testGetDelta() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockAppAuth(); Map<String, Object> body = new HashMap<String, Object>(); File f = File.createTempFile("bulkExtract", ".tar"); try { body.put(BulkExtract.BULK_EXTRACT_FILE_PATH, f.getAbsoluteP... |
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnab... | @Test public void testSEADelta() throws Exception { String edOrgId = "Midvale"; Map<String, Object> edOrgBody = new HashMap<String, Object>(); List<String> orgCategory = new ArrayList<String>(); orgCategory.add("State Education Agency"); edOrgBody.put("organizationCategories", orgCategory); Entity edOrg = new MongoEnti... |
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpt... | @Test(expected = AccessDeniedException.class) public void testAppIsNotAuthorizedForLea() throws Exception { injector.setEducatorContext(); Map<String, Object> body = new HashMap<String, Object>(); body.put("isBulkExtract", true); body.put("authorized_ed_orgs", Arrays.asList("ONE")); body.put("public_key", "KEY"); Entit... |
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Rece... | @Test(expected = AccessDeniedException.class) public void testGetSLEAListFalseAppAuth() throws Exception { injector.setEducatorContext(); Entity mockEntity = mockApplicationEntity(); mockEntity.getBody().put("isBulkExtract", false); bulkExtract.getBulkExtractList(req, CONTEXT); }
@Test(expected = AccessDeniedException.... |
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Tex... | @Test public void testToBSON() { IdFieldEmittableKey key = new IdFieldEmittableKey("test.id.key.field"); key.setId(new Text("1234")); BSONObject bson = key.toBSON(); assertNotNull(bson); assertTrue(bson.containsField("test.id.key.field")); Object obj = bson.get("test.id.key.field"); assertNotNull(obj); assertTrue(obj i... |
BulkExtract { @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context... | @Test public void testPublicExtract() throws IOException, ParseException { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); Entity mockedEntity = mockBulkExtractEntity(null); Mockito.when(edOrgHelper.byId(eq("ONE"))).thenReturn(mockedEntity); Response res = bulkExtract.getPublicExtract(CONTE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.