134 lines
3.8 KiB
Java
134 lines
3.8 KiB
Java
package com.alexanderlogistics;
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.logging.Logger;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import org.imixs.workflow.datev.imports.DatevImportAdapter;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
import junit.framework.Assert;
|
|
|
|
/**
|
|
* This test generates random test data
|
|
*
|
|
* @author rsoika
|
|
*
|
|
*/
|
|
public class TestFormat {
|
|
|
|
public static DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");
|
|
public static DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
public static DecimalFormat rateFormat = new DecimalFormat("0.000000");
|
|
|
|
private final static Logger logger = Logger.getLogger(TestFormat.class.getName());
|
|
|
|
@Before
|
|
public void setUp() throws Exception {
|
|
|
|
}
|
|
|
|
@Test
|
|
public void testBetrag() {
|
|
double total = 87547.09;
|
|
logger.info(decimalFormat.format(total));
|
|
total = 42.0;
|
|
logger.info(decimalFormat.format(total));
|
|
total = 0.5;
|
|
logger.info(decimalFormat.format(total));
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* 52329,42;"H";"EUR";0,000000;0,00;"";"8017";"14174";"";"0702";"191674";"";"";"R EX-GCA-2212-004";0;"";"";"";0;"";"";"";"Faelligkeit";"20230408";"";"";"";"";"";"";"Zahlungsbedingung";"08";"";"";"";"";"90";"";"";"DE815871706";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"SO";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";0;"01012023";""
|
|
|
|
*/
|
|
@Test
|
|
public void testDatum() {
|
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
|
|
String testDate="20230408";
|
|
try {
|
|
Date dateResult=dateFormatter.parse(testDate);
|
|
System.out.println("Result1 Date="+dateResult);
|
|
|
|
|
|
|
|
testDate=DatevImportAdapter.csvVal("20230408");
|
|
System.out.println("Result2 Date="+dateResult);
|
|
|
|
} catch (ParseException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
Assert.fail();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Test
|
|
public void testKurs() {
|
|
double kurs = 1.002118;
|
|
logger.info(rateFormat.format(kurs));
|
|
kurs = 777.0;
|
|
logger.info(rateFormat.format(kurs));
|
|
kurs = 0;
|
|
logger.info(rateFormat.format(kurs));
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testRegex() {
|
|
String text="RG-EX-SAL-2211-036";
|
|
String expr="\\bEX-SAL";
|
|
|
|
Pattern p = Pattern.compile(expr);
|
|
|
|
p = Pattern.compile(expr);
|
|
|
|
Matcher m = p.matcher(text);
|
|
if (m.find()) {
|
|
System.out.println("Ich bin ein Held");
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testRegex2() {
|
|
String text="R IM-GCA-2210-031";
|
|
String expr="\\bIM-GCA";
|
|
|
|
Pattern p = Pattern.compile(expr);
|
|
|
|
p = Pattern.compile(expr);
|
|
|
|
Matcher m = p.matcher(text);
|
|
if (m.find()) {
|
|
System.out.println("Ich bin ein Held");
|
|
} else {
|
|
System.out.println("Ich bin Kein Held");
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testSMTPMailAddress() {
|
|
|
|
Assert.assertTrue(InvoiceUtil.validateEmail("info@imixs.com"));
|
|
|
|
Assert.assertFalse(InvoiceUtil.validateEmail("in fo@imixs.com"));
|
|
|
|
Assert.assertFalse(InvoiceUtil.validateEmail("SM PSP Queries <PSP.Queries@dssmith.com>"));
|
|
|
|
Assert.assertTrue(InvoiceUtil.validateEmail("PSP.Queries@dssmith.com"));
|
|
|
|
Assert.assertTrue(InvoiceUtil.validateEmail("accounts-sg@swiftmarine.global"));
|
|
|
|
}
|
|
|
|
|
|
}
|