@Test public final void testGetWithOrgAndDisplayNameSuffix() { final HashMap<String, Serializable> inFields = new HashMap<String, Serializable>(); inFields.put("accountId", "nflanders"); inFields.put("firstName", "Ned"); inFields.put("middleName", ""); inFields.put("lastName", "Flanders"); inFields.put("preferredName", "Ned-diddly"); inFields.put("displayNameSuffix", " SUFFIX"); context.checking(new Expectations() { { oneOf(ppg).getPersonProperties(inFields); will(returnValue(ppr)); oneOf(ppr).getTabTemplates(); will(returnValue(new ArrayList<TabTemplate>( Arrays.asList(new TabTemplate("welcome", Layout.ONECOLUMN))))); oneOf(ppr).getTheme(); will(returnValue(null)); } }); GetReadOnlyStreamsDbMapper readonlyStreamsMapper = new GetReadOnlyStreamsDbMapper(); (readonlyStreamsMapper).setEntityManager(getEntityManager()); List<String> streamNames = new ArrayList<String>(CollectionUtils.asList("My saved items", "Everyone")); PersonCreator localSut = new PersonCreator(personMapperMock, readonlyStreamsMapper, streamNames, ppg); Person p = localSut.get(null, inFields); context.assertIsSatisfied(); assertNotNull(p); assertNotNull(p.getStartTabGroup()); assertEquals("nflanders", p.getAccountId()); assertEquals("Ned", p.getFirstName()); assertEquals("", p.getMiddleName()); assertEquals("Flanders", p.getLastName()); assertEquals("Ned-diddly", p.getPreferredName()); assertEquals(" SUFFIX", p.getDisplayNameSuffix()); assertEquals(2, p.getStreams().size()); assertEquals(5, p.getStreams().get(0).getId()); assertEquals(1, p.getStreams().get(1).getId()); }
@Override public Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields) { Person person = new Person((String) inFields.get("accountId"), (String) inFields.get("firstName"), (String) inFields.get("middleName"), (String) inFields.get("lastName"), (String) inFields.get("preferredName")); person.setEmail((String) inFields.get("email")); person.setOpenSocialId(UUID.randomUUID().toString()); person.setCompanyName((String) inFields.get("companyName")); String displayNameSuffix = (String) inFields.get("displayNameSuffix"); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); TabGroup startTabGroup = new TabGroup(); PersonPropertiesResponse properties = personPropertiesGenerator.getPersonProperties(inFields); for (TabTemplate tt : properties.getTabTemplates()) { for (Gadget gadget : tt.getGadgets()) { gadget.setOwner(person); } startTabGroup.addTab(new Tab(tt)); } person.setStartTabGroup(startTabGroup); person.setTheme(properties.getTheme()); StreamScope personScope = new StreamScope(ScopeType.PERSON, (String) inFields.get("accountId")); person.setStreamScope(personScope); Set<StreamScope> defaultScopeList = new HashSet<StreamScope>(); defaultScopeList.add(personScope); List<Stream> streams = getStreamsForPerson(); person.setStreams(streams); person.setStreamViewHiddenLineIndex(streams.size() - 1); person.setGroupStreamHiddenLineIndex(3); if (inFields.containsKey("additionalProperties")) { HashMap<String, String> additionalProperties = (HashMap<String, String>) inFields .get("additionalProperties"); person.setAdditionalProperties(additionalProperties); } inFields.remove("email"); inFields.remove("sourceList"); return person; }
PersonCreator implements ResourcePersistenceStrategy<Person> { @Override public Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields) { Person person = new Person((String) inFields.get("accountId"), (String) inFields.get("firstName"), (String) inFields.get("middleName"), (String) inFields.get("lastName"), (String) inFields.get("preferredName")); person.setEmail((String) inFields.get("email")); person.setOpenSocialId(UUID.randomUUID().toString()); person.setCompanyName((String) inFields.get("companyName")); String displayNameSuffix = (String) inFields.get("displayNameSuffix"); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); TabGroup startTabGroup = new TabGroup(); PersonPropertiesResponse properties = personPropertiesGenerator.getPersonProperties(inFields); for (TabTemplate tt : properties.getTabTemplates()) { for (Gadget gadget : tt.getGadgets()) { gadget.setOwner(person); } startTabGroup.addTab(new Tab(tt)); } person.setStartTabGroup(startTabGroup); person.setTheme(properties.getTheme()); StreamScope personScope = new StreamScope(ScopeType.PERSON, (String) inFields.get("accountId")); person.setStreamScope(personScope); Set<StreamScope> defaultScopeList = new HashSet<StreamScope>(); defaultScopeList.add(personScope); List<Stream> streams = getStreamsForPerson(); person.setStreams(streams); person.setStreamViewHiddenLineIndex(streams.size() - 1); person.setGroupStreamHiddenLineIndex(3); if (inFields.containsKey("additionalProperties")) { HashMap<String, String> additionalProperties = (HashMap<String, String>) inFields .get("additionalProperties"); person.setAdditionalProperties(additionalProperties); } inFields.remove("email"); inFields.remove("sourceList"); return person; } }
PersonCreator implements ResourcePersistenceStrategy<Person> { @Override public Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields) { Person person = new Person((String) inFields.get("accountId"), (String) inFields.get("firstName"), (String) inFields.get("middleName"), (String) inFields.get("lastName"), (String) inFields.get("preferredName")); person.setEmail((String) inFields.get("email")); person.setOpenSocialId(UUID.randomUUID().toString()); person.setCompanyName((String) inFields.get("companyName")); String displayNameSuffix = (String) inFields.get("displayNameSuffix"); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); TabGroup startTabGroup = new TabGroup(); PersonPropertiesResponse properties = personPropertiesGenerator.getPersonProperties(inFields); for (TabTemplate tt : properties.getTabTemplates()) { for (Gadget gadget : tt.getGadgets()) { gadget.setOwner(person); } startTabGroup.addTab(new Tab(tt)); } person.setStartTabGroup(startTabGroup); person.setTheme(properties.getTheme()); StreamScope personScope = new StreamScope(ScopeType.PERSON, (String) inFields.get("accountId")); person.setStreamScope(personScope); Set<StreamScope> defaultScopeList = new HashSet<StreamScope>(); defaultScopeList.add(personScope); List<Stream> streams = getStreamsForPerson(); person.setStreams(streams); person.setStreamViewHiddenLineIndex(streams.size() - 1); person.setGroupStreamHiddenLineIndex(3); if (inFields.containsKey("additionalProperties")) { HashMap<String, String> additionalProperties = (HashMap<String, String>) inFields .get("additionalProperties"); person.setAdditionalProperties(additionalProperties); } inFields.remove("email"); inFields.remove("sourceList"); return person; } PersonCreator(final PersonMapper inPersonMapper,
            final DomainMapper<Long, List<Stream>> inReadonlyStreamsMapper, //
            final List<String> inReadOnlyStreamsNameList, final PersonPropertiesGenerator inPersonPropertiesGenerator); }
PersonCreator implements ResourcePersistenceStrategy<Person> { @Override public Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields) { Person person = new Person((String) inFields.get("accountId"), (String) inFields.get("firstName"), (String) inFields.get("middleName"), (String) inFields.get("lastName"), (String) inFields.get("preferredName")); person.setEmail((String) inFields.get("email")); person.setOpenSocialId(UUID.randomUUID().toString()); person.setCompanyName((String) inFields.get("companyName")); String displayNameSuffix = (String) inFields.get("displayNameSuffix"); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); TabGroup startTabGroup = new TabGroup(); PersonPropertiesResponse properties = personPropertiesGenerator.getPersonProperties(inFields); for (TabTemplate tt : properties.getTabTemplates()) { for (Gadget gadget : tt.getGadgets()) { gadget.setOwner(person); } startTabGroup.addTab(new Tab(tt)); } person.setStartTabGroup(startTabGroup); person.setTheme(properties.getTheme()); StreamScope personScope = new StreamScope(ScopeType.PERSON, (String) inFields.get("accountId")); person.setStreamScope(personScope); Set<StreamScope> defaultScopeList = new HashSet<StreamScope>(); defaultScopeList.add(personScope); List<Stream> streams = getStreamsForPerson(); person.setStreams(streams); person.setStreamViewHiddenLineIndex(streams.size() - 1); person.setGroupStreamHiddenLineIndex(3); if (inFields.containsKey("additionalProperties")) { HashMap<String, String> additionalProperties = (HashMap<String, String>) inFields .get("additionalProperties"); person.setAdditionalProperties(additionalProperties); } inFields.remove("email"); inFields.remove("sourceList"); return person; } PersonCreator(final PersonMapper inPersonMapper,
            final DomainMapper<Long, List<Stream>> inReadonlyStreamsMapper, //
            final List<String> inReadOnlyStreamsNameList, final PersonPropertiesGenerator inPersonPropertiesGenerator); @Override Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields); @Override void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields, final Person inPerson); }
PersonCreator implements ResourcePersistenceStrategy<Person> { @Override public Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields) { Person person = new Person((String) inFields.get("accountId"), (String) inFields.get("firstName"), (String) inFields.get("middleName"), (String) inFields.get("lastName"), (String) inFields.get("preferredName")); person.setEmail((String) inFields.get("email")); person.setOpenSocialId(UUID.randomUUID().toString()); person.setCompanyName((String) inFields.get("companyName")); String displayNameSuffix = (String) inFields.get("displayNameSuffix"); if (displayNameSuffix == null) { displayNameSuffix = ""; } person.setDisplayNameSuffix(displayNameSuffix); TabGroup startTabGroup = new TabGroup(); PersonPropertiesResponse properties = personPropertiesGenerator.getPersonProperties(inFields); for (TabTemplate tt : properties.getTabTemplates()) { for (Gadget gadget : tt.getGadgets()) { gadget.setOwner(person); } startTabGroup.addTab(new Tab(tt)); } person.setStartTabGroup(startTabGroup); person.setTheme(properties.getTheme()); StreamScope personScope = new StreamScope(ScopeType.PERSON, (String) inFields.get("accountId")); person.setStreamScope(personScope); Set<StreamScope> defaultScopeList = new HashSet<StreamScope>(); defaultScopeList.add(personScope); List<Stream> streams = getStreamsForPerson(); person.setStreams(streams); person.setStreamViewHiddenLineIndex(streams.size() - 1); person.setGroupStreamHiddenLineIndex(3); if (inFields.containsKey("additionalProperties")) { HashMap<String, String> additionalProperties = (HashMap<String, String>) inFields .get("additionalProperties"); person.setAdditionalProperties(additionalProperties); } inFields.remove("email"); inFields.remove("sourceList"); return person; } PersonCreator(final PersonMapper inPersonMapper,
            final DomainMapper<Long, List<Stream>> inReadonlyStreamsMapper, //
            final List<String> inReadOnlyStreamsNameList, final PersonPropertiesGenerator inPersonPropertiesGenerator); @Override Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields); @Override void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields, final Person inPerson);  }