Update Junit Test classes
This commit is contained in:
parent
042fd7bdcf
commit
02f24df8a3
20 changed files with 242 additions and 481 deletions
|
|
@ -1,16 +1,15 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.imixs.workflow.FileData;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test generates random test data
|
||||
|
|
@ -20,46 +19,40 @@ import junit.framework.Assert;
|
|||
*/
|
||||
public class TestFTP {
|
||||
|
||||
|
||||
final static String FILE = "/DTVF_SKBeschrift_21010.csv";
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TestFTP.class.getName());
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Kreditoren import
|
||||
*/
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Test
|
||||
public void testPutFileToFTP() {
|
||||
|
||||
FTPConnector ftpc=new FTPConnector();
|
||||
|
||||
ftpc.ftpServer=Optional.ofNullable("u248962.your-storagebox.de");
|
||||
ftpc.ftpPort=Optional.ofNullable(21);
|
||||
ftpc.ftpUser=Optional.ofNullable("u248962-sub2");
|
||||
ftpc.ftpPassword=Optional.ofNullable("aXa61n9Un3jDNQlL");
|
||||
ftpc.ftpPath=Optional.ofNullable("/");
|
||||
|
||||
|
||||
|
||||
|
||||
FileData fileData=new FileData("test.txt","some data...".getBytes(),"text",null);
|
||||
|
||||
FTPConnector ftpc = new FTPConnector();
|
||||
|
||||
ftpc.ftpServer = Optional.ofNullable("u248962.your-storagebox.de");
|
||||
ftpc.ftpPort = Optional.ofNullable(21);
|
||||
ftpc.ftpUser = Optional.ofNullable("u248962-sub2");
|
||||
ftpc.ftpPassword = Optional.ofNullable("aXa61n9Un3jDNQlL");
|
||||
ftpc.ftpPath = Optional.ofNullable("/");
|
||||
|
||||
FileData fileData = new FileData("test.txt", "some data...".getBytes(), "text", null);
|
||||
try {
|
||||
ftpc.put(fileData);
|
||||
ftpc.put(fileData);
|
||||
logger.info("test finished...");
|
||||
} catch ( PluginException e) {
|
||||
|
||||
} catch (PluginException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
|
|
@ -12,10 +14,8 @@ 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;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test generates random test data
|
||||
|
|
@ -31,7 +31,7 @@ public class TestFormat {
|
|||
|
||||
private final static Logger logger = Logger.getLogger(TestFormat.class.getName());
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ public class TestFormat {
|
|||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -118,15 +118,15 @@ public class TestFormat {
|
|||
@Test
|
||||
public void testSMTPMailAddress() {
|
||||
|
||||
Assert.assertTrue(InvoiceUtil.validateEmail("info@imixs.com"));
|
||||
assertTrue(InvoiceUtil.validateEmail("info@imixs.com"));
|
||||
|
||||
Assert.assertFalse(InvoiceUtil.validateEmail("in fo@imixs.com"));
|
||||
assertFalse(InvoiceUtil.validateEmail("in fo@imixs.com"));
|
||||
|
||||
Assert.assertFalse(InvoiceUtil.validateEmail("SM PSP Queries <PSP.Queries@dssmith.com>"));
|
||||
assertFalse(InvoiceUtil.validateEmail("SM PSP Queries <PSP.Queries@dssmith.com>"));
|
||||
|
||||
Assert.assertTrue(InvoiceUtil.validateEmail("PSP.Queries@dssmith.com"));
|
||||
assertTrue(InvoiceUtil.validateEmail("PSP.Queries@dssmith.com"));
|
||||
|
||||
Assert.assertTrue(InvoiceUtil.validateEmail("accounts-sg@swiftmarine.global"));
|
||||
assertTrue(InvoiceUtil.validateEmail("accounts-sg@swiftmarine.global"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
|
@ -9,14 +13,13 @@ import org.imixs.archive.importer.DocumentImportService;
|
|||
import org.imixs.archive.importer.mail.IMAPBasicAuthenticator;
|
||||
import org.imixs.archive.importer.mail.IMAPOutlookAuthenticator;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.mail.Folder;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Store;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* This test class test the Imixs IMAPAuthenticator classes
|
||||
|
|
@ -52,8 +55,8 @@ public class TestIMAPAuhtenticators {
|
|||
logger.info("Connect started....");
|
||||
try {
|
||||
Store store = auth.openMessageStore(source, sourceOptions);
|
||||
Assert.assertNotNull(store);
|
||||
Assert.assertTrue(store.isConnected());
|
||||
assertNotNull(store);
|
||||
assertTrue(store.isConnected());
|
||||
logger.info("Connect OK");
|
||||
|
||||
// test open INBOX
|
||||
|
|
@ -65,7 +68,7 @@ public class TestIMAPAuhtenticators {
|
|||
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +98,8 @@ public class TestIMAPAuhtenticators {
|
|||
|
||||
try {
|
||||
Store store = auth.openMessageStore(source, sourceOptions);
|
||||
Assert.assertNotNull(store);
|
||||
Assert.assertTrue(store.isConnected());
|
||||
assertNotNull(store);
|
||||
assertTrue(store.isConnected());
|
||||
logger.info("Connect OK");
|
||||
|
||||
// test open INBOX
|
||||
|
|
@ -107,7 +110,7 @@ public class TestIMAPAuhtenticators {
|
|||
logger.log(Level.INFO, "... {0} new messages found", messages.length);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -137,8 +140,8 @@ public class TestIMAPAuhtenticators {
|
|||
|
||||
try {
|
||||
Store store = auth.openMessageStore(source, sourceOptions);
|
||||
Assert.assertNotNull(store);
|
||||
Assert.assertTrue(store.isConnected());
|
||||
assertNotNull(store);
|
||||
assertTrue(store.isConnected());
|
||||
logger.info("Connect OK");
|
||||
|
||||
// test open INBOX
|
||||
|
|
@ -149,7 +152,7 @@ public class TestIMAPAuhtenticators {
|
|||
logger.log(Level.INFO, "... {0} new messages found", messages.length);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +166,7 @@ public class TestIMAPAuhtenticators {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void testBasicAuthenticator() {
|
||||
|
||||
IMAPBasicAuthenticator auth = new IMAPBasicAuthenticator();
|
||||
|
|
@ -179,10 +182,10 @@ public class TestIMAPAuhtenticators {
|
|||
|
||||
try {
|
||||
Store store = auth.openMessageStore(source, sourceOptions);
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -18,8 +21,8 @@ import org.apache.http.impl.client.HttpClients;
|
|||
import org.apache.http.message.BasicHeader;
|
||||
import org.eclipse.angus.mail.imap.IMAPFolder;
|
||||
import org.imixs.archive.importer.mail.IMAPImportHelper;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
@ -35,7 +38,6 @@ import jakarta.mail.Session;
|
|||
import jakarta.mail.Store;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeUtility;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* This test shows how to access outlook via oauth2
|
||||
|
|
@ -68,9 +70,9 @@ public class TestIMAPOutlookOAuth {
|
|||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "imixs@alexander-logistics.com");
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -84,10 +86,10 @@ public class TestIMAPOutlookOAuth {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -96,16 +98,16 @@ public class TestIMAPOutlookOAuth {
|
|||
* Debug reading first mail....
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void TestMailboxImixsDebug() {
|
||||
Store store = null;
|
||||
String token = null;
|
||||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "imixs@alexander-logistics.com");
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -128,7 +130,7 @@ public class TestIMAPOutlookOAuth {
|
|||
subject = message.getSubject();
|
||||
} catch (MessagingException me) {
|
||||
System.out.println("...Failed to read message from inbox: " + me.getMessage());
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
System.out.println("......received mail from: " + fromAddress[0].toString());
|
||||
|
|
@ -177,10 +179,10 @@ public class TestIMAPOutlookOAuth {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -192,10 +194,10 @@ public class TestIMAPOutlookOAuth {
|
|||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "Imixsbhv@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -209,26 +211,26 @@ public class TestIMAPOutlookOAuth {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void TestMailboxImixsPL() {
|
||||
Store store = null;
|
||||
String token = null;
|
||||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "imixspl@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -252,7 +254,7 @@ public class TestIMAPOutlookOAuth {
|
|||
subject = message.getSubject();
|
||||
} catch (MessagingException me) {
|
||||
System.out.println("...Failed to read message from inbox: " + me.getMessage());
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
System.out.println("......received mail from: " + fromAddress[0].toString());
|
||||
|
|
@ -296,10 +298,10 @@ public class TestIMAPOutlookOAuth {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -311,10 +313,10 @@ public class TestIMAPOutlookOAuth {
|
|||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "Imixsae@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -328,10 +330,10 @@ public class TestIMAPOutlookOAuth {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -392,7 +394,7 @@ public class TestIMAPOutlookOAuth {
|
|||
e.printStackTrace(new PrintWriter(sw));
|
||||
String exceptionAsString = sw.toString();
|
||||
System.out.println(exceptionAsString);
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -28,15 +31,13 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.imixs.archive.importer.mail.IMAPImportHelper;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* This test shows how to access outlook via oauth2
|
||||
*
|
||||
|
|
@ -49,17 +50,17 @@ public class TestIMAPOutlookOAuthDebug {
|
|||
private static final String CLIENT_SECRET = "zzzzz";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void TestMailboxImixsPL() {
|
||||
Store store = null;
|
||||
String token = null;
|
||||
try {
|
||||
// try to connect...
|
||||
token = getAuthToken();
|
||||
Assert.assertNotNull(token);
|
||||
assertNotNull(token);
|
||||
store = connect(token, "imixspl@alexander-logistics.com");
|
||||
|
||||
Assert.assertNotNull(store);
|
||||
assertNotNull(store);
|
||||
|
||||
if (!store.isConnected()) {
|
||||
// not connected!
|
||||
|
|
@ -83,7 +84,7 @@ public class TestIMAPOutlookOAuthDebug {
|
|||
subject = message.getSubject();
|
||||
} catch (MessagingException me) {
|
||||
System.out.println("...Failed to read message from inbox: " + me.getMessage());
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
System.out.println("......received mail from: " + fromAddress[0].toString());
|
||||
|
|
@ -124,10 +125,10 @@ public class TestIMAPOutlookOAuthDebug {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -213,7 +214,7 @@ public class TestIMAPOutlookOAuthDebug {
|
|||
e.printStackTrace(new PrintWriter(sw));
|
||||
String exceptionAsString = sw.toString();
|
||||
System.out.println(exceptionAsString);
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test tests the InvoicePlugin isCargosoft method
|
||||
|
|
@ -19,13 +20,13 @@ public class TestModelMatcher {
|
|||
ItemCollection workitem = new ItemCollection();
|
||||
|
||||
workitem.setModelVersion("rechnungseingang-de-1.0");
|
||||
Assert.assertTrue(InvoicePlugin.isCargoRechnung(workitem));
|
||||
assertTrue(InvoicePlugin.isCargoRechnung(workitem));
|
||||
|
||||
workitem.setModelVersion("rechnungseingang-pl-1.2");
|
||||
Assert.assertTrue(InvoicePlugin.isCargoRechnung(workitem));
|
||||
assertTrue(InvoicePlugin.isCargoRechnung(workitem));
|
||||
|
||||
workitem.setModelVersion("rechnungseingang-sachrechnung-pl-1.2");
|
||||
Assert.assertFalse(InvoicePlugin.isCargoRechnung(workitem));
|
||||
assertFalse(InvoicePlugin.isCargoRechnung(workitem));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
|
|
@ -12,8 +12,8 @@ import java.time.temporal.IsoFields;
|
|||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Testen der KW Berechnung
|
||||
|
|
@ -27,7 +27,7 @@ public class TestOPListen {
|
|||
|
||||
private final static Logger logger = Logger.getLogger(TestOPListen.class.getName());
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.alexanderlogistics.datev.DatevCargosoftImportAdapter;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* This test generates random test data
|
||||
*
|
||||
|
|
@ -20,20 +21,20 @@ public class TestPostionsnummernRegex {
|
|||
@Test
|
||||
public void testPutFileToFTP() {
|
||||
|
||||
Assert.assertTrue("AA-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
Assert.assertFalse("aa-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
Assert.assertFalse("CC-BBC-1234-991 ".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
assertTrue("AA-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
assertFalse("aa-BBC-1234-991".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
assertFalse("CC-BBC-1234-991 ".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
|
||||
Assert.assertTrue("IM-ZEL-2101-005".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
assertTrue("IM-ZEL-2101-005".matches(InvoicePlugin.INVOICE_POSITIONS_PATTERN_DEFAULT));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCargoImportText() {
|
||||
|
||||
Assert.assertTrue("R3 EX-PRO-2208-054".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
Assert.assertTrue("R3 VP".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
Assert.assertFalse("R LA-HOL-2208-013".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
assertTrue("R3 EX-PRO-2208-054".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
assertTrue("R3 VP".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
assertFalse("R LA-HOL-2208-013".matches(DatevCargosoftImportAdapter.REGEX_IMPORTTEXTPATTERN));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,14 @@
|
|||
package com.alexanderlogistics;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
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;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test generates random test data
|
||||
|
|
@ -29,7 +24,7 @@ public class TestRunden {
|
|||
|
||||
private final static Logger logger = Logger.getLogger(TestFormat.class.getName());
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
}
|
||||
|
|
@ -39,16 +34,16 @@ public class TestRunden {
|
|||
double d1 = 915.1400000000001;
|
||||
double d2 = 915.1400000000002;
|
||||
|
||||
logger.info("d1="+d1);
|
||||
logger.info("d2="+d2);
|
||||
logger.info("d1=" + d1);
|
||||
logger.info("d2=" + d2);
|
||||
|
||||
logger.info("d1="+InvoiceUtil.round(d1));
|
||||
logger.info("d2="+InvoiceUtil.round(d2));
|
||||
logger.info("d1=" + InvoiceUtil.round(d1));
|
||||
logger.info("d2=" + InvoiceUtil.round(d2));
|
||||
|
||||
if (Math.abs(InvoiceUtil.round(d1)) > Math.abs(InvoiceUtil.round(d2))) {
|
||||
Assert.fail();
|
||||
}
|
||||
if (Math.abs(InvoiceUtil.round(d1)) > Math.abs(InvoiceUtil.round(d2))) {
|
||||
fail();
|
||||
}
|
||||
logger.info("Test erfolgreich");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.alexanderlogistics.migration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
|
|
@ -16,13 +19,11 @@ import org.imixs.melman.WorkflowClient;
|
|||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.datev.imports.DatevImportAdapter;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Deprecated
|
||||
public class DueDateBugfix {
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public class DueDateBugfix {
|
|||
String ps = "archive4imixs";
|
||||
String restAPI = "https://alexander-logistics.office-workflow.de/api";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException {
|
||||
// Init Workflow Client
|
||||
workflowCLient = new WorkflowClient(restAPI);
|
||||
|
|
@ -42,7 +43,7 @@ public class DueDateBugfix {
|
|||
} catch (RestAPIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -54,7 +55,7 @@ public class DueDateBugfix {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void fixe() {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
@ -105,7 +106,7 @@ public class DueDateBugfix {
|
|||
try {
|
||||
ClassLoader classLoader = this.getClass().getClassLoader();
|
||||
File inputFile = new File(classLoader.getResource(filename_input).getFile());
|
||||
Assert.assertTrue(inputFile.exists());
|
||||
assertTrue(inputFile.exists());
|
||||
fis = new FileInputStream(inputFile);
|
||||
DataInputStream in = new DataInputStream(fis);
|
||||
br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
|
|
@ -177,14 +178,14 @@ public class DueDateBugfix {
|
|||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.alexanderlogistics.migration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
|
|
@ -16,13 +19,11 @@ import org.imixs.melman.RestAPIException;
|
|||
import org.imixs.melman.WorkflowClient;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Deprecated
|
||||
public class MigrationMahnerAusziffern {
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ public class MigrationMahnerAusziffern {
|
|||
int notFound = 0;
|
||||
int count = 0;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException, RestAPIException {
|
||||
rechnungen = new ArrayList<Rechnung>();
|
||||
// Init Workflow Client
|
||||
|
|
@ -64,7 +65,7 @@ public class MigrationMahnerAusziffern {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void anlysiere() throws RestAPIException, PluginException {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
@ -78,7 +79,7 @@ public class MigrationMahnerAusziffern {
|
|||
try {
|
||||
ClassLoader classLoader = this.getClass().getClassLoader();
|
||||
File inputFile = new File(classLoader.getResource(filename_input).getFile());
|
||||
Assert.assertTrue(inputFile.exists());
|
||||
assertTrue(inputFile.exists());
|
||||
fis = new FileInputStream(inputFile);
|
||||
DataInputStream in = new DataInputStream(fis);
|
||||
br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
|
|
@ -86,7 +87,7 @@ public class MigrationMahnerAusziffern {
|
|||
// read the first line containing the field names
|
||||
String fieldnames = br.readLine();
|
||||
|
||||
Assert.assertTrue(fieldnames.contains("Kontonummer"));
|
||||
assertTrue(fieldnames.contains("Kontonummer"));
|
||||
|
||||
String line;
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ public class MigrationMahnerAusziffern {
|
|||
if (data.length != 90) {
|
||||
System.out.println("Fehlerhafte Daten in Zeile " + count);
|
||||
System.out.println(line);
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
analyzeLine(data, count);
|
||||
|
|
@ -115,14 +116,14 @@ public class MigrationMahnerAusziffern {
|
|||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.alexanderlogistics.migration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataInputStream;
|
||||
|
|
@ -12,13 +15,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Deprecated
|
||||
public class MigrationMahnerDatev {
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ public class MigrationMahnerDatev {
|
|||
List<String> rechnungsnummern = new ArrayList<String>();
|
||||
String WJ = "2022";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException {
|
||||
doppelteBuchungen = new ArrayList<String>();
|
||||
rechnungsnummern = new ArrayList<String>();
|
||||
|
|
@ -39,7 +40,7 @@ public class MigrationMahnerDatev {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void migriere() {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
@ -54,7 +55,7 @@ public class MigrationMahnerDatev {
|
|||
try {
|
||||
ClassLoader classLoader = this.getClass().getClassLoader();
|
||||
File inputFile = new File(classLoader.getResource(filename_input).getFile());
|
||||
Assert.assertTrue(inputFile.exists());
|
||||
assertTrue(inputFile.exists());
|
||||
fis = new FileInputStream(inputFile);
|
||||
DataInputStream in = new DataInputStream(fis);
|
||||
br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
|
|
@ -62,7 +63,7 @@ public class MigrationMahnerDatev {
|
|||
// read the first line containing the field names
|
||||
String fieldnames = br.readLine();
|
||||
|
||||
Assert.assertTrue(fieldnames.contains("Kontonummer"));
|
||||
assertTrue(fieldnames.contains("Kontonummer"));
|
||||
|
||||
// write output file...
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(filename_output));
|
||||
|
|
@ -83,7 +84,7 @@ public class MigrationMahnerDatev {
|
|||
if (data.length != 90) {
|
||||
System.out.println("Fehlerhafte Daten in Zeile " + count);
|
||||
System.out.println(line);
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
|
||||
String wj = data[3];
|
||||
|
|
@ -123,14 +124,14 @@ public class MigrationMahnerDatev {
|
|||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ import org.imixs.melman.RestAPIException;
|
|||
import org.imixs.melman.WorkflowClient;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Dieser Agent ordnet nachträglich Ausgangsrechnungen aus der Migraiton einem
|
||||
|
|
@ -23,7 +23,7 @@ import org.junit.Test;
|
|||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
@Disabled
|
||||
@Deprecated
|
||||
public class MigrationSpaceZuordnung {
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public class MigrationSpaceZuordnung {
|
|||
Map<String, List<String>> spacePosMappings = null;
|
||||
Map<String, String> spaceNames = null;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException, RestAPIException, UnsupportedEncodingException {
|
||||
|
||||
// Init Workflow Client
|
||||
|
|
@ -60,7 +60,7 @@ public class MigrationSpaceZuordnung {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void anlysiere() throws RestAPIException, PluginException, UnsupportedEncodingException {
|
||||
|
||||
System.out.println("***********************");
|
||||
|
|
|
|||
|
|
@ -1,105 +0,0 @@
|
|||
package com.alexanderlogistics.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.imixs.melman.RestAPIException;
|
||||
import org.keycloak.jose.jws.JWSInput;
|
||||
import org.keycloak.jose.jws.JWSInputException;
|
||||
import org.keycloak.representations.AccessToken;
|
||||
|
||||
import jakarta.ws.rs.client.ClientRequestContext;
|
||||
import jakarta.ws.rs.client.ClientRequestFilter;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
|
||||
/**
|
||||
* This RequestFilter performs a keycloak authentication.
|
||||
*
|
||||
*
|
||||
*
|
||||
* The client configuration is defined in a keycloak.json file as follows:
|
||||
*
|
||||
* {
|
||||
* "realm": "imixs-office-workflow",
|
||||
* "auth-server-url" : "https://my.keycloak.host/",
|
||||
* "resource" : "the clientid",
|
||||
* "credentials": {
|
||||
* "secret": "xxx"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @author rsoika
|
||||
*
|
||||
*/
|
||||
public class KeycloakAuthenticator implements ClientRequestFilter {
|
||||
|
||||
private String token = null;
|
||||
|
||||
public static final String KEYCLOAK_ENDPOINT = "keycloak.endpoint";
|
||||
public static final String KEYCLOAK_REALM = "keycloak.realm";
|
||||
public static final String KEYCLOAK_CLIENTID = "keycloak.clientid";
|
||||
public static final String KEYCLOAK_SECRET = "keycloak.secret";
|
||||
|
||||
private final static Logger logger = Logger.getLogger(KeycloakAuthenticator.class.getName());
|
||||
|
||||
// Keycloak
|
||||
String keycloakServer;
|
||||
String keycloakRealm;
|
||||
String keycloakClientId;
|
||||
String keycloakSecret;
|
||||
|
||||
/**
|
||||
* Creates a new FormAuthenticator based on a baseUri and a username, password.
|
||||
* The constructor post the user credentials to the endpoint /j_security_check
|
||||
* to receive a JSESSIONID.
|
||||
*
|
||||
* @param _baseUri
|
||||
* @param username
|
||||
* @param password
|
||||
* @throws RestAPIException
|
||||
*/
|
||||
public KeycloakAuthenticator(String token) throws RestAPIException {
|
||||
|
||||
this.token = token;
|
||||
|
||||
logger.info("token=" + token);
|
||||
|
||||
AccessToken accessToken;
|
||||
try {
|
||||
accessToken = new JWSInput(token).readJsonContent(AccessToken.class);
|
||||
logger.info("---email=" + accessToken.getEmail());
|
||||
|
||||
} catch (JWSInputException cause) {
|
||||
throw new IllegalArgumentException("Failed to deserialize token", cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* This filter method is called for each request. The method adds teh bearer
|
||||
* token into the header.
|
||||
*
|
||||
*/
|
||||
public void filter(ClientRequestContext requestContext) throws IOException {
|
||||
if (token != null && !"".equals(token)) {
|
||||
logger.info(" add authroization header....v2");
|
||||
// requestContext.getHeaders().add("Bearer", getToken());
|
||||
|
||||
// Authorization: bearer $TOKEN
|
||||
// requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, getToken());
|
||||
|
||||
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Bearer " + getToken());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,8 +5,9 @@ import java.util.logging.Logger;
|
|||
import org.imixs.melman.CookieAuthenticator;
|
||||
import org.imixs.melman.DocumentClient;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.oracle.truffle.api.library.ExportMessage.Ignore;
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ public class TestDataClient {
|
|||
String sessionID = "rMxsrGJwT2GOisKrjEcaI5kpny_DnWieEPbIUvH2.imixs-office-workflow-8c9795689-d62t5";
|
||||
String reportName = "Steuerbescheide";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException {
|
||||
// Create a Cookie object with a name and a value
|
||||
Cookie cookie = new Cookie.Builder("JSESSIONID")
|
||||
|
|
@ -53,6 +54,7 @@ public class TestDataClient {
|
|||
*
|
||||
*/
|
||||
@Test
|
||||
@Disabled
|
||||
public void testGetReportData() {
|
||||
|
||||
// Test access
|
||||
|
|
|
|||
|
|
@ -1,166 +0,0 @@
|
|||
package com.alexanderlogistics.rest;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.imixs.melman.RestAPIException;
|
||||
import org.imixs.melman.WorkflowClient;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.authorization.client.AuthzClient;
|
||||
import org.keycloak.authorization.client.Configuration;
|
||||
|
||||
import com.oracle.truffle.api.library.ExportMessage.Ignore;
|
||||
|
||||
import jakarta.ws.rs.client.Invocation;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Test to request data via keycloak authentication....
|
||||
*
|
||||
*
|
||||
* Curl Beispiel:
|
||||
* https://stackoverflow.com/questions/50256433/obtaining-an-access-token-via-curl
|
||||
*
|
||||
*
|
||||
* Beispiel:
|
||||
*
|
||||
* curl \
|
||||
* -d "client_id=imixs" \
|
||||
* -d "client_secret=O8YjWcoW2nxb7jIgBePBKMvoDLUruZ3V" \
|
||||
* -d "grant_type=client_credentials" \
|
||||
* "https://sso.alexander-logistics.office-workflow.de/realms/imixs-office-workflow/protocol/openid-connect/token"
|
||||
*
|
||||
*
|
||||
*
|
||||
* curl -X GET
|
||||
* "https://test.alexander-logistics.office-workflow.de/api/documents/xxxxxx" \
|
||||
* -H "Authorization: Bearer
|
||||
* eyJhbGciOiJSUzI1NiIsInR5cCIxxxxxxxxxxxxxlvPDoPf4l5w"
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* curl -c cookies.txt -b cookies.txt -v -H "Authorization: Bearer
|
||||
* eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJQT0g5Q0RPOUJjdGxEZFBVc3RlSzR4blVCM0VQNThKOENqaXdJb2hIUFRFIn0.eyJleHAiOjE3NDE2ODAwNDEsImlhdCI6MTc0MTY3OTc0MSwianRpIjoiMTJhZWMzZmItMDZlYy00ODY1LWI2MTAtYzBhNDczNjk1MWViIiwiaXNzIjoiaHR0cHM6Ly9zc28uYWxleGFuZGVyLWxvZ2lzdGljcy5vZmZpY2Utd29ya2Zsb3cuZGUvcmVhbG1zL2ltaXhzLW9mZmljZS13b3JrZmxvdyIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiIyYjAyMTJiMy0wMTE4LTQ1ZmMtYjJiOS05ZjM4MmUyODlkMDgiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJpbWl4cyIsInNlc3Npb25fc3RhdGUiOiI2MWVlZWEwYy01ODRiLTRhMTctYjg3ZC0zNGE0NzY5Mzg3YmYiLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbImh0dHBzOi8vdGVzdC5hbGV4YW5kZXItbG9naXN0aWNzLm9mZmljZS13b3JrZmxvdy5kZSJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1pbWl4cy1vZmZpY2Utd29ya2Zsb3ciLCJvZmZsaW5lX2FjY2VzcyIsIm9yZy5pbWl4cy5BQ0NFU1NMRVZFTC5BVVRIT1JBQ0NFU1MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsInNpZCI6IjYxZWVlYTBjLTU4NGItNGExNy1iODdkLTM0YTQ3NjkzODdiZiIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoiQW5uYSBNdXN0ZXJtYW5uIiwiZ3JvdXBzIjpbImRlZmF1bHQtcm9sZXMtaW1peHMtb2ZmaWNlLXdvcmtmbG93Iiwib2ZmbGluZV9hY2Nlc3MiLCJvcmcuaW1peHMuQUNDRVNTTEVWRUwuQVVUSE9SQUNDRVNTIiwidW1hX2F1dGhvcml6YXRpb24iXSwicHJlZmVycmVkX3VzZXJuYW1lIjoiYW5uYSIsImdpdmVuX25hbWUiOiJBbm5hIiwiZmFtaWx5X25hbWUiOiJNdXN0ZXJtYW5uIiwiZW1haWwiOiJhbm5hQGltaXhzLmNvbSJ9.oitC9iBQSBEtZl3b65nWOSCwJ3MQjS0ES_YYJ4faL4IKZ3hN2XLFOL1kjW_guDF7Rg1k7dYm2WRAyI-QH1oXit7ANW-Z4DBpC0lbwepOsE5a5trjospYFtiLX5STO0WZuosa3b8XV7-F97Ru8Atox2eOqbJ4M-E_swnBjVxHvwLYIJXUBkQM_VXiF0acmwmcIjgolOl-mTC0NnnBClsZzbPfWxz0Ds2lc2lsQZQVjEaJ0mrMw3XCmf7rNC1LmSu6oJ8yiZ2UPMkkXDIRq0KV-hQ2sBqdfZdr4yFdbszXHLL0bDJixeS8xkBRkB7c0JSAxAgDmML1Y8Iuc7NuV6mg8Q"
|
||||
* "https://test.alexander-logistics.office-workflow.de/api/documents/4eea4e54-be93-4297-9574-3a61e826b4f4"
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* curl POST \
|
||||
* -H "Content-Type: application/x-www-form-urlencoded" \
|
||||
* -d "grant_type=password" \
|
||||
* -d "client_id=imixs" \
|
||||
* -d "client_secret=O8YjWcoW2nxb7jIgBePBKMvoDLUruZ3V" \
|
||||
* -d "username=anna" \
|
||||
* -d "password=anna" \
|
||||
* "https://sso.alexander-logistics.office-workflow.de/realms/imixs-office-workflow/protocol/openid-connect/token"
|
||||
*
|
||||
*
|
||||
* curl -d 'client_id=imixs' -d 'username=anna' -d 'password=anna' -d
|
||||
* 'grant_type=password' -d 'client_secret=O8YjWcoW2nxb7jIgBePBKMvoDLUruZ3V' \
|
||||
* 'https://sso.alexander-logistics.office-workflow.de/realms/imixs-office-workflow/protocol/openid-connect/token'
|
||||
* | \
|
||||
* python -m json.tool
|
||||
*/
|
||||
@Ignore
|
||||
public class TestKeycloakClient {
|
||||
|
||||
private static Logger logger = Logger.getLogger(TestKeycloakClient.class.getName());
|
||||
|
||||
private static final String KEYCLOAK_TOKEN_URL = "https://sso.alexander-logistics.office-workflow.de/auth/realms/imixs-office-workflow/protocol/openid-connect/token";
|
||||
private static final String CLIENT_ID = "imixs";
|
||||
private static final String CLIENT_SECRET = "O8YjWcoW2nxb7jIgBePBKMvoDLUruZ3V";
|
||||
private static final String USERNAME = "anna";
|
||||
private static final String PASSWORD = "anna";
|
||||
|
||||
private String token = null;
|
||||
|
||||
@Before
|
||||
public void setup() throws PluginException {
|
||||
try {
|
||||
final Configuration configuration = new Configuration(
|
||||
"https://sso.alexander-logistics.office-workflow.de/",
|
||||
"imixs-office-workflow", // keycloak realm
|
||||
"imixs", // keycloak client
|
||||
Collections.singletonMap("secret", "O8YjWcoW2nxb7jIgBePBKMvoDLUruZ3V"),
|
||||
HttpClients.createDefault());
|
||||
|
||||
token = AuthzClient.create(configuration).obtainAccessToken("anna", "anna").getToken();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error: " + e.getMessage());
|
||||
|
||||
// "Could not obtain configuration from server
|
||||
// [https://sso.alexander-logistics.office-workflow.de/auth/realms/imixs-office-workflow/.well-known/uma2-configuration]."
|
||||
|
||||
// https://sso.alexander-logistics.office-workflow.de/realms/imixs-office-workflow/.well-known/openid-configuration
|
||||
|
||||
throw new IllegalArgumentException("Token can't be obtained", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token....
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testToken() {
|
||||
|
||||
System.out.println("Token = " + token);
|
||||
|
||||
String instanceEndpoint = "https://test.alexander-logistics.office-workflow.de/api/";
|
||||
|
||||
String requestUri = "documents/6df8a656-9188-48a3-a0e0-c3a6274a586a";
|
||||
|
||||
WorkflowClient documentClient = new WorkflowClient(instanceEndpoint);
|
||||
|
||||
KeycloakAuthenticator keycloakAuth;
|
||||
try {
|
||||
keycloakAuth = new KeycloakAuthenticator(token);
|
||||
|
||||
documentClient.registerClientRequestFilter(keycloakAuth);
|
||||
|
||||
WebTarget target = documentClient.getWebTarget(requestUri);
|
||||
|
||||
// Erstelle eine Invocation von der WebTarget
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
Invocation invocation = invocationBuilder.buildGet();
|
||||
|
||||
// Sende die Anfrage und erhalte die Antwort
|
||||
Response response = invocation.invoke();
|
||||
|
||||
// Überprüfe den Status der Antwort
|
||||
if (response.getStatus() == Response.Status.OK.getStatusCode()) {
|
||||
// Extrahiere den Inhalt der Antwort als String
|
||||
String responseBody = response.readEntity(String.class);
|
||||
|
||||
// Gib den Inhalt aus (z.B. auf der Konsole)
|
||||
System.out.println("Response Body: " + responseBody);
|
||||
} else {
|
||||
System.err.println("Fehler bei der Anfrage: " + response.getStatus());
|
||||
}
|
||||
|
||||
// Schließe die Response, um Ressourcen freizugeben
|
||||
response.close();
|
||||
|
||||
List<ItemCollection> result = documentClient.getCustomResource(requestUri);
|
||||
|
||||
logger.info(" result size = " + result.size());
|
||||
} catch (RestAPIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Assert.fail();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package com.alexanderlogistics.sepa;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Diese Klasse testet die SEPA XSLT Transformation
|
||||
|
|
@ -22,7 +22,7 @@ public class TestSEPATransform {
|
|||
|
||||
private static Logger logger = Logger.getLogger(TestSEPATransform.class.getName());
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws PluginException, ModelException {
|
||||
logger.info("setup test environment ...");
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class TestSEPATransform {
|
|||
try {
|
||||
XSLTester.transform(MODEL_PATH_XML, MODEL_PATH_XSL, "../reports/sepa/result_sepa01.xml");
|
||||
} catch (Exception e) {
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class TestSEPATransform {
|
|||
try {
|
||||
XSLTester.transform(MODEL_PATH_XML, MODEL_PATH_XSL, "../reports/sepa/result_sepa-pl.xml");
|
||||
} catch (Exception e) {
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.alexanderlogistics.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -17,14 +17,16 @@ import org.imixs.workflow.exceptions.AccessDeniedException;
|
|||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.ProcessingErrorException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import com.alexanderlogistics.InvoiceUtil;
|
||||
import com.alexanderlogistics.KreditorDebitorService;
|
||||
|
|
@ -37,7 +39,8 @@ import com.alexanderlogistics.mahnlauf.MahnlaufService;
|
|||
*
|
||||
* @author rsoika
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.WARN)
|
||||
public class EAkteImportTester {
|
||||
|
||||
@Spy
|
||||
|
|
@ -53,7 +56,7 @@ public class EAkteImportTester {
|
|||
@Mock
|
||||
private MahnlaufService mahnlaufService;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// Mock protected Methode 'alreadyImported' -> always false
|
||||
Mockito.when(service.alreadyImported(Mockito.anyString())).thenReturn(false);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.alexanderlogistics.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -17,14 +17,16 @@ import org.imixs.workflow.exceptions.AccessDeniedException;
|
|||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.imixs.workflow.exceptions.ProcessingErrorException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import com.alexanderlogistics.InvoiceUtil;
|
||||
import com.alexanderlogistics.KreditorDebitorService;
|
||||
|
|
@ -37,7 +39,8 @@ import com.alexanderlogistics.mahnlauf.MahnlaufService;
|
|||
*
|
||||
* @author rsoika
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.WARN)
|
||||
public class InvoiceImportTester {
|
||||
|
||||
@Spy
|
||||
|
|
@ -53,7 +56,7 @@ public class InvoiceImportTester {
|
|||
@Mock
|
||||
private MahnlaufService mahnlaufService;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// Mock protected Methode 'alreadyImported' -> always false
|
||||
Mockito.when(service.alreadyImported(Mockito.anyString())).thenReturn(false);
|
||||
|
|
|
|||
39
pom.xml
39
pom.xml
|
|
@ -40,13 +40,16 @@
|
|||
<org.imixs.ai.version>1.1.1</org.imixs.ai.version>
|
||||
<custom.webResources>src/main/webapp</custom.webResources>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<junit.jupiter.version>5.9.2</junit.jupiter.version>
|
||||
<mockito.version>5.8.0</mockito.version>
|
||||
|
||||
<!-- Environment Settings -->
|
||||
<imixs-office.contextroot>/</imixs-office.contextroot>
|
||||
<imixs-office.realm>imixsrealm</imixs-office.realm>
|
||||
<imixs-office.jta-data-source>jdbc/office</imixs-office.jta-data-source>
|
||||
<imixs-office.IndexDir>lucene/office-index</imixs-office.IndexDir>
|
||||
<imixs-office.applicationname>office-alexander-logistics</imixs-office.applicationname>
|
||||
|
||||
<imixs-mail-res-ref-name>java:/mail/org.imixs.workflow.mail</imixs-mail-res-ref-name>
|
||||
|
||||
|
||||
|
|
@ -113,6 +116,12 @@
|
|||
<target>${java.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Testing JUnit 5 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
|
|
@ -269,19 +278,35 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit Tests -->
|
||||
<!-- Testing -->
|
||||
|
||||
<!-- JUnit 5 Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Mockito Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.8.0</version>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.parsson</groupId>
|
||||
<artifactId>jakarta.json</artifactId>
|
||||
|
|
|
|||
Loading…
Reference in a new issue