Search in sources :

Example 1 with RecordNameManager

use of org.orcid.core.manager.v3.RecordNameManager in project ORCID-Source by ORCID.

the class ManageProfileControllerTest method testStripHtmlFromNames.

@Test
public void testStripHtmlFromNames() throws NoSuchRequestHandlingMethodException {
    RecordNameManager mockRecordNameManager = Mockito.mock(RecordNameManager.class);
    SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
    TargetProxyHelper.injectIntoProxy(controller, "recordNameManager", mockRecordNameManager);
    when(mockRecordNameManager.exists(Mockito.anyString())).thenReturn(true);
    NamesForm nf = new NamesForm();
    nf.setCreditName(Text.valueOf("<button onclick=\"alert('hello')\">Credit Name</button>"));
    nf.setGivenNames(Text.valueOf("<button onclick=\"alert('hello')\">Given Names</button>"));
    nf.setFamilyName(Text.valueOf("<button onclick=\"alert('hello')\">Family Name</button>"));
    nf.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PUBLIC));
    nf = controller.setNameFormJson(nf);
    assertEquals("Credit Name", nf.getCreditName().getValue());
    assertEquals("Given Names", nf.getGivenNames().getValue());
    assertEquals("Family Name", nf.getFamilyName().getValue());
    Name name = new Name();
    name.setCreditName(new CreditName("Credit Name"));
    name.setFamilyName(new FamilyName("Family Name"));
    name.setGivenNames(new GivenNames("Given Names"));
    name.setVisibility(Visibility.PUBLIC);
    verify(mockRecordNameManager, times(1)).updateRecordName(Mockito.eq(USER_ORCID), Mockito.eq(name));
}
Also used : RecordNameManager(org.orcid.core.manager.v3.RecordNameManager) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) NamesForm(org.orcid.pojo.ajaxForm.NamesForm) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 RecordNameManager (org.orcid.core.manager.v3.RecordNameManager)1 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)1 FamilyName (org.orcid.jaxb.model.v3.dev1.record.FamilyName)1 GivenNames (org.orcid.jaxb.model.v3.dev1.record.GivenNames)1 Name (org.orcid.jaxb.model.v3.dev1.record.Name)1 NamesForm (org.orcid.pojo.ajaxForm.NamesForm)1