OSSEZ-11 处理的测试类
This commit is contained in:
parent
72f46644b0
commit
dd1a7cd80b
47
core/pom.xml
47
core/pom.xml
@ -27,11 +27,6 @@
|
||||
|
||||
|
||||
<!-- DATABASE AND HIBERNATE -->
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>1.5.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-c3p0</artifactId>
|
||||
@ -63,52 +58,17 @@
|
||||
|
||||
|
||||
<!-- APACHE COMMONS -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-csv</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.2</version>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.3</version>
|
||||
</dependency>
|
||||
<!-- /APACHE COMMONS -->
|
||||
|
||||
@ -145,7 +105,7 @@
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.11.166</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--/CLOUDS -->
|
||||
|
||||
<dependency>
|
||||
@ -178,7 +138,6 @@
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-core</artifactId>
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF).
|
||||
*/
|
||||
package com.usvisatrack.core.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.filefilter.TrueFileFilter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.usvisatrack.core.common.Factory;
|
||||
import com.usvisatrack.core.dao.model.UscisForm;
|
||||
import com.usvisatrack.core.dao.model.UscisFormClassification;
|
||||
import com.usvisatrack.core.factories.UscisCaseFactory;
|
||||
import com.usvisatrack.core.factories.UscisFormFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public class ProcessingTimeTest extends TestCase {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ProcessingTimeTest.class);
|
||||
|
||||
@Before
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportFormClassification() throws Exception {
|
||||
List<File> files = (List<File>) FileUtils.listFiles(new File("D:\\uscis-form-processing-time\\2017-09"), TrueFileFilter.TRUE, null);
|
||||
|
||||
logger.debug("File Size - [{}]", files.size());
|
||||
|
||||
for (File file: files) {
|
||||
parseFormClassification(file);
|
||||
}
|
||||
// parseFormClassification ()
|
||||
}
|
||||
|
||||
private void parseFormClassification(File ProcessingTimeFile) throws Exception {
|
||||
logger.debug("Load from file to process form classification, Parse file - [{}]", ProcessingTimeFile.getName());
|
||||
|
||||
// CSVParser parser = CSVFormat.new CSVParser(new FileReader(fileName),
|
||||
// CSVFormat.EXCEL);
|
||||
|
||||
Iterable<CSVRecord> parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().withCommentMarker('#').withDelimiter(',')
|
||||
.parse(new FileReader(ProcessingTimeFile.getAbsolutePath()));
|
||||
|
||||
Date processDate = new Date();
|
||||
for (CSVRecord record : parser) {
|
||||
// IntegerValidator
|
||||
|
||||
String formCode = StringUtils.upperCase(record.get(0));
|
||||
String formClassificationTitle = StringUtils.trim(record.get(1));
|
||||
String formClassificationName = StringUtils.trim(record.get(2));
|
||||
|
||||
// logger.debug("FROM ID - {}", record.get(0));
|
||||
// logger.debug("FROM Title - {}", record.get(1));
|
||||
// logger.debug("FROM Classification - {}", record.get(2));
|
||||
// logger.debug("FROM Date - {}", record.get(3));
|
||||
|
||||
UscisForm uscisForm = UscisFormFactory.getUscisFormByCode(StringUtils.upperCase(record.get(0)));
|
||||
UscisFormClassification uscisFormClassification = UscisFormFactory.getUscisFormClassification(uscisForm,
|
||||
formClassificationTitle, formClassificationName);
|
||||
|
||||
if (uscisFormClassification != null) {
|
||||
// logger.debug("USCIS FORM CODE/NAME - [{}]/[{}]", uscisForm.getUscisFormCode(), formClassificationName);
|
||||
} else {
|
||||
uscisFormClassification = new UscisFormClassification();
|
||||
|
||||
uscisFormClassification.setUscisForm(uscisForm);
|
||||
uscisFormClassification.setUscisFormClassificationName(formClassificationName);
|
||||
uscisFormClassification.setUscisFormClassificationTitle(formClassificationTitle);
|
||||
|
||||
UscisFormFactory.save(uscisFormClassification);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user