added support for users

enhanced list capabilities
This commit is contained in:
jomu
2015-02-04 21:33:27 +00:00
parent b77d6f69ba
commit 586191d078
13 changed files with 2453 additions and 66 deletions

View File

@ -11,6 +11,7 @@ import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
@ -35,18 +36,24 @@ public class SPListTest extends BaseTest {
IOException {
SPLists instance = new SPLists(context);
SPList list = instance.getSpListByTitle("Count");
SPList list = instance.getSpListByTitle("Test");
assertNotNull(list);
String listName = list.getListName();
assertEquals("Listname", "{D8C8D97E-1065-4674-A8F2-026D6D478794}", listName);
// get list of all country codes
java.util.List<String> columns = new ArrayList<>();
columns.add("Title");
columns.add("ID");
java.util.List<java.util.List<String>> countryCodes = list.getListItems(columns, "300");
Map<String, String> data = new HashMap<>();
data.put("Title", "Test");
data.put("Choice", "Enter Choice #1"); // is not checked, possible to add wrong value
data.put("Country", "357;#DE"); // reference taken from testGetLookupValuesMap
data.put("Number", "17"); // is validating
data.put("Lines", "Long text<br>with line breaks"); // line breaks using <br>
list.addListItem(listName, data);
list.addListItem(data);
}
@Test
@ -81,7 +88,7 @@ public class SPListTest extends BaseTest {
data.put(list.getColumnNameByDisplayName("IbaseOldApplication"), "0");
data.put(list.getColumnNameByDisplayName("MaintenanceContract"), "none");
data.put(list.getColumnNameByDisplayName("Comments"), "This is a test");
list.addListItem(listName, data);
list.addListItem(data);
}
@Test
@ -118,6 +125,13 @@ public class SPListTest extends BaseTest {
SPLists instance = new SPLists(context);
SPList list = instance.getSpListByTitle("Questionnaire");
assertEquals ("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS"));
}
@Test
@Ignore // Depends on available sharepoint currently
public void testGetItemCount() throws Exception {
SPLists instance = new SPLists(context);
SPList list = instance.getSpListByTitle("Questionnaire");
assertTrue (list.getItemCount() > 0);
}
}

View File

@ -0,0 +1,39 @@
package de.muehlencord.shared.sharepoint.api.usergroup;
import de.muehlencord.shared.sharepoint.api.BaseTest;
import static de.muehlencord.shared.sharepoint.api.BaseTest.readFileContentFromTest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Ignore;
import org.junit.Test;
/**
*
* @author joern.muehlencord
*/
public class SPUserGroupTest extends BaseTest {
@Test
public void testFromXML() throws Exception {
String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8");
SPUser user = new SPUser(context);
assertNotNull(xmlString);
user.setValue(xmlString);
}
@Test
@Ignore // Depends on available sharepoint currently
public void testGetUserInfo() throws Exception {
SPUserGroup ug = new SPUserGroup(context);
String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord");
assertEquals("Userid", "16", userId);
}
@Test
@Ignore // Depends on available sharepoint currently
public void testAddUserToGroup() throws Exception {
SPUserGroup ug = new SPUserGroup(context);
ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group");
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<User Email="Joern.Muehlencord@wincor-nixdorf.com" Flags="8" ID="16" IsDomainGroup="False" IsSiteAdmin="False" LoginName="i:0#.w|wincor-nixdorf\joern.muehlencord" Name="Muehlencord, Joern" Notes="" Sid="" xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"/>