This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
878 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package edu.stanford; | ||
|
||
import org.junit.Test; | ||
|
||
import javax.xml.transform.*; | ||
import javax.xml.transform.stream.StreamResult; | ||
import javax.xml.transform.stream.StreamSource; | ||
import java.io.*; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class LibraryPatronTest { | ||
public File xslt_file = new File(getClass().getClassLoader().getResource("library_patron.xsl").getFile()); | ||
|
||
@Test | ||
public void hasActiveIDs() throws Exception { | ||
String symphony_user_rec = symphonyUserRecord(new File(this.getClass().getResource("/patron_one.xml").getFile())); | ||
File fixture_record = new File(this.getClass().getResource("/symph_user_one").getFile()); | ||
String filePath = fixture_record.getPath(); | ||
assertEquals(symphony_user_rec, fileToString(filePath)); | ||
} | ||
|
||
@Test | ||
public void hasBlankActiveIDs() throws Exception { | ||
String symphony_user_rec = symphonyUserRecord(new File(this.getClass().getResource("/patron_two.xml").getFile())); | ||
File fixture_record = new File(this.getClass().getResource("/symph_user_two").getFile()); | ||
String filePath = fixture_record.getPath(); | ||
assertEquals(symphony_user_rec, fileToString(filePath)); | ||
} | ||
|
||
@Test | ||
public void hasDisplayName() throws Exception { | ||
String symphony_user_rec = symphonyUserRecord(new File(this.getClass().getResource("/patron_three.xml").getFile())); | ||
File fixture_record = new File(this.getClass().getResource("/symph_user_three").getFile()); | ||
String filePath = fixture_record.getPath(); | ||
assertEquals(symphony_user_rec, fileToString(filePath)); | ||
} | ||
|
||
public Transformer libraryPatronTransformer(File xslt_file) { | ||
TransformerFactory factory = TransformerFactory.newInstance(); | ||
|
||
Source xslt = new StreamSource(xslt_file); | ||
Transformer transformer = null; | ||
try { | ||
transformer = factory.newTransformer(xslt); | ||
} catch (TransformerConfigurationException e) { | ||
e.printStackTrace(); | ||
} | ||
return transformer; | ||
} | ||
|
||
public String symphonyUserRecord(File personXmlFile) throws IOException, TransformerException { | ||
File patron_file = personXmlFile; | ||
Source text = new StreamSource(patron_file); | ||
StringWriter outWriter = new StringWriter(); | ||
libraryPatronTransformer(xslt_file).transform(text, new StreamResult(outWriter)); | ||
StringBuffer sb = outWriter.getBuffer(); | ||
return sb.toString(); | ||
} | ||
|
||
public String fileToString(String filePath) throws IOException { | ||
StringBuilder contentBuilder = new StringBuilder(); | ||
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { | ||
String sCurrentLine; | ||
while ((sCurrentLine = br.readLine()) != null) { | ||
contentBuilder.append(sCurrentLine).append("\n"); | ||
} | ||
} | ||
catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return contentBuilder.toString(); | ||
} | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE Person SYSTEM "http://registry.stanford.edu/xml/person/1.2/Person.dtd"> | ||
|
||
<Person card="806092551234567" listing="stanford" name="Lastname, Firstname" regid="12345" relationship="staff" source="registry" sunetid="mysunet" univid="000000000">IT Services, Application Administrator / Software Developer | ||
<name type="registered" visibility="none">Lastname, Firstname Y | ||
<first nval="firstname">Firstname</first> | ||
<middle nval="y">Y</middle> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<name type="display" visibility="stanford">Lastname, Firstname | ||
<first nval="firstname">Firstname</first> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<email type="primary" visibility="stanford">me@example.com | ||
<user>me</user> | ||
<host>example.com</host> | ||
</email> | ||
<place type="work"> | ||
<telephone type="work" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
<address type="work" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
</place> | ||
<affiliation affnum="1" effective="2018-10-01" organization="stanford" type="staff" visibility="stanford">Staff | ||
<department affnum="1">Hello World Services | ||
<organization adminid="HELLO" regid="12345">Hello World Services</organization> | ||
</department> | ||
<description affnum="1">Application Administrator / Software Developer</description> | ||
<affdata affnum="1" type="academic_council">NON-MEMBER</affdata> | ||
<affdata affnum="1" code="4822" type="job">Software Dvlpr 2</affdata> | ||
<affdata affnum="1" type="stdhrs">40</affdata> | ||
<affdata affnum="1" type="refid">0</affdata> | ||
<affdata affnum="1" type="jobtitle">Application Administrator / Software Developer</affdata> | ||
<place affnum="1" type="office"> | ||
<address affnum="1" type="office" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
<telephone affnum="1" type="office" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
</place> | ||
</affiliation> | ||
<identifier nval="000000000" type="univid" visibility="none">000000000</identifier> | ||
<identifier nval="campuscard/000000000" type="refid" visibility="none">campuscard/000000000</identifier> | ||
<identifier nval="012345" type="mobileid" visibility="none">012345</identifier> | ||
<identifier nval="806092551234567" type="card" visibility="none">806092551234567</identifier> | ||
<identifier nval="1234567" type="proximity" visibility="none">1234567</identifier> | ||
<identifier nval="mysunet" type="sunetid" visibility="stanford">mysunet</identifier> | ||
<privgroup>organization:sulair</privgroup> | ||
</Person> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE Person SYSTEM "http://registry.stanford.edu/xml/person/1.2/Person.dtd"> | ||
|
||
<Person card="806092551234567" listing="stanford" name="Lastname, Displayname" regid="12345" relationship="staff" source="registry" sunetid="mysunet" univid="001234567">IT Services, Application Administrator / Software Developer | ||
<name type="registered" visibility="none">Lastname, Registeredname Y | ||
<first nval="firstname">Registeredname</first> | ||
<middle nval="y">Y</middle> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<name type="display" visibility="stanford">Lastname, Displayname | ||
<first nval="firstname">Displayname</first> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<email type="primary" visibility="stanford">me@example.com | ||
<user>me</user> | ||
<host>example.com</host> | ||
</email> | ||
<place type="work"> | ||
<telephone type="work" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
<address type="work" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
</place> | ||
<affiliation affnum="1" effective="2018-10-01" organization="stanford" type="staff" visibility="stanford">Staff | ||
<department affnum="1">Hello World Services | ||
<organization adminid="HELLO" regid="12345">Hello World Services</organization> | ||
</department> | ||
<description affnum="1">Application Administrator / Software Developer</description> | ||
<affdata affnum="1" type="academic_council">NON-MEMBER</affdata> | ||
<affdata affnum="1" code="4822" type="job">Software Dvlpr 2</affdata> | ||
<affdata affnum="1" type="stdhrs">40</affdata> | ||
<affdata affnum="1" type="refid">0</affdata> | ||
<affdata affnum="1" type="jobtitle">Application Administrator / Software Developer</affdata> | ||
<place affnum="1" type="office"> | ||
<address affnum="1" type="office" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
<telephone affnum="1" type="office" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
</place> | ||
</affiliation> | ||
<identifier nval="001234567" type="univid" visibility="none">001234567</identifier> | ||
<identifier nval="campuscard/001234567" type="refid" visibility="none">campuscard/001234567</identifier> | ||
<identifier nval="806092551234567" type="card" visibility="none">806092551234567</identifier> | ||
<identifier nval="mysunet" type="sunetid" visibility="stanford">mysunet</identifier> | ||
<privgroup>organization:medicine</privgroup> | ||
</Person> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE Person SYSTEM "http://registry.stanford.edu/xml/person/1.2/Person.dtd"> | ||
|
||
<Person card="806092551234567" listing="stanford" name="Lastname, Firstname" regid="12345" relationship="staff" source="registry" sunetid="mysunet" univid="000000000">IT Services, Application Administrator / Software Developer | ||
<name type="registered" visibility="none">Lastname, Firstname Y | ||
<first nval="firstname">Firstname</first> | ||
<middle nval="y">Y</middle> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<name type="display" visibility="stanford">Lastname, Firstname | ||
<first nval="firstname">Firstname</first> | ||
<last nval="lastname">Lastname</last> | ||
</name> | ||
<email type="primary" visibility="stanford">me@example.com | ||
<user>me</user> | ||
<host>example.com</host> | ||
</email> | ||
<place type="work"> | ||
<telephone type="work" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
<address type="work" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
</place> | ||
<affiliation affnum="1" effective="2018-10-01" organization="stanford" type="staff" visibility="stanford">Staff | ||
<department affnum="1">Hello World Services | ||
<organization adminid="HELLO" regid="12345">Hello World Services</organization> | ||
</department> | ||
<description affnum="1">Application Administrator / Software Developer</description> | ||
<affdata affnum="1" type="academic_council">NON-MEMBER</affdata> | ||
<affdata affnum="1" code="4822" type="job">Software Dvlpr 2</affdata> | ||
<affdata affnum="1" type="stdhrs">40</affdata> | ||
<affdata affnum="1" type="refid">0</affdata> | ||
<affdata affnum="1" type="jobtitle">Application Administrator / Software Developer</affdata> | ||
<place affnum="1" type="office"> | ||
<address affnum="1" type="office" visibility="stanford">DLSS Lathrop 3rd Floor, 557 Escondido Mall, Mail Code 6069, Stanford, California 94305-6069 | ||
<line>DLSS Lathrop 3rd Floor</line> | ||
<line>557 Escondido Mall</line> | ||
<line>Mail Code 6069</line> | ||
<city>Stanford</city> | ||
<state code="CA">California</state> | ||
<postalcode>94305-6069</postalcode> | ||
<country alpha2="US" alpha3="USA" numeric="840">United States</country> | ||
</address> | ||
<telephone affnum="1" type="office" visibility="stanford">(111) 111-1111 | ||
<icc>1</icc> | ||
<area>111</area> | ||
<number>111-1111</number> | ||
</telephone> | ||
</place> | ||
</affiliation> | ||
<identifier nval="000000000" type="univid" visibility="none">000000000</identifier> | ||
<identifier nval="campuscard/000000000" type="refid" visibility="none">campuscard/000000000</identifier> | ||
<identifier nval="806092551234567" type="card" visibility="none">806092551234567</identifier> | ||
<identifier nval="mysunet" type="sunetid" visibility="stanford">mysunet</identifier> | ||
<privgroup>organization:sulair</privgroup> | ||
</Person> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.REC. | ||
*** DOCUMENT BOUNDARY *** | ||
FORM=LDUSER | ||
.USER_ID. |a2551234567 | ||
.USER_ALT_ID. |a000000000 | ||
.USER_NAME. |aLastname, Firstname Y | ||
.USER_FIRST_NAME. |aFirstname | ||
.USER_MIDDLE_NAME. |aY | ||
.USER_LAST_NAME. |aLastname | ||
.USER_ADDR1_BEGIN. | ||
.LINE1. |aDLSS Lathrop 3rd Floor 557 Escondido Mall | ||
.LINE2. |aMail Code 6069 | ||
.LINE3. |aStanford, CA 94305-6069 | ||
.EMAIL. |ame@example.com | ||
.PHONE. |a(111) 111-1111 | ||
.DEPT. |aHello World Services | ||
.USER_ADDR1_END. | ||
.USER_ADDR2_BEGIN. | ||
.PHONE. |a | ||
.DEPT. |a | ||
.USER_ADDR2_END. | ||
.USER_DEPARTMENT. |aHELLO | ||
.USER_PROFILE. |aCNS | ||
.USER_PRIV_GRANTED. |aTODAYSDATE | ||
.USER_PRIV_EXPIRES. |aNEVER | ||
.USER_GROUP_ID. |amysunet | ||
.USER_WEB_AUTH. |amysunet | ||
.USER_XINFO_BEGIN. | ||
.ACTIVEID. |a012345,1234567 | ||
.AFFIL1. |astaff | ||
.USER_XINFO_END. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.REC. | ||
*** DOCUMENT BOUNDARY *** | ||
FORM=LDUSER | ||
.USER_ID. |a2551234567 | ||
.USER_ALT_ID. |a001234567 | ||
.USER_NAME. |aLastname, Registeredname Y | ||
.USER_FIRST_NAME. |aRegisteredname | ||
.USER_MIDDLE_NAME. |aY | ||
.USER_LAST_NAME. |aLastname | ||
.USER_ADDR1_BEGIN. | ||
.LINE1. |aDLSS Lathrop 3rd Floor 557 Escondido Mall | ||
.LINE2. |aMail Code 6069 | ||
.LINE3. |aStanford, CA 94305-6069 | ||
.EMAIL. |ame@example.com | ||
.PHONE. |a(111) 111-1111 | ||
.DEPT. |aHello World Services | ||
.USER_ADDR1_END. | ||
.USER_ADDR2_BEGIN. | ||
.PHONE. |a | ||
.DEPT. |aorganization:medicine | ||
.USER_ADDR2_END. | ||
.USER_DEPARTMENT. |aHELLO | ||
.USER_PROFILE. |aCNS | ||
.USER_PRIV_GRANTED. |aTODAYSDATE | ||
.USER_PRIV_EXPIRES. |aNEVER | ||
.USER_GROUP_ID. |amysunet | ||
.USER_WEB_AUTH. |amysunet | ||
.USER_XINFO_BEGIN. | ||
.ACTIVEID. |a | ||
.AFFIL1. |astaff | ||
.USER_XINFO_END. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.REC. | ||
*** DOCUMENT BOUNDARY *** | ||
FORM=LDUSER | ||
.USER_ID. |a2551234567 | ||
.USER_ALT_ID. |a000000000 | ||
.USER_NAME. |aLastname, Firstname Y | ||
.USER_FIRST_NAME. |aFirstname | ||
.USER_MIDDLE_NAME. |aY | ||
.USER_LAST_NAME. |aLastname | ||
.USER_ADDR1_BEGIN. | ||
.LINE1. |aDLSS Lathrop 3rd Floor 557 Escondido Mall | ||
.LINE2. |aMail Code 6069 | ||
.LINE3. |aStanford, CA 94305-6069 | ||
.EMAIL. |ame@example.com | ||
.PHONE. |a(111) 111-1111 | ||
.DEPT. |aHello World Services | ||
.USER_ADDR1_END. | ||
.USER_ADDR2_BEGIN. | ||
.PHONE. |a | ||
.DEPT. |a | ||
.USER_ADDR2_END. | ||
.USER_DEPARTMENT. |aHELLO | ||
.USER_PROFILE. |aCNS | ||
.USER_PRIV_GRANTED. |aTODAYSDATE | ||
.USER_PRIV_EXPIRES. |aNEVER | ||
.USER_GROUP_ID. |amysunet | ||
.USER_WEB_AUTH. |amysunet | ||
.USER_XINFO_BEGIN. | ||
.ACTIVEID. |a | ||
.AFFIL1. |astaff | ||
.USER_XINFO_END. |
Oops, something went wrong.