chore: restore to gitea from backup
This commit is contained in:
commit
b164523d05
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/.classpath
|
||||
|
||||
/target
|
||||
/.factorypath
|
||||
34
.project
Normal file
34
.project
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>WhatsInAName</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
161
README.md
Normal file
161
README.md
Normal file
@ -0,0 +1,161 @@
|
||||
# Individual Name Formatter API
|
||||
|
||||
A RESTful API for properly formatting and generating multiple representations of individual names. The API handles capitalization, prefixes, suffixes, middle initials, and professional designations.
|
||||
|
||||
---
|
||||
|
||||
## Base URL
|
||||
|
||||
```
|
||||
http://localhost:8080/v1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This API takes name components (first name, middle name, last name, prefix, suffix) and returns multiple formats, including:
|
||||
|
||||
* FirstName LastName
|
||||
* FirstName MiddleInitial LastName
|
||||
* LastName, FirstName
|
||||
* LastName, FirstName MiddleInitial
|
||||
* Prefix FirstName LastName
|
||||
* Prefix FirstName MiddleInitial LastName
|
||||
* Prefix LastName
|
||||
* FirstName LastName Suffix
|
||||
* FirstName MiddleName LastName
|
||||
|
||||
---
|
||||
|
||||
## Content-Type
|
||||
|
||||
All **POST** requests must include:
|
||||
|
||||
```
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Format Individual Name
|
||||
|
||||
**POST** `/individualNames/format`
|
||||
|
||||
#### Request Body
|
||||
|
||||
```json
|
||||
{
|
||||
"firstName": "john",
|
||||
"middleName": "kenneth",
|
||||
"lastName": "doe",
|
||||
"prefix": "dr",
|
||||
"suffix": "jr",
|
||||
"preferredName": "johnny",
|
||||
"professionalDesignation": "PhD"
|
||||
}
|
||||
```
|
||||
|
||||
#### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"firstName": "John",
|
||||
"middleName": "Kenneth",
|
||||
"lastName": "Doe",
|
||||
"prefix": "Dr",
|
||||
"suffix": "Jr",
|
||||
"preferredName": "johnny",
|
||||
"professionalDesignation": "PhD",
|
||||
"firstNameLastName": "John Doe",
|
||||
"firstNameMiddleNameLastName": "John Kenneth Doe",
|
||||
"firstNameLastNameSuffix": "John Doe Jr",
|
||||
"lastNameFirstName": "Doe, John",
|
||||
"lastNameFirstNameMiddleInitial": "Doe, John K.",
|
||||
"prefixFirstNameLastName": "Dr John Doe",
|
||||
"prefixFirstNameMiddleInitialLastName": "Dr John K. Doe",
|
||||
"prefixLastName": "Dr Doe"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
#### 1. Simple Name
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"firstName": "jane",
|
||||
"lastName": "smith"
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"firstNameLastName": "Jane Smith",
|
||||
"lastNameFirstName": "Smith, Jane"
|
||||
}
|
||||
```
|
||||
|
||||
#### 2. Name with Middle Name and Suffix
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"firstName": "robert",
|
||||
"middleName": "alan",
|
||||
"lastName": "johnson",
|
||||
"suffix": "III"
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"firstNameMiddleNameLastName": "Robert Alan Johnson",
|
||||
"firstNameLastNameSuffix": "Robert Johnson III",
|
||||
"lastNameFirstNameMiddleInitial": "Johnson, Robert A."
|
||||
}
|
||||
```
|
||||
|
||||
#### 3. Name with Prefix
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"prefix": "ms",
|
||||
"firstName": "anna",
|
||||
"lastName": "lee"
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"prefixFirstNameLastName": "Ms Anna Lee",
|
||||
"prefixLastName": "Ms Lee"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
Specify license information here.
|
||||
|
||||
---
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
Developed by John Groller. Inspired by the need for standardized name formatting in applications.
|
||||
122
pom.xml
Normal file
122
pom.xml
Normal file
@ -0,0 +1,122 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.jkgroller</groupId>
|
||||
<artifactId>WhatsInAName</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<organization>
|
||||
<name>John Groller</name>
|
||||
<url>http://www.jkgroller.com</url>
|
||||
</organization>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.5.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<license-maven-plugin.version>2.3</license-maven-plugin.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<license-maven-plugin.version>2.3</license-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
<version>1.3.0.Beta2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.crnk</groupId>
|
||||
<artifactId>crnk-setup-spring-boot2</artifactId>
|
||||
<version>2.6.20180522184741</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.mycila</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>${license-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<header>src/main/resources/licenseTemplate.txt</header>
|
||||
<includes>
|
||||
<include>src/main/**</include>
|
||||
<include>src/test/**</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>src/main/resources/**</exclude>
|
||||
<exclude>src/test/resources/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>format</goal>
|
||||
</goals>
|
||||
<phase>process-sources</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.mycila</groupId>
|
||||
<artifactId>licenses</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.3.0.Beta2</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
27
src/main/java/com/jkgroller/whatsinaname/Application.java
Normal file
27
src/main/java/com/jkgroller/whatsinaname/Application.java
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
package com.jkgroller.whatsinaname;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author John Groller (john@grollerfamily.com)
|
||||
*
|
||||
* This API attempts to properly format and capitalize components of a
|
||||
* name. Then, using those values, this API provides several formats of
|
||||
* the name.
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* Configuration class.
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class NamesConfig {
|
||||
|
||||
@Value("${names}")
|
||||
private List<String> names;
|
||||
|
||||
/**
|
||||
*
|
||||
* Makes a List<String> of predefined names available in-memory for searching.
|
||||
* These names can be found in application.properties. This list contains proper
|
||||
* nouns with multiple capitalizations and non-alphabetic characters.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public List<String> names() {
|
||||
|
||||
return names;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.converter;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import com.jkgroller.whatsinaname.resource.IndividualNameResource;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterRequestTO;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterResponseTO;
|
||||
|
||||
/**
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* @see <a href="http://mapstruct.org/">MapStruct</a>.
|
||||
*
|
||||
* Converts domain and resource objects.
|
||||
*
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface IndividualNameConverter {
|
||||
|
||||
IndividualNameFormatterRequestTO convertResourceToFormatterRequest(IndividualNameResource individualNameResource);
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts IndividualNameFormatterResponseTO to IndividualNameResource
|
||||
*
|
||||
* @param individualNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
IndividualNameResource convertFormatterResponseToResource(
|
||||
IndividualNameFormatterResponseTO individualNameFormatterResponseTO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,192 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.resource;
|
||||
|
||||
import io.crnk.core.resource.annotations.JsonApiField;
|
||||
import io.crnk.core.resource.annotations.JsonApiId;
|
||||
import io.crnk.core.resource.annotations.JsonApiResource;
|
||||
|
||||
/**
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* This is the individualName (/individualNames) resource. Consumers may
|
||||
* POST prefix, firstName, middleName, lastName, suffix, and
|
||||
* preferredName, but nothing else. All values are presented in a GET.
|
||||
* Nothing can be PATCHED, currently.
|
||||
*
|
||||
*/
|
||||
@JsonApiResource(type = "individualName", resourcePath = "individualNames")
|
||||
public class IndividualNameResource {
|
||||
|
||||
@JsonApiId
|
||||
private Integer individualNameIdentifier;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String prefix;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String firstName;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String middleName;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String lastName;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String suffix;
|
||||
|
||||
@JsonApiField(readable = true, postable = true, patchable = false)
|
||||
private String preferredName;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String professionalDesignation;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String prefixLastName;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String lastNameFirstName;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String lastNameFirstNameMiddleInitial;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String prefixFirstNameMiddleInitialLastName;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String firstNameMiddleNameLastName;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String firstNameLastNameSuffix;
|
||||
|
||||
@JsonApiField(readable = true, postable = false, patchable = false)
|
||||
private String prefixFirstNameLastName;
|
||||
|
||||
public Integer getIndividualNameIdentifier() {
|
||||
return individualNameIdentifier;
|
||||
}
|
||||
|
||||
public void setIndividualNameIdentifier(Integer individualNameIdentifier) {
|
||||
this.individualNameIdentifier = individualNameIdentifier;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public String getPreferredName() {
|
||||
return preferredName;
|
||||
}
|
||||
|
||||
public void setPreferredName(String preferredName) {
|
||||
this.preferredName = preferredName;
|
||||
}
|
||||
|
||||
public String getProfessionalDesignation() {
|
||||
return professionalDesignation;
|
||||
}
|
||||
|
||||
public void setProfessionalDesignation(String professionalDesignation) {
|
||||
this.professionalDesignation = professionalDesignation;
|
||||
}
|
||||
|
||||
public String getPrefixLastName() {
|
||||
return prefixLastName;
|
||||
}
|
||||
|
||||
public void setPrefixLastName(String prefixLastName) {
|
||||
this.prefixLastName = prefixLastName;
|
||||
}
|
||||
|
||||
public String getLastNameFirstName() {
|
||||
return lastNameFirstName;
|
||||
}
|
||||
|
||||
public void setLastNameFirstName(String lastNameFirstName) {
|
||||
this.lastNameFirstName = lastNameFirstName;
|
||||
}
|
||||
|
||||
public String getLastNameFirstNameMiddleInitial() {
|
||||
return lastNameFirstNameMiddleInitial;
|
||||
}
|
||||
|
||||
public void setLastNameFirstNameMiddleInitial(String lastNameFirstNameMiddleInitial) {
|
||||
this.lastNameFirstNameMiddleInitial = lastNameFirstNameMiddleInitial;
|
||||
}
|
||||
|
||||
public String getPrefixFirstNameMiddleInitialLastName() {
|
||||
return prefixFirstNameMiddleInitialLastName;
|
||||
}
|
||||
|
||||
public void setPrefixFirstNameMiddleInitialLastName(String prefixFirstNameMiddleInitialLastName) {
|
||||
this.prefixFirstNameMiddleInitialLastName = prefixFirstNameMiddleInitialLastName;
|
||||
}
|
||||
|
||||
public String getFirstNameMiddleNameLastName() {
|
||||
return firstNameMiddleNameLastName;
|
||||
}
|
||||
|
||||
public void setFirstNameMiddleNameLastName(String firstNameMiddleNameLastName) {
|
||||
this.firstNameMiddleNameLastName = firstNameMiddleNameLastName;
|
||||
}
|
||||
|
||||
public String getFirstNameLastNameSuffix() {
|
||||
return firstNameLastNameSuffix;
|
||||
}
|
||||
|
||||
public void setFirstNameLastNameSuffix(String firstNameLastNameSuffix) {
|
||||
this.firstNameLastNameSuffix = firstNameLastNameSuffix;
|
||||
}
|
||||
|
||||
public String getPrefixFirstNameLastName() {
|
||||
return prefixFirstNameLastName;
|
||||
}
|
||||
|
||||
public void setPrefixFirstNameLastName(String prefixFirstNameLastName) {
|
||||
this.prefixFirstNameLastName = prefixFirstNameLastName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.resource.repository;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jkgroller.whatsinaname.converter.IndividualNameConverter;
|
||||
import com.jkgroller.whatsinaname.resource.IndividualNameResource;
|
||||
import com.jkgroller.whatsinaname.service.IndividualNameFormatterService;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterRequestTO;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterResponseTO;
|
||||
|
||||
import io.crnk.core.exception.MethodNotAllowedException;
|
||||
import io.crnk.core.queryspec.QuerySpec;
|
||||
import io.crnk.core.repository.ResourceRepositoryV2;
|
||||
import io.crnk.core.resource.list.ResourceList;
|
||||
|
||||
/**
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* Resource repository for IndividualName.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class IndividualNameResourceRepository implements ResourceRepositoryV2<IndividualNameResource, Integer> {
|
||||
|
||||
@Autowired
|
||||
private IndividualNameConverter individualNameConverter;
|
||||
|
||||
@Autowired
|
||||
private IndividualNameFormatterService individualNameFormatterService;
|
||||
|
||||
@Override
|
||||
public Class<IndividualNameResource> getResourceClass() {
|
||||
return IndividualNameResource.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndividualNameResource findOne(Integer id, QuerySpec querySpec) {
|
||||
throw new MethodNotAllowedException("Not yet implemented. Planned for future release.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceList<IndividualNameResource> findAll(QuerySpec querySpec) {
|
||||
throw new MethodNotAllowedException("Not yet implemented. Planned for future release.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceList<IndividualNameResource> findAll(Iterable<Integer> ids, QuerySpec querySpec) {
|
||||
throw new MethodNotAllowedException("Not yet implemented. Planned for future release.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends IndividualNameResource> S save(S resource) {
|
||||
throw new MethodNotAllowedException("Not yet implemented. Planned for future release.");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates the IndividualName resource. Currently does not persist the data and
|
||||
* is returned with a random and meaningless identifier. Future plans may
|
||||
* include persisting this data simply as a mechanism to gather information and
|
||||
* update back-end systems. It would have the added benefit of being more
|
||||
* "RESTful".
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S extends IndividualNameResource> S create(S resource) {
|
||||
|
||||
IndividualNameFormatterRequestTO individualNameFormatterRequestTO = individualNameConverter
|
||||
.convertResourceToFormatterRequest(resource);
|
||||
|
||||
IndividualNameFormatterResponseTO individualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
resource = (S) individualNameConverter.convertFormatterResponseToResource(individualNameFormatterResponseTO);
|
||||
|
||||
Random random = new Random();
|
||||
resource.setIndividualNameIdentifier(random.nextInt((99999 - 9999) + 1) + 9999);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer id) {
|
||||
throw new MethodNotAllowedException("Not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.service;
|
||||
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterRequestTO;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterResponseTO;
|
||||
|
||||
/**
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* Provides many formats of individual names.
|
||||
*/
|
||||
public interface IndividualNameFormatterService {
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides many formats of an individual's name given name elements.
|
||||
*
|
||||
* @param individualNameFormatterRequestTO
|
||||
* @return
|
||||
*/
|
||||
IndividualNameFormatterResponseTO formatIndividualName(
|
||||
IndividualNameFormatterRequestTO individualNameFormatterRequestTO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,532 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterRequestTO;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterResponseTO;
|
||||
|
||||
/**
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class IndividualNameFormatterServiceImpl implements IndividualNameFormatterService {
|
||||
|
||||
@Autowired
|
||||
private List<String> names;
|
||||
|
||||
/**
|
||||
* Comma constant.
|
||||
*/
|
||||
private static final String COMMA = ",";
|
||||
|
||||
/**
|
||||
* Comma space constant.
|
||||
*/
|
||||
private static final String COMMA_SPACE = COMMA + StringUtils.SPACE;
|
||||
|
||||
/**
|
||||
* Period constant.
|
||||
*/
|
||||
private static final String PERIOD = ".";
|
||||
|
||||
/**
|
||||
* Period space constant.
|
||||
*/
|
||||
private static final String PERIOD_SPACE = PERIOD + StringUtils.SPACE;
|
||||
|
||||
/**
|
||||
*
|
||||
* Orchestrates all formatting and generating of names based on primary name.
|
||||
*
|
||||
*/
|
||||
public IndividualNameFormatterResponseTO formatIndividualName(
|
||||
IndividualNameFormatterRequestTO individualNameFormatterRequestTO) {
|
||||
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO = properlyFormatPrimaryNameElements(
|
||||
individualNameFormatterRequestTO);
|
||||
|
||||
individualrNameFormatterResponseTO.setPreferredName(individualNameFormatterRequestTO.getPreferredName());
|
||||
|
||||
individualrNameFormatterResponseTO.setSuffix(individualNameFormatterRequestTO.getSuffix());
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setFirstNameLastNameSuffix(generateFirstNameLastNameSuffix(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO.setFirstNameMiddleNameLastName(
|
||||
generateFirstNameMiddleNameLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setLastNameFirstName(generateLastNameFirstName(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO.setLastNameFirstNameMiddleInitial(
|
||||
generateLastNameFirstNameMiddleInitial(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setPrefixFirstNameLastName(generatePrefixFirstNameLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO.setPrefixFirstNameMiddleInitialLastName(
|
||||
generatePrefixFirstNameMiddleInitialLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setPrefixLastName(generatePrefixLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setFirstNameLastName(generateFirstNameLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
return individualrNameFormatterResponseTO;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Properly formats primary name elements... the elements from which all other
|
||||
* name formats are derived: firstName, lastName, middleName, prefix.
|
||||
*
|
||||
* @param individualrNameFormatterRequestTO
|
||||
* @return
|
||||
*/
|
||||
private IndividualNameFormatterResponseTO properlyFormatPrimaryNameElements(
|
||||
IndividualNameFormatterRequestTO individualrNameFormatterRequestTO) {
|
||||
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO = new IndividualNameFormatterResponseTO();
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setFirstName(properlyFormatNameElement(individualrNameFormatterRequestTO.getFirstName()));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setMiddleName(properlyFormatNameElement(individualrNameFormatterRequestTO.getMiddleName()));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setLastName(properlyFormatNameElement(individualrNameFormatterRequestTO.getLastName()));
|
||||
|
||||
individualrNameFormatterResponseTO
|
||||
.setPrefix(properlyFormatNameElement(individualrNameFormatterRequestTO.getPrefix()));
|
||||
|
||||
return individualrNameFormatterResponseTO;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Orchestrates formattting of the name by first checking for null, then
|
||||
* checking for matching name in name list. If found, return that matching name.
|
||||
* If not, properly capitalize name element and return.
|
||||
*
|
||||
* @param nameElement
|
||||
* @return
|
||||
*/
|
||||
private String properlyFormatNameElement(String nameElement) {
|
||||
|
||||
if (StringUtils.isBlank(nameElement)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String matchingName = findMatchingName(nameElement);
|
||||
|
||||
if (null != matchingName) {
|
||||
return matchingName;
|
||||
}
|
||||
|
||||
return properlyCapitalizeNameElement(nameElement);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Searches the names collection for a matching name element.
|
||||
*
|
||||
* If found, that matching name element is returned.
|
||||
*
|
||||
* @param nameElement
|
||||
* @return
|
||||
*/
|
||||
private String findMatchingName(String nameElement) {
|
||||
|
||||
return names.stream().filter(s -> s.equalsIgnoreCase(nameElement)).findFirst().orElse(null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* If nameElement is not null, changes the value to all lower case, then checks
|
||||
* the entire string to verify alpha. If it is, return it with the first letter
|
||||
* capitalized.
|
||||
*
|
||||
* If it's not totally alpha things get interesting.
|
||||
*
|
||||
* The lowerCase string is converted to a char array, and the very first char
|
||||
* converted to uppercase, provided it's alpha. Then, the char array is looped
|
||||
* through, looking for non-alphanumeric values (for names it will likely be
|
||||
* things like "'", "-", and " ". When non-alpha values are found, the char
|
||||
* after them is capitalized. If the end of the array contains the non-alpha, it
|
||||
* does not attempt a case change since that would cause an index out of bounds
|
||||
* exception.
|
||||
*
|
||||
* @param nameElement
|
||||
* @return
|
||||
*/
|
||||
private String properlyCapitalizeNameElement(String nameElement) {
|
||||
|
||||
if (StringUtils.isBlank(nameElement)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String lowerCaseNameElement = nameElement.toLowerCase();
|
||||
|
||||
if (StringUtils.isAlpha(lowerCaseNameElement)) {
|
||||
return StringUtils.capitalize(lowerCaseNameElement);
|
||||
}
|
||||
|
||||
char[] properlyCapitalizedNameElementChars = lowerCaseNameElement.toCharArray();
|
||||
|
||||
if (CharUtils.isAsciiAlpha(properlyCapitalizedNameElementChars[0])) {
|
||||
properlyCapitalizedNameElementChars[0] = Character.toUpperCase(properlyCapitalizedNameElementChars[0]);
|
||||
}
|
||||
|
||||
int properlyCapitalizedNameElementCharsLength = properlyCapitalizedNameElementChars.length;
|
||||
|
||||
for (int i = 0; i < properlyCapitalizedNameElementCharsLength; i++) {
|
||||
if (!CharUtils.isAsciiAlpha(properlyCapitalizedNameElementChars[i])) {
|
||||
if ((i + 1) < properlyCapitalizedNameElementCharsLength) {
|
||||
properlyCapitalizedNameElementChars[i + 1] = Character
|
||||
.toUpperCase(properlyCapitalizedNameElementChars[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new String(properlyCapitalizedNameElementChars);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates name in the format <lastName>,<space><firstName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateLastNameFirstName(IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isFirstNameLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getLastName());
|
||||
stringBuilder.append(COMMA_SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getFirstName());
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format
|
||||
* <lastName>,<space><firstName><space><middleInitial><period>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateLastNameFirstNameMiddleInitial(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isFirstNameMiddleNameLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(generateLastNameFirstName(individualrNameFormatterResponseTO));
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getMiddleName().substring(0, 1).toUpperCase());
|
||||
stringBuilder.append(PERIOD);
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format <firstName><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateFirstNameLastName(IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getFirstName());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getLastName());
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format <prefix><space><firstName><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generatePrefixFirstNameLastName(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isPrefixFirstNameLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getPrefix());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(generateFirstNameLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format <prefix><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generatePrefixLastName(IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isPrefixLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getPrefix());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getLastName());
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format <firstName><space><lastName><space><suffix>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateFirstNameLastNameSuffix(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isFirstNameLastNameSuffixMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(generateFirstNameLastName(individualrNameFormatterResponseTO));
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getSuffix());
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format <firstName><space><middleName><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateFirstNameMiddleNameLastName(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isFirstNameMiddleNameLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getFirstName());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getMiddleName());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getLastName());
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format
|
||||
* <firstName><space><middleInitial><period><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generateFirstNameMiddleInitialLastName(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getFirstName());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getMiddleName().substring(0, 1).toUpperCase());
|
||||
stringBuilder.append(PERIOD_SPACE);
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getLastName());
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates name in the format
|
||||
* <prefix><space><firstName><space><middleInitial><space><lastName>.
|
||||
*
|
||||
* Returns null if this can't be calculated.
|
||||
*
|
||||
*
|
||||
* @param individualrNameFormatterResponseTO
|
||||
* @return
|
||||
*/
|
||||
private String generatePrefixFirstNameMiddleInitialLastName(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
if (isPrefixFirstNameMiddleNameLastNameMissing(individualrNameFormatterResponseTO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(individualrNameFormatterResponseTO.getPrefix());
|
||||
stringBuilder.append(StringUtils.SPACE);
|
||||
stringBuilder.append(generateFirstNameMiddleInitialLastName(individualrNameFormatterResponseTO));
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of first and last names.
|
||||
*
|
||||
* True if either are missing. False if both are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isFirstNameLastNameMissing(IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return StringUtils.isBlank(individualrNameFormatterResponseTO.getFirstName())
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of first, middle, and last names.
|
||||
*
|
||||
* True if any are missing. False if all are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isFirstNameMiddleNameLastNameMissing(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return isFirstNameLastNameMissing(individualrNameFormatterResponseTO)
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getMiddleName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of prefix, first, and last names.
|
||||
*
|
||||
* True if any are missing. False if all are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isPrefixFirstNameLastNameMissing(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return isFirstNameLastNameMissing(individualrNameFormatterResponseTO)
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getPrefix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of prefix, first, middle, and last names.
|
||||
*
|
||||
* True if any are missing. False if all are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isPrefixFirstNameMiddleNameLastNameMissing(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return isPrefixFirstNameLastNameMissing(individualrNameFormatterResponseTO)
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getMiddleName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of first and last names, and suffix.
|
||||
*
|
||||
* True if any are missing. False if all are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isFirstNameLastNameSuffixMissing(
|
||||
IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return isFirstNameLastNameMissing(individualrNameFormatterResponseTO)
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence of prefix and last name.
|
||||
*
|
||||
* True if either are missing. False if both are present.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isPrefixLastNameMissing(IndividualNameFormatterResponseTO individualrNameFormatterResponseTO) {
|
||||
|
||||
return StringUtils.isBlank(individualrNameFormatterResponseTO.getLastName())
|
||||
|| StringUtils.isBlank(individualrNameFormatterResponseTO.getPrefix());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.service.to;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* Request object for IndividualNameFormatterService.
|
||||
*
|
||||
*/
|
||||
public class IndividualNameFormatterRequestTO {
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String middleName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private String preferredName;
|
||||
|
||||
private String professionalDesignation;
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public String getPreferredName() {
|
||||
return preferredName;
|
||||
}
|
||||
|
||||
public void setPreferredName(String preferredName) {
|
||||
this.preferredName = preferredName;
|
||||
}
|
||||
|
||||
public String getProfessionalDesignation() {
|
||||
return professionalDesignation;
|
||||
}
|
||||
|
||||
public void setProfessionalDesignation(String professionalDesignation) {
|
||||
this.professionalDesignation = professionalDesignation;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.service.to;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author john@grollerfamily.com
|
||||
*
|
||||
* Response object for IndividualNameFormatterService.
|
||||
*
|
||||
*/
|
||||
public class IndividualNameFormatterResponseTO {
|
||||
|
||||
private Integer individualNameIdentifier;
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String middleName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private String preferredName;
|
||||
|
||||
private String professionalDesignation;
|
||||
|
||||
private String prefixLastName;
|
||||
|
||||
private String lastNameFirstName;
|
||||
|
||||
private String lastNameFirstNameMiddleInitial;
|
||||
|
||||
private String prefixFirstNameMiddleInitialLastName;
|
||||
|
||||
private String firstNameMiddleNameLastName;
|
||||
|
||||
private String firstNameLastNameSuffix;
|
||||
|
||||
private String prefixFirstNameLastName;
|
||||
|
||||
private String firstNameLastName;
|
||||
|
||||
public String getFirstNameLastName() {
|
||||
return firstNameLastName;
|
||||
}
|
||||
|
||||
public void setFirstNameLastName(String firstNameLastName) {
|
||||
this.firstNameLastName = firstNameLastName;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public String getPreferredName() {
|
||||
return preferredName;
|
||||
}
|
||||
|
||||
public void setPreferredName(String preferredName) {
|
||||
this.preferredName = preferredName;
|
||||
}
|
||||
|
||||
public String getProfessionalDesignation() {
|
||||
return professionalDesignation;
|
||||
}
|
||||
|
||||
public void setProfessionalDesignation(String professionalDesignation) {
|
||||
this.professionalDesignation = professionalDesignation;
|
||||
}
|
||||
|
||||
public String getPrefixLastName() {
|
||||
return prefixLastName;
|
||||
}
|
||||
|
||||
public void setPrefixLastName(String prefixLastName) {
|
||||
this.prefixLastName = prefixLastName;
|
||||
}
|
||||
|
||||
public String getLastNameFirstName() {
|
||||
return lastNameFirstName;
|
||||
}
|
||||
|
||||
public void setLastNameFirstName(String lastNameFirstName) {
|
||||
this.lastNameFirstName = lastNameFirstName;
|
||||
}
|
||||
|
||||
public String getLastNameFirstNameMiddleInitial() {
|
||||
return lastNameFirstNameMiddleInitial;
|
||||
}
|
||||
|
||||
public void setLastNameFirstNameMiddleInitial(String lastNameFirstNameMiddleInitial) {
|
||||
this.lastNameFirstNameMiddleInitial = lastNameFirstNameMiddleInitial;
|
||||
}
|
||||
|
||||
public String getPrefixFirstNameMiddleInitialLastName() {
|
||||
return prefixFirstNameMiddleInitialLastName;
|
||||
}
|
||||
|
||||
public void setPrefixFirstNameMiddleInitialLastName(String prefixFirstNameMiddleInitialLastName) {
|
||||
this.prefixFirstNameMiddleInitialLastName = prefixFirstNameMiddleInitialLastName;
|
||||
}
|
||||
|
||||
public String getFirstNameMiddleNameLastName() {
|
||||
return firstNameMiddleNameLastName;
|
||||
}
|
||||
|
||||
public void setFirstNameMiddleNameLastName(String firstNameMiddleNameLastName) {
|
||||
this.firstNameMiddleNameLastName = firstNameMiddleNameLastName;
|
||||
}
|
||||
|
||||
public String getFirstNameLastNameSuffix() {
|
||||
return firstNameLastNameSuffix;
|
||||
}
|
||||
|
||||
public void setFirstNameLastNameSuffix(String firstNameLastNameSuffix) {
|
||||
this.firstNameLastNameSuffix = firstNameLastNameSuffix;
|
||||
}
|
||||
|
||||
public String getPrefixFirstNameLastName() {
|
||||
return prefixFirstNameLastName;
|
||||
}
|
||||
|
||||
public void setPrefixFirstNameLastName(String prefixFirstNameLastName) {
|
||||
this.prefixFirstNameLastName = prefixFirstNameLastName;
|
||||
}
|
||||
|
||||
public Integer getIndividualNameIdentifier() {
|
||||
return individualNameIdentifier;
|
||||
}
|
||||
|
||||
public void setIndividualNameIdentifier(Integer individualNameIdentifier) {
|
||||
this.individualNameIdentifier = individualNameIdentifier;
|
||||
}
|
||||
|
||||
}
|
||||
10
src/main/resources/application.properties
Normal file
10
src/main/resources/application.properties
Normal file
File diff suppressed because one or more lines are too long
3
src/main/resources/licenseTemplate.txt
Normal file
3
src/main/resources/licenseTemplate.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Copyright (c) 2019 John Groller
|
||||
|
||||
WhatsInAName - John Groller
|
||||
@ -0,0 +1,465 @@
|
||||
/**
|
||||
* Copyright (c) 2019 John Groller
|
||||
*
|
||||
* WhatsInAName - John Groller
|
||||
*/
|
||||
package com.jkgroller.whatsinaname.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterRequestTO;
|
||||
import com.jkgroller.whatsinaname.service.to.IndividualNameFormatterResponseTO;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IndividualNameFormatterServiceTest {
|
||||
|
||||
@Mock
|
||||
List<String> names = new ArrayList<String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
add("McGinnis");
|
||||
add("McGlaughlin");
|
||||
add("McGlin");
|
||||
}
|
||||
};
|
||||
|
||||
private IndividualNameFormatterRequestTO individualNameFormatterRequestTO;
|
||||
|
||||
private IndividualNameFormatterResponseTO expectedIndividualNameFormatterResponseTO;
|
||||
|
||||
@InjectMocks
|
||||
private IndividualNameFormatterServiceImpl individualNameFormatterService;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setupRequestAndResponses() {
|
||||
|
||||
individualNameFormatterRequestTO = generateIndividualNameFormatterRequestTO();
|
||||
|
||||
expectedIndividualNameFormatterResponseTO = generateIndividualNameFormatterResponseTO();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testLastNameFirstNameCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getLastNameFirstName(),
|
||||
actualIndividualNameFormatterResponseTO.getLastNameFirstName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testLastNameFirstNameFirstNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getLastNameFirstName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testLastNameFirstNameLastNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setLastName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getLastNameFirstName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testLastNameFirstNameMiddleInitialCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getLastNameFirstNameMiddleInitial(),
|
||||
actualIndividualNameFormatterResponseTO.getLastNameFirstNameMiddleInitial());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testLastNameFirstNameMiddleInitialMiddleNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setMiddleName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getLastNameFirstNameMiddleInitial());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixFirstNameLastNameCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getPrefixFirstNameLastName(),
|
||||
actualIndividualNameFormatterResponseTO.getPrefixFirstNameLastName());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixFirstNameLastNamePrefixNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setPrefix(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getPrefixFirstNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixFirstNameLastNameFirstNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getPrefixFirstNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixLastNameCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getPrefixLastName(),
|
||||
actualIndividualNameFormatterResponseTO.getPrefixLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixLastNamePrefixNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setPrefix(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getPrefixLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixLastNameLastNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setLastName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getPrefixLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameSuffixCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix(),
|
||||
actualIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameSuffixSuffixNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setSuffix(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameSuffixLastNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setLastName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameSuffixFirstNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameSuffixFirstNameAndLastNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName(null);
|
||||
individualNameFormatterRequestTO.setLastName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameLastNameSuffix());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameLastNameCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName(),
|
||||
actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameMiddleNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setMiddleName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameLastNameNull() {
|
||||
|
||||
individualNameFormatterRequestTO.setLastName(null);
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertNull(actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testPrefixFirstNameMiddleInitialLastNameCorrectFormat() {
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals(expectedIndividualNameFormatterResponseTO.getPrefixFirstNameMiddleInitialLastName(),
|
||||
actualIndividualNameFormatterResponseTO.getPrefixFirstNameMiddleInitialLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameLastNameLastNameOnTheList() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName("JOHN");
|
||||
individualNameFormatterRequestTO.setLastName("LA MONTAGNE");
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals("John La Montagne", actualIndividualNameFormatterResponseTO.getFirstNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameLastNameLastNameSpace() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName("JOHN");
|
||||
individualNameFormatterRequestTO.setMiddleName("JACOB");
|
||||
individualNameFormatterRequestTO.setLastName("JINGLEHEIMER SCHMIDT");
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals("John Jacob Jingleheimer Schmidt",
|
||||
actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameLastNameLastNameHyphen() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName("JOHN");
|
||||
individualNameFormatterRequestTO.setMiddleName("JACOB");
|
||||
individualNameFormatterRequestTO.setLastName("JINGLEHEIMER-SCHMIDT");
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals("John Jacob Jingleheimer-Schmidt",
|
||||
actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testFirstNameMiddleNameLastNameFirstNameHyphen() {
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName("JOHN-SOMETHING");
|
||||
individualNameFormatterRequestTO.setMiddleName("JACOB");
|
||||
individualNameFormatterRequestTO.setLastName("JINGLEHEIMER-SCHMIDT");
|
||||
|
||||
IndividualNameFormatterResponseTO actualIndividualNameFormatterResponseTO = individualNameFormatterService
|
||||
.formatIndividualName(individualNameFormatterRequestTO);
|
||||
|
||||
assertEquals("John-Something Jacob Jingleheimer-Schmidt",
|
||||
actualIndividualNameFormatterResponseTO.getFirstNameMiddleNameLastName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the request.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private IndividualNameFormatterRequestTO generateIndividualNameFormatterRequestTO() {
|
||||
IndividualNameFormatterRequestTO individualNameFormatterRequestTO = new IndividualNameFormatterRequestTO();
|
||||
|
||||
individualNameFormatterRequestTO.setFirstName("JOHN");
|
||||
individualNameFormatterRequestTO.setLastName("GROLLER");
|
||||
individualNameFormatterRequestTO.setPrefix("DR.");
|
||||
individualNameFormatterRequestTO.setSuffix("IV");
|
||||
individualNameFormatterRequestTO.setMiddleName("CHRISTOPHER");
|
||||
individualNameFormatterRequestTO.setPreferredName("JAMES WESTFALL");
|
||||
|
||||
return individualNameFormatterRequestTO;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the expected response.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private IndividualNameFormatterResponseTO generateIndividualNameFormatterResponseTO() {
|
||||
|
||||
IndividualNameFormatterResponseTO individualNameFormatterResponseTO = new IndividualNameFormatterResponseTO();
|
||||
|
||||
individualNameFormatterResponseTO.setFirstName("John");
|
||||
individualNameFormatterResponseTO.setLastName("Groller");
|
||||
individualNameFormatterResponseTO.setPrefix("Dr.");
|
||||
individualNameFormatterResponseTO.setSuffix("IV");
|
||||
individualNameFormatterResponseTO.setMiddleName("Christopher");
|
||||
individualNameFormatterResponseTO.setPreferredName("James Westfall");
|
||||
individualNameFormatterResponseTO.setFirstNameLastNameSuffix("John Groller IV");
|
||||
individualNameFormatterResponseTO.setFirstNameMiddleNameLastName("John Christopher Groller");
|
||||
individualNameFormatterResponseTO.setLastNameFirstName("Groller, John");
|
||||
individualNameFormatterResponseTO.setLastNameFirstNameMiddleInitial("Groller, John C.");
|
||||
individualNameFormatterResponseTO.setPrefixFirstNameLastName("Dr. John Groller");
|
||||
individualNameFormatterResponseTO.setPrefixFirstNameMiddleInitialLastName("Dr. John C. Groller");
|
||||
individualNameFormatterResponseTO.setPrefixLastName("Dr. Groller");
|
||||
individualNameFormatterResponseTO.setProfessionalDesignation("Esquire");
|
||||
|
||||
return individualNameFormatterResponseTO;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user