implemented first basic lists handling functions
This commit is contained in:
@ -0,0 +1,75 @@
|
||||
package de.muehlencord.shared.sharepoint.api.lists;
|
||||
|
||||
import de.muehlencord.shared.sharepoint.api.NtlmAuthenticator;
|
||||
import de.muehlencord.shared.sharepoint.api.SPContext;
|
||||
import de.muehlencord.shared.sharepoint.api.SPVersion;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class SPListTest {
|
||||
|
||||
public SPListTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSPList() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException, ParseException, JAXBException, SAXException,
|
||||
ParserConfigurationException, IOException {
|
||||
// Create NTLM v2 credentials (authenticator) & setup context
|
||||
|
||||
// FIXME - needs to be implemented using mock; replace with real data but make sure password is not commited
|
||||
NtlmAuthenticator credentials = null;
|
||||
SPContext context = null;
|
||||
// Connect to Sharepoint
|
||||
// SPSite instance = new SPSite(context);
|
||||
SPList instance = new SPList(context);
|
||||
// System.out.println (instance.getListNames());
|
||||
// System.out.println (instance.getListName("Test"));
|
||||
// instance.getListColumns(instance.getListName("Questionnaire Test"));
|
||||
|
||||
// Map<String, String> data = new HashMap<>();
|
||||
// data.put("Country", "DE");
|
||||
// data.put("WNRegion", "DACH");
|
||||
// data.put("AccountManager", "Jörn");
|
||||
// data.put("Customer", "Mühlencord");
|
||||
// data.put("Current OS", "Windows XP");
|
||||
// data.put("PlannedOS", "migrate to Windows 7");
|
||||
// data.put("RolloutStart", "in 2014");
|
||||
// data.put("RolloutEnd", "in 2015");
|
||||
// data.put("InstalledBase", "2000");
|
||||
// data.put("IbaseMigrated", "1000");
|
||||
// data.put("IbaseOrdered", "500");
|
||||
// data.put("IbaseNotOrdered", "500");
|
||||
// data.put("IbaseNotMigrated", "0");
|
||||
// data.put("ReaseonNotMigrated", "");
|
||||
// data.put("Platform", "ProBase/C");
|
||||
// data.put("IbaseOldPlatform", "0");
|
||||
// data.put("Application", "ProFlex4");
|
||||
// data.put("IbaseOldApplication", "0");
|
||||
// data.put("MaintenanceContract", "none");
|
||||
// data.put("Comments", "This is a test");
|
||||
// instance.addListItemByTitle("Questionnaire Test", data);
|
||||
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put ("Title", "Test");
|
||||
data.put ("Choice", "Enter Choice #1"); // is not check, possible to add wrong value
|
||||
// data.put ("Country", "DE"); // reference needed, need to implement lookup
|
||||
data.put ("Number", "17"); // is validating
|
||||
data.put ("Lines", "Long text<br>with line breaks"); // line breaks using <br>
|
||||
instance.addListItemByTitle("Test", data);
|
||||
}
|
||||
|
||||
}
|
||||
17
sharepoint/api/src/test/resources/BatchImportTest.xml
Normal file
17
sharepoint/api/src/test/resources/BatchImportTest.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Batch>
|
||||
<Method ID="1" Cmd="Update">
|
||||
<Field Name="ID">6</Field>
|
||||
<Field Name="Title">Modified sixth item</Field>
|
||||
</Method>
|
||||
<Method ID="2" Cmd="Update">
|
||||
<Field Name="ID">7</Field>
|
||||
<Field Name="Title">Modified seventh item</Field>
|
||||
</Method>
|
||||
<Method ID="3" Cmd="Delete">
|
||||
<Field Name="ID">5</Field>
|
||||
</Method>
|
||||
<Method ID="4" Cmd="New">
|
||||
<Field Name="Title">Added item</Field>
|
||||
</Method>
|
||||
</Batch>
|
||||
17
sharepoint/api/src/test/resources/BatchTest.xml
Normal file
17
sharepoint/api/src/test/resources/BatchTest.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Batch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='../../main/resources/xsd/batch.xsd'>
|
||||
<Method ID="1" Cmd="Update">
|
||||
<Field Name="ID">6</Field>
|
||||
<Field Name="Title">Modified sixth item</Field>
|
||||
</Method>
|
||||
<Method ID="2" Cmd="Update">
|
||||
<Field Name="ID">7</Field>
|
||||
<Field Name="Title">Modified seventh item</Field>
|
||||
</Method>
|
||||
<Method ID="3" Cmd="Delete">
|
||||
<Field Name="ID">5</Field>
|
||||
</Method>
|
||||
<Method ID="4" Cmd="New">
|
||||
<Field Name="Title">Added item</Field>
|
||||
</Method>
|
||||
</Batch>
|
||||
Reference in New Issue
Block a user