diff --git a/.jhipster/Country.json b/.jhipster/Country.json new file mode 100644 index 0000000..b06c41a --- /dev/null +++ b/.jhipster/Country.json @@ -0,0 +1,28 @@ +{ + "name": "Country", + "fields": [ + { + "fieldName": "countryName", + "fieldType": "String" + } + ], + "relationships": [ + { + "relationshipType": "one-to-one", + "otherEntityName": "region", + "otherEntityRelationshipName": "country", + "relationshipName": "region", + "otherEntityField": "id", + "ownerSide": true + } + ], + "changelogDate": "20190424132218", + "entityTableName": "country", + "dto": "no", + "pagination": "no", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Department.json b/.jhipster/Department.json new file mode 100644 index 0000000..1ade0ae --- /dev/null +++ b/.jhipster/Department.json @@ -0,0 +1,38 @@ +{ + "name": "Department", + "fields": [ + { + "fieldName": "departmentName", + "fieldType": "String", + "fieldValidateRules": [ + "required" + ] + } + ], + "relationships": [ + { + "relationshipType": "one-to-one", + "otherEntityName": "location", + "otherEntityRelationshipName": "department", + "relationshipName": "location", + "otherEntityField": "id", + "ownerSide": true + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "employee", + "otherEntityRelationshipName": "department", + "javadoc": "A relationship", + "relationshipName": "employee" + } + ], + "changelogDate": "20190424132220", + "entityTableName": "department", + "dto": "no", + "pagination": "no", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Employee.json b/.jhipster/Employee.json new file mode 100644 index 0000000..ddeca5c --- /dev/null +++ b/.jhipster/Employee.json @@ -0,0 +1,65 @@ +{ + "name": "Employee", + "fields": [ + { + "fieldName": "firstName", + "javadoc": "The firstname attribute.", + "fieldType": "String" + }, + { + "fieldName": "lastName", + "fieldType": "String" + }, + { + "fieldName": "email", + "fieldType": "String" + }, + { + "fieldName": "phoneNumber", + "fieldType": "String" + }, + { + "fieldName": "hireDate", + "fieldType": "Instant" + }, + { + "fieldName": "salary", + "fieldType": "Long" + }, + { + "fieldName": "commissionPct", + "fieldType": "Long" + } + ], + "relationships": [ + { + "relationshipName": "department", + "otherEntityName": "department", + "relationshipType": "many-to-one", + "otherEntityField": "id" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "job", + "otherEntityRelationshipName": "employee", + "relationshipName": "job" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "employee", + "otherEntityRelationshipName": "employee", + "relationshipName": "manager", + "otherEntityField": "id" + } + ], + "changelogDate": "20190424132222", + "javadoc": "The Employee entity.", + "entityTableName": "employee", + "dto": "no", + "pagination": "infinite-scroll", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Job.json b/.jhipster/Job.json new file mode 100644 index 0000000..2e2ad6b --- /dev/null +++ b/.jhipster/Job.json @@ -0,0 +1,42 @@ +{ + "name": "Job", + "fields": [ + { + "fieldName": "jobTitle", + "fieldType": "String" + }, + { + "fieldName": "minSalary", + "fieldType": "Long" + }, + { + "fieldName": "maxSalary", + "fieldType": "Long" + } + ], + "relationships": [ + { + "relationshipName": "employee", + "otherEntityName": "employee", + "relationshipType": "many-to-one", + "otherEntityField": "id" + }, + { + "relationshipType": "many-to-many", + "otherEntityName": "task", + "otherEntityRelationshipName": "job", + "relationshipName": "task", + "otherEntityField": "title", + "ownerSide": true + } + ], + "changelogDate": "20190424132223", + "entityTableName": "job", + "dto": "no", + "pagination": "pagination", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/JobHistory.json b/.jhipster/JobHistory.json new file mode 100644 index 0000000..02a3ae5 --- /dev/null +++ b/.jhipster/JobHistory.json @@ -0,0 +1,53 @@ +{ + "name": "JobHistory", + "fields": [ + { + "fieldName": "startDate", + "fieldType": "Instant" + }, + { + "fieldName": "endDate", + "fieldType": "Instant" + }, + { + "fieldName": "language", + "fieldType": "Language", + "fieldValues": "FRENCH,ENGLISH,SPANISH" + } + ], + "relationships": [ + { + "relationshipType": "one-to-one", + "otherEntityName": "job", + "otherEntityRelationshipName": "jobHistory", + "relationshipName": "job", + "otherEntityField": "id", + "ownerSide": true + }, + { + "relationshipType": "one-to-one", + "otherEntityName": "department", + "otherEntityRelationshipName": "jobHistory", + "relationshipName": "department", + "otherEntityField": "id", + "ownerSide": true + }, + { + "relationshipType": "one-to-one", + "otherEntityName": "employee", + "otherEntityRelationshipName": "jobHistory", + "relationshipName": "employee", + "otherEntityField": "id", + "ownerSide": true + } + ], + "changelogDate": "20190424132224", + "entityTableName": "job_history", + "dto": "no", + "pagination": "infinite-scroll", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Location.json b/.jhipster/Location.json new file mode 100644 index 0000000..9bb815c --- /dev/null +++ b/.jhipster/Location.json @@ -0,0 +1,41 @@ +{ + "name": "Location", + "fields": [ + { + "fieldName": "streetAddress", + "fieldType": "String" + }, + { + "fieldName": "postalCode", + "fieldType": "String" + }, + { + "fieldName": "city", + "fieldType": "String" + }, + { + "fieldName": "stateProvince", + "fieldType": "String" + } + ], + "relationships": [ + { + "relationshipType": "one-to-one", + "otherEntityName": "country", + "otherEntityRelationshipName": "location", + "relationshipName": "country", + "otherEntityField": "id", + "ownerSide": true + } + ], + "changelogDate": "20190424132219", + "javadoc": "not an ignored comment", + "entityTableName": "location", + "dto": "no", + "pagination": "no", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Region.json b/.jhipster/Region.json new file mode 100644 index 0000000..997a159 --- /dev/null +++ b/.jhipster/Region.json @@ -0,0 +1,19 @@ +{ + "name": "Region", + "fields": [ + { + "fieldName": "regionName", + "fieldType": "String" + } + ], + "relationships": [], + "changelogDate": "20190424132217", + "entityTableName": "region", + "dto": "no", + "pagination": "no", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Task.json b/.jhipster/Task.json new file mode 100644 index 0000000..ee9720f --- /dev/null +++ b/.jhipster/Task.json @@ -0,0 +1,33 @@ +{ + "name": "Task", + "fields": [ + { + "fieldName": "title", + "fieldType": "String" + }, + { + "fieldName": "description", + "fieldType": "String" + } + ], + "relationships": [ + { + "relationshipType": "many-to-many", + "otherEntityName": "job", + "otherEntityRelationshipName": "task", + "relationshipName": "job", + "otherEntityField": "id", + "ownerSide": false + } + ], + "changelogDate": "20190424132221", + "javadoc": "Task entity.\n@author The JHipster team.", + "entityTableName": "task", + "dto": "no", + "pagination": "no", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/src/main/java/com/cooperl/si/integration/ui/config/CacheConfiguration.java b/src/main/java/com/cooperl/si/integration/ui/config/CacheConfiguration.java index 7ea03b9..0791367 100644 --- a/src/main/java/com/cooperl/si/integration/ui/config/CacheConfiguration.java +++ b/src/main/java/com/cooperl/si/integration/ui/config/CacheConfiguration.java @@ -38,6 +38,18 @@ public JCacheManagerCustomizer cacheManagerCustomizer() { cm.createCache(com.cooperl.si.integration.ui.domain.User.class.getName(), jcacheConfiguration); cm.createCache(com.cooperl.si.integration.ui.domain.Authority.class.getName(), jcacheConfiguration); cm.createCache(com.cooperl.si.integration.ui.domain.User.class.getName() + ".authorities", jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Region.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Country.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Location.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Department.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Department.class.getName() + ".employees", jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Task.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Task.class.getName() + ".jobs", jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Employee.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Employee.class.getName() + ".jobs", jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Job.class.getName(), jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.Job.class.getName() + ".tasks", jcacheConfiguration); + cm.createCache(com.cooperl.si.integration.ui.domain.JobHistory.class.getName(), jcacheConfiguration); // jhipster-needle-ehcache-add-entry }; } diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Country.java b/src/main/java/com/cooperl/si/integration/ui/domain/Country.java new file mode 100644 index 0000000..ca45039 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Country.java @@ -0,0 +1,97 @@ +package com.cooperl.si.integration.ui.domain; + + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A Country. + */ +@Entity +@Table(name = "country") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Country implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "country_name") + private String countryName; + + @OneToOne + @JoinColumn(unique = true) + private Region region; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCountryName() { + return countryName; + } + + public Country countryName(String countryName) { + this.countryName = countryName; + return this; + } + + public void setCountryName(String countryName) { + this.countryName = countryName; + } + + public Region getRegion() { + return region; + } + + public Country region(Region region) { + this.region = region; + return this; + } + + public void setRegion(Region region) { + this.region = region; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Country country = (Country) o; + if (country.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), country.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Country{" + + "id=" + getId() + + ", countryName='" + getCountryName() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Department.java b/src/main/java/com/cooperl/si/integration/ui/domain/Department.java new file mode 100644 index 0000000..5e239ca --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Department.java @@ -0,0 +1,135 @@ +package com.cooperl.si.integration.ui.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * A Department. + */ +@Entity +@Table(name = "department") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Department implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Column(name = "department_name", nullable = false) + private String departmentName; + + @OneToOne + @JoinColumn(unique = true) + private Location location; + + /** + * A relationship + */ + @ApiModelProperty(value = "A relationship") + @OneToMany(mappedBy = "department") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + private Set employees = new HashSet<>(); + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getDepartmentName() { + return departmentName; + } + + public Department departmentName(String departmentName) { + this.departmentName = departmentName; + return this; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Location getLocation() { + return location; + } + + public Department location(Location location) { + this.location = location; + return this; + } + + public void setLocation(Location location) { + this.location = location; + } + + public Set getEmployees() { + return employees; + } + + public Department employees(Set employees) { + this.employees = employees; + return this; + } + + public Department addEmployee(Employee employee) { + this.employees.add(employee); + employee.setDepartment(this); + return this; + } + + public Department removeEmployee(Employee employee) { + this.employees.remove(employee); + employee.setDepartment(null); + return this; + } + + public void setEmployees(Set employees) { + this.employees = employees; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Department department = (Department) o; + if (department.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), department.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Department{" + + "id=" + getId() + + ", departmentName='" + getDepartmentName() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Employee.java b/src/main/java/com/cooperl/si/integration/ui/domain/Employee.java new file mode 100644 index 0000000..faffa6a --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Employee.java @@ -0,0 +1,256 @@ +package com.cooperl.si.integration.ui.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.time.Instant; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * The Employee entity. + */ +@ApiModel(description = "The Employee entity.") +@Entity +@Table(name = "employee") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Employee implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + /** + * The firstname attribute. + */ + @ApiModelProperty(value = "The firstname attribute.") + @Column(name = "first_name") + private String firstName; + + @Column(name = "last_name") + private String lastName; + + @Column(name = "email") + private String email; + + @Column(name = "phone_number") + private String phoneNumber; + + @Column(name = "hire_date") + private Instant hireDate; + + @Column(name = "salary") + private Long salary; + + @Column(name = "commission_pct") + private Long commissionPct; + + @ManyToOne + @JsonIgnoreProperties("employees") + private Department department; + + @OneToMany(mappedBy = "employee") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + private Set jobs = new HashSet<>(); + @ManyToOne + @JsonIgnoreProperties("employees") + private Employee manager; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public Employee firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public Employee lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public Employee email(String email) { + this.email = email; + return this; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public Employee phoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Instant getHireDate() { + return hireDate; + } + + public Employee hireDate(Instant hireDate) { + this.hireDate = hireDate; + return this; + } + + public void setHireDate(Instant hireDate) { + this.hireDate = hireDate; + } + + public Long getSalary() { + return salary; + } + + public Employee salary(Long salary) { + this.salary = salary; + return this; + } + + public void setSalary(Long salary) { + this.salary = salary; + } + + public Long getCommissionPct() { + return commissionPct; + } + + public Employee commissionPct(Long commissionPct) { + this.commissionPct = commissionPct; + return this; + } + + public void setCommissionPct(Long commissionPct) { + this.commissionPct = commissionPct; + } + + public Department getDepartment() { + return department; + } + + public Employee department(Department department) { + this.department = department; + return this; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Set getJobs() { + return jobs; + } + + public Employee jobs(Set jobs) { + this.jobs = jobs; + return this; + } + + public Employee addJob(Job job) { + this.jobs.add(job); + job.setEmployee(this); + return this; + } + + public Employee removeJob(Job job) { + this.jobs.remove(job); + job.setEmployee(null); + return this; + } + + public void setJobs(Set jobs) { + this.jobs = jobs; + } + + public Employee getManager() { + return manager; + } + + public Employee manager(Employee employee) { + this.manager = employee; + return this; + } + + public void setManager(Employee employee) { + this.manager = employee; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Employee employee = (Employee) o; + if (employee.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), employee.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Employee{" + + "id=" + getId() + + ", firstName='" + getFirstName() + "'" + + ", lastName='" + getLastName() + "'" + + ", email='" + getEmail() + "'" + + ", phoneNumber='" + getPhoneNumber() + "'" + + ", hireDate='" + getHireDate() + "'" + + ", salary=" + getSalary() + + ", commissionPct=" + getCommissionPct() + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Job.java b/src/main/java/com/cooperl/si/integration/ui/domain/Job.java new file mode 100644 index 0000000..4d42068 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Job.java @@ -0,0 +1,166 @@ +package com.cooperl.si.integration.ui.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * A Job. + */ +@Entity +@Table(name = "job") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Job implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "job_title") + private String jobTitle; + + @Column(name = "min_salary") + private Long minSalary; + + @Column(name = "max_salary") + private Long maxSalary; + + @ManyToOne + @JsonIgnoreProperties("jobs") + private Employee employee; + + @ManyToMany + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JoinTable(name = "job_task", + joinColumns = @JoinColumn(name = "job_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "task_id", referencedColumnName = "id")) + private Set tasks = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getJobTitle() { + return jobTitle; + } + + public Job jobTitle(String jobTitle) { + this.jobTitle = jobTitle; + return this; + } + + public void setJobTitle(String jobTitle) { + this.jobTitle = jobTitle; + } + + public Long getMinSalary() { + return minSalary; + } + + public Job minSalary(Long minSalary) { + this.minSalary = minSalary; + return this; + } + + public void setMinSalary(Long minSalary) { + this.minSalary = minSalary; + } + + public Long getMaxSalary() { + return maxSalary; + } + + public Job maxSalary(Long maxSalary) { + this.maxSalary = maxSalary; + return this; + } + + public void setMaxSalary(Long maxSalary) { + this.maxSalary = maxSalary; + } + + public Employee getEmployee() { + return employee; + } + + public Job employee(Employee employee) { + this.employee = employee; + return this; + } + + public void setEmployee(Employee employee) { + this.employee = employee; + } + + public Set getTasks() { + return tasks; + } + + public Job tasks(Set tasks) { + this.tasks = tasks; + return this; + } + + public Job addTask(Task task) { + this.tasks.add(task); + task.getJobs().add(this); + return this; + } + + public Job removeTask(Task task) { + this.tasks.remove(task); + task.getJobs().remove(this); + return this; + } + + public void setTasks(Set tasks) { + this.tasks = tasks; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Job job = (Job) o; + if (job.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), job.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Job{" + + "id=" + getId() + + ", jobTitle='" + getJobTitle() + "'" + + ", minSalary=" + getMinSalary() + + ", maxSalary=" + getMaxSalary() + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/JobHistory.java b/src/main/java/com/cooperl/si/integration/ui/domain/JobHistory.java new file mode 100644 index 0000000..1593678 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/JobHistory.java @@ -0,0 +1,169 @@ +package com.cooperl.si.integration.ui.domain; + + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.time.Instant; +import java.util.Objects; + +import com.cooperl.si.integration.ui.domain.enumeration.Language; + +/** + * A JobHistory. + */ +@Entity +@Table(name = "job_history") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class JobHistory implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "start_date") + private Instant startDate; + + @Column(name = "end_date") + private Instant endDate; + + @Enumerated(EnumType.STRING) + @Column(name = "language") + private Language language; + + @OneToOne + @JoinColumn(unique = true) + private Job job; + + @OneToOne + @JoinColumn(unique = true) + private Department department; + + @OneToOne + @JoinColumn(unique = true) + private Employee employee; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getStartDate() { + return startDate; + } + + public JobHistory startDate(Instant startDate) { + this.startDate = startDate; + return this; + } + + public void setStartDate(Instant startDate) { + this.startDate = startDate; + } + + public Instant getEndDate() { + return endDate; + } + + public JobHistory endDate(Instant endDate) { + this.endDate = endDate; + return this; + } + + public void setEndDate(Instant endDate) { + this.endDate = endDate; + } + + public Language getLanguage() { + return language; + } + + public JobHistory language(Language language) { + this.language = language; + return this; + } + + public void setLanguage(Language language) { + this.language = language; + } + + public Job getJob() { + return job; + } + + public JobHistory job(Job job) { + this.job = job; + return this; + } + + public void setJob(Job job) { + this.job = job; + } + + public Department getDepartment() { + return department; + } + + public JobHistory department(Department department) { + this.department = department; + return this; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Employee getEmployee() { + return employee; + } + + public JobHistory employee(Employee employee) { + this.employee = employee; + return this; + } + + public void setEmployee(Employee employee) { + this.employee = employee; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + JobHistory jobHistory = (JobHistory) o; + if (jobHistory.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), jobHistory.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "JobHistory{" + + "id=" + getId() + + ", startDate='" + getStartDate() + "'" + + ", endDate='" + getEndDate() + "'" + + ", language='" + getLanguage() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Location.java b/src/main/java/com/cooperl/si/integration/ui/domain/Location.java new file mode 100644 index 0000000..62ecaf6 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Location.java @@ -0,0 +1,150 @@ +package com.cooperl.si.integration.ui.domain; + + +import io.swagger.annotations.ApiModel; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * not an ignored comment + */ +@ApiModel(description = "not an ignored comment") +@Entity +@Table(name = "location") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Location implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "street_address") + private String streetAddress; + + @Column(name = "postal_code") + private String postalCode; + + @Column(name = "city") + private String city; + + @Column(name = "state_province") + private String stateProvince; + + @OneToOne + @JoinColumn(unique = true) + private Country country; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getStreetAddress() { + return streetAddress; + } + + public Location streetAddress(String streetAddress) { + this.streetAddress = streetAddress; + return this; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + public String getPostalCode() { + return postalCode; + } + + public Location postalCode(String postalCode) { + this.postalCode = postalCode; + return this; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getCity() { + return city; + } + + public Location city(String city) { + this.city = city; + return this; + } + + public void setCity(String city) { + this.city = city; + } + + public String getStateProvince() { + return stateProvince; + } + + public Location stateProvince(String stateProvince) { + this.stateProvince = stateProvince; + return this; + } + + public void setStateProvince(String stateProvince) { + this.stateProvince = stateProvince; + } + + public Country getCountry() { + return country; + } + + public Location country(Country country) { + this.country = country; + return this; + } + + public void setCountry(Country country) { + this.country = country; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Location location = (Location) o; + if (location.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), location.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Location{" + + "id=" + getId() + + ", streetAddress='" + getStreetAddress() + "'" + + ", postalCode='" + getPostalCode() + "'" + + ", city='" + getCity() + "'" + + ", stateProvince='" + getStateProvince() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Region.java b/src/main/java/com/cooperl/si/integration/ui/domain/Region.java new file mode 100644 index 0000000..6747819 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Region.java @@ -0,0 +1,80 @@ +package com.cooperl.si.integration.ui.domain; + + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A Region. + */ +@Entity +@Table(name = "region") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Region implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "region_name") + private String regionName; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getRegionName() { + return regionName; + } + + public Region regionName(String regionName) { + this.regionName = regionName; + return this; + } + + public void setRegionName(String regionName) { + this.regionName = regionName; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Region region = (Region) o; + if (region.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), region.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Region{" + + "id=" + getId() + + ", regionName='" + getRegionName() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/Task.java b/src/main/java/com/cooperl/si/integration/ui/domain/Task.java new file mode 100644 index 0000000..24bf367 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/Task.java @@ -0,0 +1,133 @@ +package com.cooperl.si.integration.ui.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * Task entity. + * @author The JHipster team. + */ +@ApiModel(description = "Task entity. @author The JHipster team.") +@Entity +@Table(name = "task") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Task implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "title") + private String title; + + @Column(name = "description") + private String description; + + @ManyToMany(mappedBy = "tasks") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JsonIgnore + private Set jobs = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public Task title(String title) { + this.title = title; + return this; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public Task description(String description) { + this.description = description; + return this; + } + + public void setDescription(String description) { + this.description = description; + } + + public Set getJobs() { + return jobs; + } + + public Task jobs(Set jobs) { + this.jobs = jobs; + return this; + } + + public Task addJob(Job job) { + this.jobs.add(job); + job.getTasks().add(this); + return this; + } + + public Task removeJob(Job job) { + this.jobs.remove(job); + job.getTasks().remove(this); + return this; + } + + public void setJobs(Set jobs) { + this.jobs = jobs; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Task task = (Task) o; + if (task.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), task.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Task{" + + "id=" + getId() + + ", title='" + getTitle() + "'" + + ", description='" + getDescription() + "'" + + "}"; + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/domain/enumeration/Language.java b/src/main/java/com/cooperl/si/integration/ui/domain/enumeration/Language.java new file mode 100644 index 0000000..dd5cdf4 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/domain/enumeration/Language.java @@ -0,0 +1,8 @@ +package com.cooperl.si.integration.ui.domain.enumeration; + +/** + * The Language enumeration. + */ +public enum Language { + FRENCH, ENGLISH, SPANISH +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/CountryRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/CountryRepository.java new file mode 100644 index 0000000..78a3bf7 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/CountryRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Country; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Country entity. + */ +@SuppressWarnings("unused") +@Repository +public interface CountryRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/DepartmentRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/DepartmentRepository.java new file mode 100644 index 0000000..2725edd --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/DepartmentRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Department; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Department entity. + */ +@SuppressWarnings("unused") +@Repository +public interface DepartmentRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/EmployeeRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/EmployeeRepository.java new file mode 100644 index 0000000..b8a23ce --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/EmployeeRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Employee; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Employee entity. + */ +@SuppressWarnings("unused") +@Repository +public interface EmployeeRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/JobHistoryRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/JobHistoryRepository.java new file mode 100644 index 0000000..e7e3ad6 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/JobHistoryRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.JobHistory; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the JobHistory entity. + */ +@SuppressWarnings("unused") +@Repository +public interface JobHistoryRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/JobRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/JobRepository.java new file mode 100644 index 0000000..e8ab117 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/JobRepository.java @@ -0,0 +1,30 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Job; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +/** + * Spring Data repository for the Job entity. + */ +@SuppressWarnings("unused") +@Repository +public interface JobRepository extends JpaRepository { + + @Query(value = "select distinct job from Job job left join fetch job.tasks", + countQuery = "select count(distinct job) from Job job") + Page findAllWithEagerRelationships(Pageable pageable); + + @Query(value = "select distinct job from Job job left join fetch job.tasks") + List findAllWithEagerRelationships(); + + @Query("select job from Job job left join fetch job.tasks where job.id =:id") + Optional findOneWithEagerRelationships(@Param("id") Long id); + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/LocationRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/LocationRepository.java new file mode 100644 index 0000000..298b258 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/LocationRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Location; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Location entity. + */ +@SuppressWarnings("unused") +@Repository +public interface LocationRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/RegionRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/RegionRepository.java new file mode 100644 index 0000000..33ede98 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/RegionRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Region; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Region entity. + */ +@SuppressWarnings("unused") +@Repository +public interface RegionRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/repository/TaskRepository.java b/src/main/java/com/cooperl/si/integration/ui/repository/TaskRepository.java new file mode 100644 index 0000000..6a9cc55 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/repository/TaskRepository.java @@ -0,0 +1,15 @@ +package com.cooperl.si.integration.ui.repository; + +import com.cooperl.si.integration.ui.domain.Task; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Task entity. + */ +@SuppressWarnings("unused") +@Repository +public interface TaskRepository extends JpaRepository { + +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/CountryService.java b/src/main/java/com/cooperl/si/integration/ui/service/CountryService.java new file mode 100644 index 0000000..8fe4615 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/CountryService.java @@ -0,0 +1,43 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.Country; + +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing Country. + */ +public interface CountryService { + + /** + * Save a country. + * + * @param country the entity to save + * @return the persisted entity + */ + Country save(Country country); + + /** + * Get all the countries. + * + * @return the list of entities + */ + List findAll(); + + + /** + * Get the "id" country. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" country. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/DepartmentService.java b/src/main/java/com/cooperl/si/integration/ui/service/DepartmentService.java new file mode 100644 index 0000000..bd3c1ff --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/DepartmentService.java @@ -0,0 +1,43 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.Department; + +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing Department. + */ +public interface DepartmentService { + + /** + * Save a department. + * + * @param department the entity to save + * @return the persisted entity + */ + Department save(Department department); + + /** + * Get all the departments. + * + * @return the list of entities + */ + List findAll(); + + + /** + * Get the "id" department. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" department. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/JobHistoryService.java b/src/main/java/com/cooperl/si/integration/ui/service/JobHistoryService.java new file mode 100644 index 0000000..e59fa50 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/JobHistoryService.java @@ -0,0 +1,46 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.JobHistory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing JobHistory. + */ +public interface JobHistoryService { + + /** + * Save a jobHistory. + * + * @param jobHistory the entity to save + * @return the persisted entity + */ + JobHistory save(JobHistory jobHistory); + + /** + * Get all the jobHistories. + * + * @param pageable the pagination information + * @return the list of entities + */ + Page findAll(Pageable pageable); + + + /** + * Get the "id" jobHistory. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" jobHistory. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/LocationService.java b/src/main/java/com/cooperl/si/integration/ui/service/LocationService.java new file mode 100644 index 0000000..5d22df6 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/LocationService.java @@ -0,0 +1,43 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.Location; + +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing Location. + */ +public interface LocationService { + + /** + * Save a location. + * + * @param location the entity to save + * @return the persisted entity + */ + Location save(Location location); + + /** + * Get all the locations. + * + * @return the list of entities + */ + List findAll(); + + + /** + * Get the "id" location. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" location. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/RegionService.java b/src/main/java/com/cooperl/si/integration/ui/service/RegionService.java new file mode 100644 index 0000000..4c10b26 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/RegionService.java @@ -0,0 +1,43 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.Region; + +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing Region. + */ +public interface RegionService { + + /** + * Save a region. + * + * @param region the entity to save + * @return the persisted entity + */ + Region save(Region region); + + /** + * Get all the regions. + * + * @return the list of entities + */ + List findAll(); + + + /** + * Get the "id" region. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" region. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/TaskService.java b/src/main/java/com/cooperl/si/integration/ui/service/TaskService.java new file mode 100644 index 0000000..a71317a --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/TaskService.java @@ -0,0 +1,43 @@ +package com.cooperl.si.integration.ui.service; + +import com.cooperl.si.integration.ui.domain.Task; + +import java.util.List; +import java.util.Optional; + +/** + * Service Interface for managing Task. + */ +public interface TaskService { + + /** + * Save a task. + * + * @param task the entity to save + * @return the persisted entity + */ + Task save(Task task); + + /** + * Get all the tasks. + * + * @return the list of entities + */ + List findAll(); + + + /** + * Get the "id" task. + * + * @param id the id of the entity + * @return the entity + */ + Optional findOne(Long id); + + /** + * Delete the "id" task. + * + * @param id the id of the entity + */ + void delete(Long id); +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/CountryServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/CountryServiceImpl.java new file mode 100644 index 0000000..76413e9 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/CountryServiceImpl.java @@ -0,0 +1,78 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.CountryService; +import com.cooperl.si.integration.ui.domain.Country; +import com.cooperl.si.integration.ui.repository.CountryRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * Service Implementation for managing Country. + */ +@Service +@Transactional +public class CountryServiceImpl implements CountryService { + + private final Logger log = LoggerFactory.getLogger(CountryServiceImpl.class); + + private final CountryRepository countryRepository; + + public CountryServiceImpl(CountryRepository countryRepository) { + this.countryRepository = countryRepository; + } + + /** + * Save a country. + * + * @param country the entity to save + * @return the persisted entity + */ + @Override + public Country save(Country country) { + log.debug("Request to save Country : {}", country); + return countryRepository.save(country); + } + + /** + * Get all the countries. + * + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public List findAll() { + log.debug("Request to get all Countries"); + return countryRepository.findAll(); + } + + + /** + * Get one country by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Country : {}", id); + return countryRepository.findById(id); + } + + /** + * Delete the country by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Country : {}", id); + countryRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/DepartmentServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/DepartmentServiceImpl.java new file mode 100644 index 0000000..4c2c06e --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,78 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.DepartmentService; +import com.cooperl.si.integration.ui.domain.Department; +import com.cooperl.si.integration.ui.repository.DepartmentRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * Service Implementation for managing Department. + */ +@Service +@Transactional +public class DepartmentServiceImpl implements DepartmentService { + + private final Logger log = LoggerFactory.getLogger(DepartmentServiceImpl.class); + + private final DepartmentRepository departmentRepository; + + public DepartmentServiceImpl(DepartmentRepository departmentRepository) { + this.departmentRepository = departmentRepository; + } + + /** + * Save a department. + * + * @param department the entity to save + * @return the persisted entity + */ + @Override + public Department save(Department department) { + log.debug("Request to save Department : {}", department); + return departmentRepository.save(department); + } + + /** + * Get all the departments. + * + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public List findAll() { + log.debug("Request to get all Departments"); + return departmentRepository.findAll(); + } + + + /** + * Get one department by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Department : {}", id); + return departmentRepository.findById(id); + } + + /** + * Delete the department by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Department : {}", id); + departmentRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/JobHistoryServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/JobHistoryServiceImpl.java new file mode 100644 index 0000000..15ad2cc --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/JobHistoryServiceImpl.java @@ -0,0 +1,80 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.JobHistoryService; +import com.cooperl.si.integration.ui.domain.JobHistory; +import com.cooperl.si.integration.ui.repository.JobHistoryRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing JobHistory. + */ +@Service +@Transactional +public class JobHistoryServiceImpl implements JobHistoryService { + + private final Logger log = LoggerFactory.getLogger(JobHistoryServiceImpl.class); + + private final JobHistoryRepository jobHistoryRepository; + + public JobHistoryServiceImpl(JobHistoryRepository jobHistoryRepository) { + this.jobHistoryRepository = jobHistoryRepository; + } + + /** + * Save a jobHistory. + * + * @param jobHistory the entity to save + * @return the persisted entity + */ + @Override + public JobHistory save(JobHistory jobHistory) { + log.debug("Request to save JobHistory : {}", jobHistory); + return jobHistoryRepository.save(jobHistory); + } + + /** + * Get all the jobHistories. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all JobHistories"); + return jobHistoryRepository.findAll(pageable); + } + + + /** + * Get one jobHistory by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get JobHistory : {}", id); + return jobHistoryRepository.findById(id); + } + + /** + * Delete the jobHistory by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete JobHistory : {}", id); + jobHistoryRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/LocationServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/LocationServiceImpl.java new file mode 100644 index 0000000..8e049ce --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/LocationServiceImpl.java @@ -0,0 +1,78 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.LocationService; +import com.cooperl.si.integration.ui.domain.Location; +import com.cooperl.si.integration.ui.repository.LocationRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * Service Implementation for managing Location. + */ +@Service +@Transactional +public class LocationServiceImpl implements LocationService { + + private final Logger log = LoggerFactory.getLogger(LocationServiceImpl.class); + + private final LocationRepository locationRepository; + + public LocationServiceImpl(LocationRepository locationRepository) { + this.locationRepository = locationRepository; + } + + /** + * Save a location. + * + * @param location the entity to save + * @return the persisted entity + */ + @Override + public Location save(Location location) { + log.debug("Request to save Location : {}", location); + return locationRepository.save(location); + } + + /** + * Get all the locations. + * + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public List findAll() { + log.debug("Request to get all Locations"); + return locationRepository.findAll(); + } + + + /** + * Get one location by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Location : {}", id); + return locationRepository.findById(id); + } + + /** + * Delete the location by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Location : {}", id); + locationRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/RegionServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/RegionServiceImpl.java new file mode 100644 index 0000000..396d63c --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/RegionServiceImpl.java @@ -0,0 +1,78 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.RegionService; +import com.cooperl.si.integration.ui.domain.Region; +import com.cooperl.si.integration.ui.repository.RegionRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * Service Implementation for managing Region. + */ +@Service +@Transactional +public class RegionServiceImpl implements RegionService { + + private final Logger log = LoggerFactory.getLogger(RegionServiceImpl.class); + + private final RegionRepository regionRepository; + + public RegionServiceImpl(RegionRepository regionRepository) { + this.regionRepository = regionRepository; + } + + /** + * Save a region. + * + * @param region the entity to save + * @return the persisted entity + */ + @Override + public Region save(Region region) { + log.debug("Request to save Region : {}", region); + return regionRepository.save(region); + } + + /** + * Get all the regions. + * + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public List findAll() { + log.debug("Request to get all Regions"); + return regionRepository.findAll(); + } + + + /** + * Get one region by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Region : {}", id); + return regionRepository.findById(id); + } + + /** + * Delete the region by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Region : {}", id); + regionRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/service/impl/TaskServiceImpl.java b/src/main/java/com/cooperl/si/integration/ui/service/impl/TaskServiceImpl.java new file mode 100644 index 0000000..64aa49b --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/service/impl/TaskServiceImpl.java @@ -0,0 +1,78 @@ +package com.cooperl.si.integration.ui.service.impl; + +import com.cooperl.si.integration.ui.service.TaskService; +import com.cooperl.si.integration.ui.domain.Task; +import com.cooperl.si.integration.ui.repository.TaskRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +/** + * Service Implementation for managing Task. + */ +@Service +@Transactional +public class TaskServiceImpl implements TaskService { + + private final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class); + + private final TaskRepository taskRepository; + + public TaskServiceImpl(TaskRepository taskRepository) { + this.taskRepository = taskRepository; + } + + /** + * Save a task. + * + * @param task the entity to save + * @return the persisted entity + */ + @Override + public Task save(Task task) { + log.debug("Request to save Task : {}", task); + return taskRepository.save(task); + } + + /** + * Get all the tasks. + * + * @return the list of entities + */ + @Override + @Transactional(readOnly = true) + public List findAll() { + log.debug("Request to get all Tasks"); + return taskRepository.findAll(); + } + + + /** + * Get one task by id. + * + * @param id the id of the entity + * @return the entity + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Task : {}", id); + return taskRepository.findById(id); + } + + /** + * Delete the task by id. + * + * @param id the id of the entity + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Task : {}", id); + taskRepository.deleteById(id); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/CountryResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/CountryResource.java new file mode 100644 index 0000000..7eccffa --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/CountryResource.java @@ -0,0 +1,111 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Country; +import com.cooperl.si.integration.ui.service.CountryService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Country. + */ +@RestController +@RequestMapping("/api") +public class CountryResource { + + private final Logger log = LoggerFactory.getLogger(CountryResource.class); + + private static final String ENTITY_NAME = "country"; + + private final CountryService countryService; + + public CountryResource(CountryService countryService) { + this.countryService = countryService; + } + + /** + * POST /countries : Create a new country. + * + * @param country the country to create + * @return the ResponseEntity with status 201 (Created) and with body the new country, or with status 400 (Bad Request) if the country has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/countries") + public ResponseEntity createCountry(@RequestBody Country country) throws URISyntaxException { + log.debug("REST request to save Country : {}", country); + if (country.getId() != null) { + throw new BadRequestAlertException("A new country cannot already have an ID", ENTITY_NAME, "idexists"); + } + Country result = countryService.save(country); + return ResponseEntity.created(new URI("/api/countries/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /countries : Updates an existing country. + * + * @param country the country to update + * @return the ResponseEntity with status 200 (OK) and with body the updated country, + * or with status 400 (Bad Request) if the country is not valid, + * or with status 500 (Internal Server Error) if the country couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/countries") + public ResponseEntity updateCountry(@RequestBody Country country) throws URISyntaxException { + log.debug("REST request to update Country : {}", country); + if (country.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Country result = countryService.save(country); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, country.getId().toString())) + .body(result); + } + + /** + * GET /countries : get all the countries. + * + * @return the ResponseEntity with status 200 (OK) and the list of countries in body + */ + @GetMapping("/countries") + public List getAllCountries() { + log.debug("REST request to get all Countries"); + return countryService.findAll(); + } + + /** + * GET /countries/:id : get the "id" country. + * + * @param id the id of the country to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the country, or with status 404 (Not Found) + */ + @GetMapping("/countries/{id}") + public ResponseEntity getCountry(@PathVariable Long id) { + log.debug("REST request to get Country : {}", id); + Optional country = countryService.findOne(id); + return ResponseUtil.wrapOrNotFound(country); + } + + /** + * DELETE /countries/:id : delete the "id" country. + * + * @param id the id of the country to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/countries/{id}") + public ResponseEntity deleteCountry(@PathVariable Long id) { + log.debug("REST request to delete Country : {}", id); + countryService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/DepartmentResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/DepartmentResource.java new file mode 100644 index 0000000..3df2370 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/DepartmentResource.java @@ -0,0 +1,112 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Department; +import com.cooperl.si.integration.ui.service.DepartmentService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Department. + */ +@RestController +@RequestMapping("/api") +public class DepartmentResource { + + private final Logger log = LoggerFactory.getLogger(DepartmentResource.class); + + private static final String ENTITY_NAME = "department"; + + private final DepartmentService departmentService; + + public DepartmentResource(DepartmentService departmentService) { + this.departmentService = departmentService; + } + + /** + * POST /departments : Create a new department. + * + * @param department the department to create + * @return the ResponseEntity with status 201 (Created) and with body the new department, or with status 400 (Bad Request) if the department has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/departments") + public ResponseEntity createDepartment(@Valid @RequestBody Department department) throws URISyntaxException { + log.debug("REST request to save Department : {}", department); + if (department.getId() != null) { + throw new BadRequestAlertException("A new department cannot already have an ID", ENTITY_NAME, "idexists"); + } + Department result = departmentService.save(department); + return ResponseEntity.created(new URI("/api/departments/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /departments : Updates an existing department. + * + * @param department the department to update + * @return the ResponseEntity with status 200 (OK) and with body the updated department, + * or with status 400 (Bad Request) if the department is not valid, + * or with status 500 (Internal Server Error) if the department couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/departments") + public ResponseEntity updateDepartment(@Valid @RequestBody Department department) throws URISyntaxException { + log.debug("REST request to update Department : {}", department); + if (department.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Department result = departmentService.save(department); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, department.getId().toString())) + .body(result); + } + + /** + * GET /departments : get all the departments. + * + * @return the ResponseEntity with status 200 (OK) and the list of departments in body + */ + @GetMapping("/departments") + public List getAllDepartments() { + log.debug("REST request to get all Departments"); + return departmentService.findAll(); + } + + /** + * GET /departments/:id : get the "id" department. + * + * @param id the id of the department to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the department, or with status 404 (Not Found) + */ + @GetMapping("/departments/{id}") + public ResponseEntity getDepartment(@PathVariable Long id) { + log.debug("REST request to get Department : {}", id); + Optional department = departmentService.findOne(id); + return ResponseUtil.wrapOrNotFound(department); + } + + /** + * DELETE /departments/:id : delete the "id" department. + * + * @param id the id of the department to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/departments/{id}") + public ResponseEntity deleteDepartment(@PathVariable Long id) { + log.debug("REST request to delete Department : {}", id); + departmentService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/EmployeeResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/EmployeeResource.java new file mode 100644 index 0000000..5b0756a --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/EmployeeResource.java @@ -0,0 +1,119 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Employee; +import com.cooperl.si.integration.ui.repository.EmployeeRepository; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import com.cooperl.si.integration.ui.web.rest.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Employee. + */ +@RestController +@RequestMapping("/api") +public class EmployeeResource { + + private final Logger log = LoggerFactory.getLogger(EmployeeResource.class); + + private static final String ENTITY_NAME = "employee"; + + private final EmployeeRepository employeeRepository; + + public EmployeeResource(EmployeeRepository employeeRepository) { + this.employeeRepository = employeeRepository; + } + + /** + * POST /employees : Create a new employee. + * + * @param employee the employee to create + * @return the ResponseEntity with status 201 (Created) and with body the new employee, or with status 400 (Bad Request) if the employee has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/employees") + public ResponseEntity createEmployee(@RequestBody Employee employee) throws URISyntaxException { + log.debug("REST request to save Employee : {}", employee); + if (employee.getId() != null) { + throw new BadRequestAlertException("A new employee cannot already have an ID", ENTITY_NAME, "idexists"); + } + Employee result = employeeRepository.save(employee); + return ResponseEntity.created(new URI("/api/employees/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /employees : Updates an existing employee. + * + * @param employee the employee to update + * @return the ResponseEntity with status 200 (OK) and with body the updated employee, + * or with status 400 (Bad Request) if the employee is not valid, + * or with status 500 (Internal Server Error) if the employee couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/employees") + public ResponseEntity updateEmployee(@RequestBody Employee employee) throws URISyntaxException { + log.debug("REST request to update Employee : {}", employee); + if (employee.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Employee result = employeeRepository.save(employee); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, employee.getId().toString())) + .body(result); + } + + /** + * GET /employees : get all the employees. + * + * @param pageable the pagination information + * @return the ResponseEntity with status 200 (OK) and the list of employees in body + */ + @GetMapping("/employees") + public ResponseEntity> getAllEmployees(Pageable pageable) { + log.debug("REST request to get a page of Employees"); + Page page = employeeRepository.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/employees"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /employees/:id : get the "id" employee. + * + * @param id the id of the employee to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the employee, or with status 404 (Not Found) + */ + @GetMapping("/employees/{id}") + public ResponseEntity getEmployee(@PathVariable Long id) { + log.debug("REST request to get Employee : {}", id); + Optional employee = employeeRepository.findById(id); + return ResponseUtil.wrapOrNotFound(employee); + } + + /** + * DELETE /employees/:id : delete the "id" employee. + * + * @param id the id of the employee to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/employees/{id}") + public ResponseEntity deleteEmployee(@PathVariable Long id) { + log.debug("REST request to delete Employee : {}", id); + employeeRepository.deleteById(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResource.java new file mode 100644 index 0000000..c0a355d --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResource.java @@ -0,0 +1,119 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.JobHistory; +import com.cooperl.si.integration.ui.service.JobHistoryService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import com.cooperl.si.integration.ui.web.rest.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing JobHistory. + */ +@RestController +@RequestMapping("/api") +public class JobHistoryResource { + + private final Logger log = LoggerFactory.getLogger(JobHistoryResource.class); + + private static final String ENTITY_NAME = "jobHistory"; + + private final JobHistoryService jobHistoryService; + + public JobHistoryResource(JobHistoryService jobHistoryService) { + this.jobHistoryService = jobHistoryService; + } + + /** + * POST /job-histories : Create a new jobHistory. + * + * @param jobHistory the jobHistory to create + * @return the ResponseEntity with status 201 (Created) and with body the new jobHistory, or with status 400 (Bad Request) if the jobHistory has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/job-histories") + public ResponseEntity createJobHistory(@RequestBody JobHistory jobHistory) throws URISyntaxException { + log.debug("REST request to save JobHistory : {}", jobHistory); + if (jobHistory.getId() != null) { + throw new BadRequestAlertException("A new jobHistory cannot already have an ID", ENTITY_NAME, "idexists"); + } + JobHistory result = jobHistoryService.save(jobHistory); + return ResponseEntity.created(new URI("/api/job-histories/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /job-histories : Updates an existing jobHistory. + * + * @param jobHistory the jobHistory to update + * @return the ResponseEntity with status 200 (OK) and with body the updated jobHistory, + * or with status 400 (Bad Request) if the jobHistory is not valid, + * or with status 500 (Internal Server Error) if the jobHistory couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/job-histories") + public ResponseEntity updateJobHistory(@RequestBody JobHistory jobHistory) throws URISyntaxException { + log.debug("REST request to update JobHistory : {}", jobHistory); + if (jobHistory.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + JobHistory result = jobHistoryService.save(jobHistory); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, jobHistory.getId().toString())) + .body(result); + } + + /** + * GET /job-histories : get all the jobHistories. + * + * @param pageable the pagination information + * @return the ResponseEntity with status 200 (OK) and the list of jobHistories in body + */ + @GetMapping("/job-histories") + public ResponseEntity> getAllJobHistories(Pageable pageable) { + log.debug("REST request to get a page of JobHistories"); + Page page = jobHistoryService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/job-histories"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /job-histories/:id : get the "id" jobHistory. + * + * @param id the id of the jobHistory to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the jobHistory, or with status 404 (Not Found) + */ + @GetMapping("/job-histories/{id}") + public ResponseEntity getJobHistory(@PathVariable Long id) { + log.debug("REST request to get JobHistory : {}", id); + Optional jobHistory = jobHistoryService.findOne(id); + return ResponseUtil.wrapOrNotFound(jobHistory); + } + + /** + * DELETE /job-histories/:id : delete the "id" jobHistory. + * + * @param id the id of the jobHistory to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/job-histories/{id}") + public ResponseEntity deleteJobHistory(@PathVariable Long id) { + log.debug("REST request to delete JobHistory : {}", id); + jobHistoryService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/JobResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/JobResource.java new file mode 100644 index 0000000..345fd6e --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/JobResource.java @@ -0,0 +1,125 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Job; +import com.cooperl.si.integration.ui.repository.JobRepository; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import com.cooperl.si.integration.ui.web.rest.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Job. + */ +@RestController +@RequestMapping("/api") +public class JobResource { + + private final Logger log = LoggerFactory.getLogger(JobResource.class); + + private static final String ENTITY_NAME = "job"; + + private final JobRepository jobRepository; + + public JobResource(JobRepository jobRepository) { + this.jobRepository = jobRepository; + } + + /** + * POST /jobs : Create a new job. + * + * @param job the job to create + * @return the ResponseEntity with status 201 (Created) and with body the new job, or with status 400 (Bad Request) if the job has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/jobs") + public ResponseEntity createJob(@RequestBody Job job) throws URISyntaxException { + log.debug("REST request to save Job : {}", job); + if (job.getId() != null) { + throw new BadRequestAlertException("A new job cannot already have an ID", ENTITY_NAME, "idexists"); + } + Job result = jobRepository.save(job); + return ResponseEntity.created(new URI("/api/jobs/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /jobs : Updates an existing job. + * + * @param job the job to update + * @return the ResponseEntity with status 200 (OK) and with body the updated job, + * or with status 400 (Bad Request) if the job is not valid, + * or with status 500 (Internal Server Error) if the job couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/jobs") + public ResponseEntity updateJob(@RequestBody Job job) throws URISyntaxException { + log.debug("REST request to update Job : {}", job); + if (job.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Job result = jobRepository.save(job); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, job.getId().toString())) + .body(result); + } + + /** + * GET /jobs : get all the jobs. + * + * @param pageable the pagination information + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many) + * @return the ResponseEntity with status 200 (OK) and the list of jobs in body + */ + @GetMapping("/jobs") + public ResponseEntity> getAllJobs(Pageable pageable, @RequestParam(required = false, defaultValue = "false") boolean eagerload) { + log.debug("REST request to get a page of Jobs"); + Page page; + if (eagerload) { + page = jobRepository.findAllWithEagerRelationships(pageable); + } else { + page = jobRepository.findAll(pageable); + } + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, String.format("/api/jobs?eagerload=%b", eagerload)); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /jobs/:id : get the "id" job. + * + * @param id the id of the job to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the job, or with status 404 (Not Found) + */ + @GetMapping("/jobs/{id}") + public ResponseEntity getJob(@PathVariable Long id) { + log.debug("REST request to get Job : {}", id); + Optional job = jobRepository.findOneWithEagerRelationships(id); + return ResponseUtil.wrapOrNotFound(job); + } + + /** + * DELETE /jobs/:id : delete the "id" job. + * + * @param id the id of the job to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/jobs/{id}") + public ResponseEntity deleteJob(@PathVariable Long id) { + log.debug("REST request to delete Job : {}", id); + jobRepository.deleteById(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/LocationResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/LocationResource.java new file mode 100644 index 0000000..2b71c93 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/LocationResource.java @@ -0,0 +1,111 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Location; +import com.cooperl.si.integration.ui.service.LocationService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Location. + */ +@RestController +@RequestMapping("/api") +public class LocationResource { + + private final Logger log = LoggerFactory.getLogger(LocationResource.class); + + private static final String ENTITY_NAME = "location"; + + private final LocationService locationService; + + public LocationResource(LocationService locationService) { + this.locationService = locationService; + } + + /** + * POST /locations : Create a new location. + * + * @param location the location to create + * @return the ResponseEntity with status 201 (Created) and with body the new location, or with status 400 (Bad Request) if the location has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/locations") + public ResponseEntity createLocation(@RequestBody Location location) throws URISyntaxException { + log.debug("REST request to save Location : {}", location); + if (location.getId() != null) { + throw new BadRequestAlertException("A new location cannot already have an ID", ENTITY_NAME, "idexists"); + } + Location result = locationService.save(location); + return ResponseEntity.created(new URI("/api/locations/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /locations : Updates an existing location. + * + * @param location the location to update + * @return the ResponseEntity with status 200 (OK) and with body the updated location, + * or with status 400 (Bad Request) if the location is not valid, + * or with status 500 (Internal Server Error) if the location couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/locations") + public ResponseEntity updateLocation(@RequestBody Location location) throws URISyntaxException { + log.debug("REST request to update Location : {}", location); + if (location.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Location result = locationService.save(location); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, location.getId().toString())) + .body(result); + } + + /** + * GET /locations : get all the locations. + * + * @return the ResponseEntity with status 200 (OK) and the list of locations in body + */ + @GetMapping("/locations") + public List getAllLocations() { + log.debug("REST request to get all Locations"); + return locationService.findAll(); + } + + /** + * GET /locations/:id : get the "id" location. + * + * @param id the id of the location to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the location, or with status 404 (Not Found) + */ + @GetMapping("/locations/{id}") + public ResponseEntity getLocation(@PathVariable Long id) { + log.debug("REST request to get Location : {}", id); + Optional location = locationService.findOne(id); + return ResponseUtil.wrapOrNotFound(location); + } + + /** + * DELETE /locations/:id : delete the "id" location. + * + * @param id the id of the location to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/locations/{id}") + public ResponseEntity deleteLocation(@PathVariable Long id) { + log.debug("REST request to delete Location : {}", id); + locationService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/RegionResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/RegionResource.java new file mode 100644 index 0000000..e330cd6 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/RegionResource.java @@ -0,0 +1,111 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Region; +import com.cooperl.si.integration.ui.service.RegionService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Region. + */ +@RestController +@RequestMapping("/api") +public class RegionResource { + + private final Logger log = LoggerFactory.getLogger(RegionResource.class); + + private static final String ENTITY_NAME = "region"; + + private final RegionService regionService; + + public RegionResource(RegionService regionService) { + this.regionService = regionService; + } + + /** + * POST /regions : Create a new region. + * + * @param region the region to create + * @return the ResponseEntity with status 201 (Created) and with body the new region, or with status 400 (Bad Request) if the region has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/regions") + public ResponseEntity createRegion(@RequestBody Region region) throws URISyntaxException { + log.debug("REST request to save Region : {}", region); + if (region.getId() != null) { + throw new BadRequestAlertException("A new region cannot already have an ID", ENTITY_NAME, "idexists"); + } + Region result = regionService.save(region); + return ResponseEntity.created(new URI("/api/regions/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /regions : Updates an existing region. + * + * @param region the region to update + * @return the ResponseEntity with status 200 (OK) and with body the updated region, + * or with status 400 (Bad Request) if the region is not valid, + * or with status 500 (Internal Server Error) if the region couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/regions") + public ResponseEntity updateRegion(@RequestBody Region region) throws URISyntaxException { + log.debug("REST request to update Region : {}", region); + if (region.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Region result = regionService.save(region); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, region.getId().toString())) + .body(result); + } + + /** + * GET /regions : get all the regions. + * + * @return the ResponseEntity with status 200 (OK) and the list of regions in body + */ + @GetMapping("/regions") + public List getAllRegions() { + log.debug("REST request to get all Regions"); + return regionService.findAll(); + } + + /** + * GET /regions/:id : get the "id" region. + * + * @param id the id of the region to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the region, or with status 404 (Not Found) + */ + @GetMapping("/regions/{id}") + public ResponseEntity getRegion(@PathVariable Long id) { + log.debug("REST request to get Region : {}", id); + Optional region = regionService.findOne(id); + return ResponseUtil.wrapOrNotFound(region); + } + + /** + * DELETE /regions/:id : delete the "id" region. + * + * @param id the id of the region to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/regions/{id}") + public ResponseEntity deleteRegion(@PathVariable Long id) { + log.debug("REST request to delete Region : {}", id); + regionService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/cooperl/si/integration/ui/web/rest/TaskResource.java b/src/main/java/com/cooperl/si/integration/ui/web/rest/TaskResource.java new file mode 100644 index 0000000..6108988 --- /dev/null +++ b/src/main/java/com/cooperl/si/integration/ui/web/rest/TaskResource.java @@ -0,0 +1,111 @@ +package com.cooperl.si.integration.ui.web.rest; +import com.cooperl.si.integration.ui.domain.Task; +import com.cooperl.si.integration.ui.service.TaskService; +import com.cooperl.si.integration.ui.web.rest.errors.BadRequestAlertException; +import com.cooperl.si.integration.ui.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing Task. + */ +@RestController +@RequestMapping("/api") +public class TaskResource { + + private final Logger log = LoggerFactory.getLogger(TaskResource.class); + + private static final String ENTITY_NAME = "task"; + + private final TaskService taskService; + + public TaskResource(TaskService taskService) { + this.taskService = taskService; + } + + /** + * POST /tasks : Create a new task. + * + * @param task the task to create + * @return the ResponseEntity with status 201 (Created) and with body the new task, or with status 400 (Bad Request) if the task has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/tasks") + public ResponseEntity createTask(@RequestBody Task task) throws URISyntaxException { + log.debug("REST request to save Task : {}", task); + if (task.getId() != null) { + throw new BadRequestAlertException("A new task cannot already have an ID", ENTITY_NAME, "idexists"); + } + Task result = taskService.save(task); + return ResponseEntity.created(new URI("/api/tasks/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /tasks : Updates an existing task. + * + * @param task the task to update + * @return the ResponseEntity with status 200 (OK) and with body the updated task, + * or with status 400 (Bad Request) if the task is not valid, + * or with status 500 (Internal Server Error) if the task couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/tasks") + public ResponseEntity updateTask(@RequestBody Task task) throws URISyntaxException { + log.debug("REST request to update Task : {}", task); + if (task.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Task result = taskService.save(task); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, task.getId().toString())) + .body(result); + } + + /** + * GET /tasks : get all the tasks. + * + * @return the ResponseEntity with status 200 (OK) and the list of tasks in body + */ + @GetMapping("/tasks") + public List getAllTasks() { + log.debug("REST request to get all Tasks"); + return taskService.findAll(); + } + + /** + * GET /tasks/:id : get the "id" task. + * + * @param id the id of the task to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the task, or with status 404 (Not Found) + */ + @GetMapping("/tasks/{id}") + public ResponseEntity getTask(@PathVariable Long id) { + log.debug("REST request to get Task : {}", id); + Optional task = taskService.findOne(id); + return ResponseUtil.wrapOrNotFound(task); + } + + /** + * DELETE /tasks/:id : delete the "id" task. + * + * @param id the id of the task to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/tasks/{id}") + public ResponseEntity deleteTask(@PathVariable Long id) { + log.debug("REST request to delete Task : {}", id); + taskService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/resources/config/liquibase/changelog/20190424132217_added_entity_Region.xml b/src/main/resources/config/liquibase/changelog/20190424132217_added_entity_Region.xml new file mode 100644 index 0000000..839b2ed --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132217_added_entity_Region.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_Country.xml b/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_Country.xml new file mode 100644 index 0000000..4b44e06 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_Country.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_constraints_Country.xml b/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_constraints_Country.xml new file mode 100644 index 0000000..c06840b --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132218_added_entity_constraints_Country.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_Location.xml b/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_Location.xml new file mode 100644 index 0000000..a77a1d7 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_Location.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_constraints_Location.xml b/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_constraints_Location.xml new file mode 100644 index 0000000..5dbce5c --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132219_added_entity_constraints_Location.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_Department.xml b/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_Department.xml new file mode 100644 index 0000000..a1f9608 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_Department.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_constraints_Department.xml b/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_constraints_Department.xml new file mode 100644 index 0000000..77a182b --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132220_added_entity_constraints_Department.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132221_added_entity_Task.xml b/src/main/resources/config/liquibase/changelog/20190424132221_added_entity_Task.xml new file mode 100644 index 0000000..2051b32 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132221_added_entity_Task.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_Employee.xml b/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_Employee.xml new file mode 100644 index 0000000..ec14633 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_Employee.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_constraints_Employee.xml b/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_constraints_Employee.xml new file mode 100644 index 0000000..a9bf86f --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132222_added_entity_constraints_Employee.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_Job.xml b/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_Job.xml new file mode 100644 index 0000000..e70f67c --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_Job.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_constraints_Job.xml b/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_constraints_Job.xml new file mode 100644 index 0000000..bfdd524 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132223_added_entity_constraints_Job.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_JobHistory.xml b/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_JobHistory.xml new file mode 100644 index 0000000..c34c1b7 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_JobHistory.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_constraints_JobHistory.xml b/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_constraints_JobHistory.xml new file mode 100644 index 0000000..1f8f48c --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424132224_added_entity_constraints_JobHistory.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index f2b0b1f..8e560fb 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -5,6 +5,20 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> + + + + + + + + + + + + + + diff --git a/src/main/webapp/app/entities/country/country-delete-dialog.component.html b/src/main/webapp/app/entities/country/country-delete-dialog.component.html new file mode 100644 index 0000000..fe30d4a --- /dev/null +++ b/src/main/webapp/app/entities/country/country-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/country/country-delete-dialog.component.ts b/src/main/webapp/app/entities/country/country-delete-dialog.component.ts new file mode 100644 index 0000000..6cc4c7a --- /dev/null +++ b/src/main/webapp/app/entities/country/country-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ICountry } from 'app/shared/model/country.model'; +import { CountryService } from './country.service'; + +@Component({ + selector: 'jhi-country-delete-dialog', + templateUrl: './country-delete-dialog.component.html' +}) +export class CountryDeleteDialogComponent { + country: ICountry; + + constructor(protected countryService: CountryService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.countryService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'countryListModification', + content: 'Deleted an country' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-country-delete-popup', + template: '' +}) +export class CountryDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ country }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(CountryDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.country = country; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/country', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/country', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/country/country-detail.component.html b/src/main/webapp/app/entities/country/country-detail.component.html new file mode 100644 index 0000000..12ebc75 --- /dev/null +++ b/src/main/webapp/app/entities/country/country-detail.component.html @@ -0,0 +1,33 @@ +
+
+
+

Country {{country.id}}

+
+ +
+
Country Name
+
+ {{country.countryName}} +
+
Region
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/country/country-detail.component.ts b/src/main/webapp/app/entities/country/country-detail.component.ts new file mode 100644 index 0000000..a950752 --- /dev/null +++ b/src/main/webapp/app/entities/country/country-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ICountry } from 'app/shared/model/country.model'; + +@Component({ + selector: 'jhi-country-detail', + templateUrl: './country-detail.component.html' +}) +export class CountryDetailComponent implements OnInit { + country: ICountry; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ country }) => { + this.country = country; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/country/country-update.component.html b/src/main/webapp/app/entities/country/country-update.component.html new file mode 100644 index 0000000..c806d8b --- /dev/null +++ b/src/main/webapp/app/entities/country/country-update.component.html @@ -0,0 +1,36 @@ +
+
+
+

Create or edit a Country

+
+ +
+ + +
+
+ + +
+ +
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/country/country-update.component.ts b/src/main/webapp/app/entities/country/country-update.component.ts new file mode 100644 index 0000000..12228c7 --- /dev/null +++ b/src/main/webapp/app/entities/country/country-update.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiAlertService } from 'ng-jhipster'; +import { ICountry } from 'app/shared/model/country.model'; +import { CountryService } from './country.service'; +import { IRegion } from 'app/shared/model/region.model'; +import { RegionService } from 'app/entities/region'; + +@Component({ + selector: 'jhi-country-update', + templateUrl: './country-update.component.html' +}) +export class CountryUpdateComponent implements OnInit { + country: ICountry; + isSaving: boolean; + + regions: IRegion[]; + + constructor( + protected jhiAlertService: JhiAlertService, + protected countryService: CountryService, + protected regionService: RegionService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ country }) => { + this.country = country; + }); + this.regionService + .query({ filter: 'country-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: IRegion[]) => { + if (!this.country.region || !this.country.region.id) { + this.regions = res; + } else { + this.regionService + .find(this.country.region.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: IRegion) => (this.regions = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.country.id !== undefined) { + this.subscribeToSaveResponse(this.countryService.update(this.country)); + } else { + this.subscribeToSaveResponse(this.countryService.create(this.country)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackRegionById(index: number, item: IRegion) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/country/country.component.html b/src/main/webapp/app/entities/country/country.component.html new file mode 100644 index 0000000..f9ab3e8 --- /dev/null +++ b/src/main/webapp/app/entities/country/country.component.html @@ -0,0 +1,60 @@ +
+

+ Countries + +

+ +
+
+ + + + + + + + + + + + + + + + + +
IDCountry NameRegion
{{country.id}}{{country.countryName}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/country/country.component.ts b/src/main/webapp/app/entities/country/country.component.ts new file mode 100644 index 0000000..9fe88e4 --- /dev/null +++ b/src/main/webapp/app/entities/country/country.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; + +import { ICountry } from 'app/shared/model/country.model'; +import { AccountService } from 'app/core'; +import { CountryService } from './country.service'; + +@Component({ + selector: 'jhi-country', + templateUrl: './country.component.html' +}) +export class CountryComponent implements OnInit, OnDestroy { + countries: ICountry[]; + currentAccount: any; + eventSubscriber: Subscription; + + constructor( + protected countryService: CountryService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected accountService: AccountService + ) {} + + loadAll() { + this.countryService + .query() + .pipe( + filter((res: HttpResponse) => res.ok), + map((res: HttpResponse) => res.body) + ) + .subscribe( + (res: ICountry[]) => { + this.countries = res; + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInCountries(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: ICountry) { + return item.id; + } + + registerChangeInCountries() { + this.eventSubscriber = this.eventManager.subscribe('countryListModification', response => this.loadAll()); + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/country/country.module.ts b/src/main/webapp/app/entities/country/country.module.ts new file mode 100644 index 0000000..37e7a59 --- /dev/null +++ b/src/main/webapp/app/entities/country/country.module.ts @@ -0,0 +1,29 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + CountryComponent, + CountryDetailComponent, + CountryUpdateComponent, + CountryDeletePopupComponent, + CountryDeleteDialogComponent, + countryRoute, + countryPopupRoute +} from './'; + +const ENTITY_STATES = [...countryRoute, ...countryPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + CountryComponent, + CountryDetailComponent, + CountryUpdateComponent, + CountryDeleteDialogComponent, + CountryDeletePopupComponent + ], + entryComponents: [CountryComponent, CountryUpdateComponent, CountryDeleteDialogComponent, CountryDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiCountryModule {} diff --git a/src/main/webapp/app/entities/country/country.route.ts b/src/main/webapp/app/entities/country/country.route.ts new file mode 100644 index 0000000..3fcf897 --- /dev/null +++ b/src/main/webapp/app/entities/country/country.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Country } from 'app/shared/model/country.model'; +import { CountryService } from './country.service'; +import { CountryComponent } from './country.component'; +import { CountryDetailComponent } from './country-detail.component'; +import { CountryUpdateComponent } from './country-update.component'; +import { CountryDeletePopupComponent } from './country-delete-dialog.component'; +import { ICountry } from 'app/shared/model/country.model'; + +@Injectable({ providedIn: 'root' }) +export class CountryResolve implements Resolve { + constructor(private service: CountryService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((country: HttpResponse) => country.body) + ); + } + return of(new Country()); + } +} + +export const countryRoute: Routes = [ + { + path: '', + component: CountryComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Countries' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: CountryDetailComponent, + resolve: { + country: CountryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Countries' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: CountryUpdateComponent, + resolve: { + country: CountryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Countries' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: CountryUpdateComponent, + resolve: { + country: CountryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Countries' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const countryPopupRoute: Routes = [ + { + path: ':id/delete', + component: CountryDeletePopupComponent, + resolve: { + country: CountryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Countries' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/country/country.service.ts b/src/main/webapp/app/entities/country/country.service.ts new file mode 100644 index 0000000..9452fe7 --- /dev/null +++ b/src/main/webapp/app/entities/country/country.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { ICountry } from 'app/shared/model/country.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class CountryService { + public resourceUrl = SERVER_API_URL + 'api/countries'; + + constructor(protected http: HttpClient) {} + + create(country: ICountry): Observable { + return this.http.post(this.resourceUrl, country, { observe: 'response' }); + } + + update(country: ICountry): Observable { + return this.http.put(this.resourceUrl, country, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/country/index.ts b/src/main/webapp/app/entities/country/index.ts new file mode 100644 index 0000000..51d4824 --- /dev/null +++ b/src/main/webapp/app/entities/country/index.ts @@ -0,0 +1,6 @@ +export * from './country.service'; +export * from './country-update.component'; +export * from './country-delete-dialog.component'; +export * from './country-detail.component'; +export * from './country.component'; +export * from './country.route'; diff --git a/src/main/webapp/app/entities/department/department-delete-dialog.component.html b/src/main/webapp/app/entities/department/department-delete-dialog.component.html new file mode 100644 index 0000000..a282848 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/department/department-delete-dialog.component.ts b/src/main/webapp/app/entities/department/department-delete-dialog.component.ts new file mode 100644 index 0000000..5f44d68 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-delete-dialog.component.ts @@ -0,0 +1,69 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; + +@Component({ + selector: 'jhi-department-delete-dialog', + templateUrl: './department-delete-dialog.component.html' +}) +export class DepartmentDeleteDialogComponent { + department: IDepartment; + + constructor( + protected departmentService: DepartmentService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.departmentService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'departmentListModification', + content: 'Deleted an department' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-department-delete-popup', + template: '' +}) +export class DepartmentDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ department }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(DepartmentDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.department = department; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/department', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/department', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/department/department-detail.component.html b/src/main/webapp/app/entities/department/department-detail.component.html new file mode 100644 index 0000000..785ed4f --- /dev/null +++ b/src/main/webapp/app/entities/department/department-detail.component.html @@ -0,0 +1,33 @@ +
+
+
+

Department {{department.id}}

+
+ +
+
Department Name
+
+ {{department.departmentName}} +
+
Location
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/department/department-detail.component.ts b/src/main/webapp/app/entities/department/department-detail.component.ts new file mode 100644 index 0000000..903d18d --- /dev/null +++ b/src/main/webapp/app/entities/department/department-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IDepartment } from 'app/shared/model/department.model'; + +@Component({ + selector: 'jhi-department-detail', + templateUrl: './department-detail.component.html' +}) +export class DepartmentDetailComponent implements OnInit { + department: IDepartment; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ department }) => { + this.department = department; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/department/department-update.component.html b/src/main/webapp/app/entities/department/department-update.component.html new file mode 100644 index 0000000..0a2a2dc --- /dev/null +++ b/src/main/webapp/app/entities/department/department-update.component.html @@ -0,0 +1,42 @@ +
+
+
+

Create or edit a Department

+
+ +
+ + +
+
+ + +
+ + This field is required. + +
+
+ +
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/department/department-update.component.ts b/src/main/webapp/app/entities/department/department-update.component.ts new file mode 100644 index 0000000..636fefb --- /dev/null +++ b/src/main/webapp/app/entities/department/department-update.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiAlertService } from 'ng-jhipster'; +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; +import { ILocation } from 'app/shared/model/location.model'; +import { LocationService } from 'app/entities/location'; + +@Component({ + selector: 'jhi-department-update', + templateUrl: './department-update.component.html' +}) +export class DepartmentUpdateComponent implements OnInit { + department: IDepartment; + isSaving: boolean; + + locations: ILocation[]; + + constructor( + protected jhiAlertService: JhiAlertService, + protected departmentService: DepartmentService, + protected locationService: LocationService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ department }) => { + this.department = department; + }); + this.locationService + .query({ filter: 'department-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: ILocation[]) => { + if (!this.department.location || !this.department.location.id) { + this.locations = res; + } else { + this.locationService + .find(this.department.location.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: ILocation) => (this.locations = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.department.id !== undefined) { + this.subscribeToSaveResponse(this.departmentService.update(this.department)); + } else { + this.subscribeToSaveResponse(this.departmentService.create(this.department)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackLocationById(index: number, item: ILocation) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/department/department.component.html b/src/main/webapp/app/entities/department/department.component.html new file mode 100644 index 0000000..0cf6065 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.component.html @@ -0,0 +1,60 @@ +
+

+ Departments + +

+ +
+
+ + + + + + + + + + + + + + + + + +
IDDepartment NameLocation
{{department.id}}{{department.departmentName}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/department/department.component.ts b/src/main/webapp/app/entities/department/department.component.ts new file mode 100644 index 0000000..6870e13 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; + +import { IDepartment } from 'app/shared/model/department.model'; +import { AccountService } from 'app/core'; +import { DepartmentService } from './department.service'; + +@Component({ + selector: 'jhi-department', + templateUrl: './department.component.html' +}) +export class DepartmentComponent implements OnInit, OnDestroy { + departments: IDepartment[]; + currentAccount: any; + eventSubscriber: Subscription; + + constructor( + protected departmentService: DepartmentService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected accountService: AccountService + ) {} + + loadAll() { + this.departmentService + .query() + .pipe( + filter((res: HttpResponse) => res.ok), + map((res: HttpResponse) => res.body) + ) + .subscribe( + (res: IDepartment[]) => { + this.departments = res; + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInDepartments(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IDepartment) { + return item.id; + } + + registerChangeInDepartments() { + this.eventSubscriber = this.eventManager.subscribe('departmentListModification', response => this.loadAll()); + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/department/department.module.ts b/src/main/webapp/app/entities/department/department.module.ts new file mode 100644 index 0000000..5271ff7 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.module.ts @@ -0,0 +1,29 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + DepartmentComponent, + DepartmentDetailComponent, + DepartmentUpdateComponent, + DepartmentDeletePopupComponent, + DepartmentDeleteDialogComponent, + departmentRoute, + departmentPopupRoute +} from './'; + +const ENTITY_STATES = [...departmentRoute, ...departmentPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + DepartmentComponent, + DepartmentDetailComponent, + DepartmentUpdateComponent, + DepartmentDeleteDialogComponent, + DepartmentDeletePopupComponent + ], + entryComponents: [DepartmentComponent, DepartmentUpdateComponent, DepartmentDeleteDialogComponent, DepartmentDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiDepartmentModule {} diff --git a/src/main/webapp/app/entities/department/department.route.ts b/src/main/webapp/app/entities/department/department.route.ts new file mode 100644 index 0000000..bc262a3 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Department } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; +import { DepartmentComponent } from './department.component'; +import { DepartmentDetailComponent } from './department-detail.component'; +import { DepartmentUpdateComponent } from './department-update.component'; +import { DepartmentDeletePopupComponent } from './department-delete-dialog.component'; +import { IDepartment } from 'app/shared/model/department.model'; + +@Injectable({ providedIn: 'root' }) +export class DepartmentResolve implements Resolve { + constructor(private service: DepartmentService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((department: HttpResponse) => department.body) + ); + } + return of(new Department()); + } +} + +export const departmentRoute: Routes = [ + { + path: '', + component: DepartmentComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Departments' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: DepartmentDetailComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Departments' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: DepartmentUpdateComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Departments' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: DepartmentUpdateComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Departments' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const departmentPopupRoute: Routes = [ + { + path: ':id/delete', + component: DepartmentDeletePopupComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Departments' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/department/department.service.ts b/src/main/webapp/app/entities/department/department.service.ts new file mode 100644 index 0000000..4b4cda9 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { IDepartment } from 'app/shared/model/department.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class DepartmentService { + public resourceUrl = SERVER_API_URL + 'api/departments'; + + constructor(protected http: HttpClient) {} + + create(department: IDepartment): Observable { + return this.http.post(this.resourceUrl, department, { observe: 'response' }); + } + + update(department: IDepartment): Observable { + return this.http.put(this.resourceUrl, department, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/department/index.ts b/src/main/webapp/app/entities/department/index.ts new file mode 100644 index 0000000..709526d --- /dev/null +++ b/src/main/webapp/app/entities/department/index.ts @@ -0,0 +1,6 @@ +export * from './department.service'; +export * from './department-update.component'; +export * from './department-delete-dialog.component'; +export * from './department-detail.component'; +export * from './department.component'; +export * from './department.route'; diff --git a/src/main/webapp/app/entities/employee/employee-delete-dialog.component.html b/src/main/webapp/app/entities/employee/employee-delete-dialog.component.html new file mode 100644 index 0000000..d3c59a1 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/employee/employee-delete-dialog.component.ts b/src/main/webapp/app/entities/employee/employee-delete-dialog.component.ts new file mode 100644 index 0000000..07eb246 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IEmployee } from 'app/shared/model/employee.model'; +import { EmployeeService } from './employee.service'; + +@Component({ + selector: 'jhi-employee-delete-dialog', + templateUrl: './employee-delete-dialog.component.html' +}) +export class EmployeeDeleteDialogComponent { + employee: IEmployee; + + constructor(protected employeeService: EmployeeService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.employeeService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'employeeListModification', + content: 'Deleted an employee' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-employee-delete-popup', + template: '' +}) +export class EmployeeDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ employee }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(EmployeeDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.employee = employee; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/employee', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/employee', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/employee/employee-detail.component.html b/src/main/webapp/app/entities/employee/employee-detail.component.html new file mode 100644 index 0000000..3d3bf2a --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-detail.component.html @@ -0,0 +1,63 @@ +
+
+
+

Employee {{employee.id}}

+
+ +
+
First Name
+
+ {{employee.firstName}} +
+
Last Name
+
+ {{employee.lastName}} +
+
Email
+
+ {{employee.email}} +
+
Phone Number
+
+ {{employee.phoneNumber}} +
+
Hire Date
+
+ {{employee.hireDate}} +
+
Salary
+
+ {{employee.salary}} +
+
Commission Pct
+
+ {{employee.commissionPct}} +
+
Department
+
+ +
+
Manager
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/employee/employee-detail.component.ts b/src/main/webapp/app/entities/employee/employee-detail.component.ts new file mode 100644 index 0000000..a4d0364 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IEmployee } from 'app/shared/model/employee.model'; + +@Component({ + selector: 'jhi-employee-detail', + templateUrl: './employee-detail.component.html' +}) +export class EmployeeDetailComponent implements OnInit { + employee: IEmployee; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ employee }) => { + this.employee = employee; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/employee/employee-update.component.html b/src/main/webapp/app/entities/employee/employee-update.component.html new file mode 100644 index 0000000..5554aa7 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-update.component.html @@ -0,0 +1,75 @@ +
+
+
+

Create or edit a Employee

+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/employee/employee-update.component.ts b/src/main/webapp/app/entities/employee/employee-update.component.ts new file mode 100644 index 0000000..d273d8f --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee-update.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; +import { JhiAlertService } from 'ng-jhipster'; +import { IEmployee } from 'app/shared/model/employee.model'; +import { EmployeeService } from './employee.service'; +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from 'app/entities/department'; + +@Component({ + selector: 'jhi-employee-update', + templateUrl: './employee-update.component.html' +}) +export class EmployeeUpdateComponent implements OnInit { + employee: IEmployee; + isSaving: boolean; + + departments: IDepartment[]; + + employees: IEmployee[]; + hireDate: string; + + constructor( + protected jhiAlertService: JhiAlertService, + protected employeeService: EmployeeService, + protected departmentService: DepartmentService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ employee }) => { + this.employee = employee; + this.hireDate = this.employee.hireDate != null ? this.employee.hireDate.format(DATE_TIME_FORMAT) : null; + }); + this.departmentService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IDepartment[]) => (this.departments = res), (res: HttpErrorResponse) => this.onError(res.message)); + this.employeeService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IEmployee[]) => (this.employees = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + this.employee.hireDate = this.hireDate != null ? moment(this.hireDate, DATE_TIME_FORMAT) : null; + if (this.employee.id !== undefined) { + this.subscribeToSaveResponse(this.employeeService.update(this.employee)); + } else { + this.subscribeToSaveResponse(this.employeeService.create(this.employee)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackDepartmentById(index: number, item: IDepartment) { + return item.id; + } + + trackEmployeeById(index: number, item: IEmployee) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/employee/employee.component.html b/src/main/webapp/app/entities/employee/employee.component.html new file mode 100644 index 0000000..f6efc7f --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee.component.html @@ -0,0 +1,78 @@ +
+

+ Employees + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID First Name Last Name Email Phone Number Hire Date Salary Commission Pct Department Manager
{{employee.id}}{{employee.firstName}}{{employee.lastName}}{{employee.email}}{{employee.phoneNumber}}{{employee.hireDate | date:'medium'}}{{employee.salary}}{{employee.commissionPct}} + + + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/employee/employee.component.ts b/src/main/webapp/app/entities/employee/employee.component.ts new file mode 100644 index 0000000..2524088 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IEmployee } from 'app/shared/model/employee.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { EmployeeService } from './employee.service'; + +@Component({ + selector: 'jhi-employee', + templateUrl: './employee.component.html' +}) +export class EmployeeComponent implements OnInit, OnDestroy { + employees: IEmployee[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected employeeService: EmployeeService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.employees = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.employeeService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateEmployees(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.employees = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInEmployees(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IEmployee) { + return item.id; + } + + registerChangeInEmployees() { + this.eventSubscriber = this.eventManager.subscribe('employeeListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateEmployees(data: IEmployee[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.employees.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/employee/employee.module.ts b/src/main/webapp/app/entities/employee/employee.module.ts new file mode 100644 index 0000000..b565c85 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee.module.ts @@ -0,0 +1,29 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + EmployeeComponent, + EmployeeDetailComponent, + EmployeeUpdateComponent, + EmployeeDeletePopupComponent, + EmployeeDeleteDialogComponent, + employeeRoute, + employeePopupRoute +} from './'; + +const ENTITY_STATES = [...employeeRoute, ...employeePopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + EmployeeComponent, + EmployeeDetailComponent, + EmployeeUpdateComponent, + EmployeeDeleteDialogComponent, + EmployeeDeletePopupComponent + ], + entryComponents: [EmployeeComponent, EmployeeUpdateComponent, EmployeeDeleteDialogComponent, EmployeeDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiEmployeeModule {} diff --git a/src/main/webapp/app/entities/employee/employee.route.ts b/src/main/webapp/app/entities/employee/employee.route.ts new file mode 100644 index 0000000..ea1a84f --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Employee } from 'app/shared/model/employee.model'; +import { EmployeeService } from './employee.service'; +import { EmployeeComponent } from './employee.component'; +import { EmployeeDetailComponent } from './employee-detail.component'; +import { EmployeeUpdateComponent } from './employee-update.component'; +import { EmployeeDeletePopupComponent } from './employee-delete-dialog.component'; +import { IEmployee } from 'app/shared/model/employee.model'; + +@Injectable({ providedIn: 'root' }) +export class EmployeeResolve implements Resolve { + constructor(private service: EmployeeService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((employee: HttpResponse) => employee.body) + ); + } + return of(new Employee()); + } +} + +export const employeeRoute: Routes = [ + { + path: '', + component: EmployeeComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Employees' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: EmployeeDetailComponent, + resolve: { + employee: EmployeeResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Employees' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: EmployeeUpdateComponent, + resolve: { + employee: EmployeeResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Employees' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: EmployeeUpdateComponent, + resolve: { + employee: EmployeeResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Employees' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const employeePopupRoute: Routes = [ + { + path: ':id/delete', + component: EmployeeDeletePopupComponent, + resolve: { + employee: EmployeeResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Employees' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/employee/employee.service.ts b/src/main/webapp/app/entities/employee/employee.service.ts new file mode 100644 index 0000000..a1176b9 --- /dev/null +++ b/src/main/webapp/app/entities/employee/employee.service.ts @@ -0,0 +1,74 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { map } from 'rxjs/operators'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { IEmployee } from 'app/shared/model/employee.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class EmployeeService { + public resourceUrl = SERVER_API_URL + 'api/employees'; + + constructor(protected http: HttpClient) {} + + create(employee: IEmployee): Observable { + const copy = this.convertDateFromClient(employee); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(employee: IEmployee): Observable { + const copy = this.convertDateFromClient(employee); + return this.http + .put(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + find(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http + .get(this.resourceUrl, { params: options, observe: 'response' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(employee: IEmployee): IEmployee { + const copy: IEmployee = Object.assign({}, employee, { + hireDate: employee.hireDate != null && employee.hireDate.isValid() ? employee.hireDate.toJSON() : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.hireDate = res.body.hireDate != null ? moment(res.body.hireDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((employee: IEmployee) => { + employee.hireDate = employee.hireDate != null ? moment(employee.hireDate) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/employee/index.ts b/src/main/webapp/app/entities/employee/index.ts new file mode 100644 index 0000000..3599b59 --- /dev/null +++ b/src/main/webapp/app/entities/employee/index.ts @@ -0,0 +1,6 @@ +export * from './employee.service'; +export * from './employee-update.component'; +export * from './employee-delete-dialog.component'; +export * from './employee-detail.component'; +export * from './employee.component'; +export * from './employee.route'; diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index 8af38f0..e9a1631 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -4,6 +4,38 @@ import { RouterModule } from '@angular/router'; @NgModule({ imports: [ RouterModule.forChild([ + { + path: 'region', + loadChildren: './region/region.module#IntegrationUiRegionModule' + }, + { + path: 'country', + loadChildren: './country/country.module#IntegrationUiCountryModule' + }, + { + path: 'location', + loadChildren: './location/location.module#IntegrationUiLocationModule' + }, + { + path: 'department', + loadChildren: './department/department.module#IntegrationUiDepartmentModule' + }, + { + path: 'task', + loadChildren: './task/task.module#IntegrationUiTaskModule' + }, + { + path: 'employee', + loadChildren: './employee/employee.module#IntegrationUiEmployeeModule' + }, + { + path: 'job', + loadChildren: './job/job.module#IntegrationUiJobModule' + }, + { + path: 'job-history', + loadChildren: './job-history/job-history.module#IntegrationUiJobHistoryModule' + } /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]) ], diff --git a/src/main/webapp/app/entities/job-history/index.ts b/src/main/webapp/app/entities/job-history/index.ts new file mode 100644 index 0000000..64c6986 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/index.ts @@ -0,0 +1,6 @@ +export * from './job-history.service'; +export * from './job-history-update.component'; +export * from './job-history-delete-dialog.component'; +export * from './job-history-detail.component'; +export * from './job-history.component'; +export * from './job-history.route'; diff --git a/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.html b/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.html new file mode 100644 index 0000000..97d9c4f --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.ts b/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.ts new file mode 100644 index 0000000..58800a8 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-delete-dialog.component.ts @@ -0,0 +1,69 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IJobHistory } from 'app/shared/model/job-history.model'; +import { JobHistoryService } from './job-history.service'; + +@Component({ + selector: 'jhi-job-history-delete-dialog', + templateUrl: './job-history-delete-dialog.component.html' +}) +export class JobHistoryDeleteDialogComponent { + jobHistory: IJobHistory; + + constructor( + protected jobHistoryService: JobHistoryService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.jobHistoryService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'jobHistoryListModification', + content: 'Deleted an jobHistory' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-job-history-delete-popup', + template: '' +}) +export class JobHistoryDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ jobHistory }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(JobHistoryDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.jobHistory = jobHistory; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/job-history', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/job-history', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/job-history/job-history-detail.component.html b/src/main/webapp/app/entities/job-history/job-history-detail.component.html new file mode 100644 index 0000000..a17c717 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-detail.component.html @@ -0,0 +1,53 @@ +
+
+
+

Job History {{jobHistory.id}}

+
+ +
+
Start Date
+
+ {{jobHistory.startDate}} +
+
End Date
+
+ {{jobHistory.endDate}} +
+
Language
+
+ {{jobHistory.language}} +
+
Job
+
+ +
+
Department
+
+ +
+
Employee
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/job-history/job-history-detail.component.ts b/src/main/webapp/app/entities/job-history/job-history-detail.component.ts new file mode 100644 index 0000000..6929c69 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IJobHistory } from 'app/shared/model/job-history.model'; + +@Component({ + selector: 'jhi-job-history-detail', + templateUrl: './job-history-detail.component.html' +}) +export class JobHistoryDetailComponent implements OnInit { + jobHistory: IJobHistory; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ jobHistory }) => { + this.jobHistory = jobHistory; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/job-history/job-history-update.component.html b/src/main/webapp/app/entities/job-history/job-history-update.component.html new file mode 100644 index 0000000..370299b --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-update.component.html @@ -0,0 +1,67 @@ +
+
+
+

Create or edit a Job History

+
+ +
+ + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/job-history/job-history-update.component.ts b/src/main/webapp/app/entities/job-history/job-history-update.component.ts new file mode 100644 index 0000000..0fa0e2b --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history-update.component.ts @@ -0,0 +1,170 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; +import { JhiAlertService } from 'ng-jhipster'; +import { IJobHistory } from 'app/shared/model/job-history.model'; +import { JobHistoryService } from './job-history.service'; +import { IJob } from 'app/shared/model/job.model'; +import { JobService } from 'app/entities/job'; +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from 'app/entities/department'; +import { IEmployee } from 'app/shared/model/employee.model'; +import { EmployeeService } from 'app/entities/employee'; + +@Component({ + selector: 'jhi-job-history-update', + templateUrl: './job-history-update.component.html' +}) +export class JobHistoryUpdateComponent implements OnInit { + jobHistory: IJobHistory; + isSaving: boolean; + + jobs: IJob[]; + + departments: IDepartment[]; + + employees: IEmployee[]; + startDate: string; + endDate: string; + + constructor( + protected jhiAlertService: JhiAlertService, + protected jobHistoryService: JobHistoryService, + protected jobService: JobService, + protected departmentService: DepartmentService, + protected employeeService: EmployeeService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ jobHistory }) => { + this.jobHistory = jobHistory; + this.startDate = this.jobHistory.startDate != null ? this.jobHistory.startDate.format(DATE_TIME_FORMAT) : null; + this.endDate = this.jobHistory.endDate != null ? this.jobHistory.endDate.format(DATE_TIME_FORMAT) : null; + }); + this.jobService + .query({ filter: 'jobhistory-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: IJob[]) => { + if (!this.jobHistory.job || !this.jobHistory.job.id) { + this.jobs = res; + } else { + this.jobService + .find(this.jobHistory.job.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: IJob) => (this.jobs = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + this.departmentService + .query({ filter: 'jobhistory-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: IDepartment[]) => { + if (!this.jobHistory.department || !this.jobHistory.department.id) { + this.departments = res; + } else { + this.departmentService + .find(this.jobHistory.department.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: IDepartment) => (this.departments = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + this.employeeService + .query({ filter: 'jobhistory-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: IEmployee[]) => { + if (!this.jobHistory.employee || !this.jobHistory.employee.id) { + this.employees = res; + } else { + this.employeeService + .find(this.jobHistory.employee.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: IEmployee) => (this.employees = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + this.jobHistory.startDate = this.startDate != null ? moment(this.startDate, DATE_TIME_FORMAT) : null; + this.jobHistory.endDate = this.endDate != null ? moment(this.endDate, DATE_TIME_FORMAT) : null; + if (this.jobHistory.id !== undefined) { + this.subscribeToSaveResponse(this.jobHistoryService.update(this.jobHistory)); + } else { + this.subscribeToSaveResponse(this.jobHistoryService.create(this.jobHistory)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackJobById(index: number, item: IJob) { + return item.id; + } + + trackDepartmentById(index: number, item: IDepartment) { + return item.id; + } + + trackEmployeeById(index: number, item: IEmployee) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/job-history/job-history.component.html b/src/main/webapp/app/entities/job-history/job-history.component.html new file mode 100644 index 0000000..eb9ffd1 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history.component.html @@ -0,0 +1,76 @@ +
+

+ Job Histories + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ID Start Date End Date Language Job Department Employee
{{jobHistory.id}}{{jobHistory.startDate | date:'medium'}}{{jobHistory.endDate | date:'medium'}}{{jobHistory.language}} + + + + + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/job-history/job-history.component.ts b/src/main/webapp/app/entities/job-history/job-history.component.ts new file mode 100644 index 0000000..58d8197 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IJobHistory } from 'app/shared/model/job-history.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { JobHistoryService } from './job-history.service'; + +@Component({ + selector: 'jhi-job-history', + templateUrl: './job-history.component.html' +}) +export class JobHistoryComponent implements OnInit, OnDestroy { + jobHistories: IJobHistory[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected jobHistoryService: JobHistoryService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.jobHistories = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.jobHistoryService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateJobHistories(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.jobHistories = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInJobHistories(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IJobHistory) { + return item.id; + } + + registerChangeInJobHistories() { + this.eventSubscriber = this.eventManager.subscribe('jobHistoryListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateJobHistories(data: IJobHistory[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.jobHistories.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/job-history/job-history.module.ts b/src/main/webapp/app/entities/job-history/job-history.module.ts new file mode 100644 index 0000000..bca086b --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history.module.ts @@ -0,0 +1,29 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + JobHistoryComponent, + JobHistoryDetailComponent, + JobHistoryUpdateComponent, + JobHistoryDeletePopupComponent, + JobHistoryDeleteDialogComponent, + jobHistoryRoute, + jobHistoryPopupRoute +} from './'; + +const ENTITY_STATES = [...jobHistoryRoute, ...jobHistoryPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + JobHistoryComponent, + JobHistoryDetailComponent, + JobHistoryUpdateComponent, + JobHistoryDeleteDialogComponent, + JobHistoryDeletePopupComponent + ], + entryComponents: [JobHistoryComponent, JobHistoryUpdateComponent, JobHistoryDeleteDialogComponent, JobHistoryDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiJobHistoryModule {} diff --git a/src/main/webapp/app/entities/job-history/job-history.route.ts b/src/main/webapp/app/entities/job-history/job-history.route.ts new file mode 100644 index 0000000..20d894a --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JobHistory } from 'app/shared/model/job-history.model'; +import { JobHistoryService } from './job-history.service'; +import { JobHistoryComponent } from './job-history.component'; +import { JobHistoryDetailComponent } from './job-history-detail.component'; +import { JobHistoryUpdateComponent } from './job-history-update.component'; +import { JobHistoryDeletePopupComponent } from './job-history-delete-dialog.component'; +import { IJobHistory } from 'app/shared/model/job-history.model'; + +@Injectable({ providedIn: 'root' }) +export class JobHistoryResolve implements Resolve { + constructor(private service: JobHistoryService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((jobHistory: HttpResponse) => jobHistory.body) + ); + } + return of(new JobHistory()); + } +} + +export const jobHistoryRoute: Routes = [ + { + path: '', + component: JobHistoryComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'JobHistories' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: JobHistoryDetailComponent, + resolve: { + jobHistory: JobHistoryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'JobHistories' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: JobHistoryUpdateComponent, + resolve: { + jobHistory: JobHistoryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'JobHistories' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: JobHistoryUpdateComponent, + resolve: { + jobHistory: JobHistoryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'JobHistories' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const jobHistoryPopupRoute: Routes = [ + { + path: ':id/delete', + component: JobHistoryDeletePopupComponent, + resolve: { + jobHistory: JobHistoryResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'JobHistories' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/job-history/job-history.service.ts b/src/main/webapp/app/entities/job-history/job-history.service.ts new file mode 100644 index 0000000..e4186c5 --- /dev/null +++ b/src/main/webapp/app/entities/job-history/job-history.service.ts @@ -0,0 +1,77 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { map } from 'rxjs/operators'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { IJobHistory } from 'app/shared/model/job-history.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class JobHistoryService { + public resourceUrl = SERVER_API_URL + 'api/job-histories'; + + constructor(protected http: HttpClient) {} + + create(jobHistory: IJobHistory): Observable { + const copy = this.convertDateFromClient(jobHistory); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(jobHistory: IJobHistory): Observable { + const copy = this.convertDateFromClient(jobHistory); + return this.http + .put(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + find(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http + .get(this.resourceUrl, { params: options, observe: 'response' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(jobHistory: IJobHistory): IJobHistory { + const copy: IJobHistory = Object.assign({}, jobHistory, { + startDate: jobHistory.startDate != null && jobHistory.startDate.isValid() ? jobHistory.startDate.toJSON() : null, + endDate: jobHistory.endDate != null && jobHistory.endDate.isValid() ? jobHistory.endDate.toJSON() : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.startDate = res.body.startDate != null ? moment(res.body.startDate) : null; + res.body.endDate = res.body.endDate != null ? moment(res.body.endDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((jobHistory: IJobHistory) => { + jobHistory.startDate = jobHistory.startDate != null ? moment(jobHistory.startDate) : null; + jobHistory.endDate = jobHistory.endDate != null ? moment(jobHistory.endDate) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/job/index.ts b/src/main/webapp/app/entities/job/index.ts new file mode 100644 index 0000000..6d95bd5 --- /dev/null +++ b/src/main/webapp/app/entities/job/index.ts @@ -0,0 +1,6 @@ +export * from './job.service'; +export * from './job-update.component'; +export * from './job-delete-dialog.component'; +export * from './job-detail.component'; +export * from './job.component'; +export * from './job.route'; diff --git a/src/main/webapp/app/entities/job/job-delete-dialog.component.html b/src/main/webapp/app/entities/job/job-delete-dialog.component.html new file mode 100644 index 0000000..886dbb2 --- /dev/null +++ b/src/main/webapp/app/entities/job/job-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/job/job-delete-dialog.component.ts b/src/main/webapp/app/entities/job/job-delete-dialog.component.ts new file mode 100644 index 0000000..ea37592 --- /dev/null +++ b/src/main/webapp/app/entities/job/job-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IJob } from 'app/shared/model/job.model'; +import { JobService } from './job.service'; + +@Component({ + selector: 'jhi-job-delete-dialog', + templateUrl: './job-delete-dialog.component.html' +}) +export class JobDeleteDialogComponent { + job: IJob; + + constructor(protected jobService: JobService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.jobService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'jobListModification', + content: 'Deleted an job' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-job-delete-popup', + template: '' +}) +export class JobDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ job }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(JobDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.job = job; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/job', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/job', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/job/job-detail.component.html b/src/main/webapp/app/entities/job/job-detail.component.html new file mode 100644 index 0000000..ebe6520 --- /dev/null +++ b/src/main/webapp/app/entities/job/job-detail.component.html @@ -0,0 +1,47 @@ +
+
+
+

Job {{job.id}}

+
+ +
+
Job Title
+
+ {{job.jobTitle}} +
+
Min Salary
+
+ {{job.minSalary}} +
+
Max Salary
+
+ {{job.maxSalary}} +
+
Employee
+
+ +
+
Task
+
+ + {{task.title}}{{last ? '' : ', '}} + +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/job/job-detail.component.ts b/src/main/webapp/app/entities/job/job-detail.component.ts new file mode 100644 index 0000000..94b1d76 --- /dev/null +++ b/src/main/webapp/app/entities/job/job-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IJob } from 'app/shared/model/job.model'; + +@Component({ + selector: 'jhi-job-detail', + templateUrl: './job-detail.component.html' +}) +export class JobDetailComponent implements OnInit { + job: IJob; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ job }) => { + this.job = job; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/job/job-update.component.html b/src/main/webapp/app/entities/job/job-update.component.html new file mode 100644 index 0000000..38a5c4c --- /dev/null +++ b/src/main/webapp/app/entities/job/job-update.component.html @@ -0,0 +1,52 @@ +
+
+
+

Create or edit a Job

+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/job/job-update.component.ts b/src/main/webapp/app/entities/job/job-update.component.ts new file mode 100644 index 0000000..21f3d7d --- /dev/null +++ b/src/main/webapp/app/entities/job/job-update.component.ts @@ -0,0 +1,103 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiAlertService } from 'ng-jhipster'; +import { IJob } from 'app/shared/model/job.model'; +import { JobService } from './job.service'; +import { IEmployee } from 'app/shared/model/employee.model'; +import { EmployeeService } from 'app/entities/employee'; +import { ITask } from 'app/shared/model/task.model'; +import { TaskService } from 'app/entities/task'; + +@Component({ + selector: 'jhi-job-update', + templateUrl: './job-update.component.html' +}) +export class JobUpdateComponent implements OnInit { + job: IJob; + isSaving: boolean; + + employees: IEmployee[]; + + tasks: ITask[]; + + constructor( + protected jhiAlertService: JhiAlertService, + protected jobService: JobService, + protected employeeService: EmployeeService, + protected taskService: TaskService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ job }) => { + this.job = job; + }); + this.employeeService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IEmployee[]) => (this.employees = res), (res: HttpErrorResponse) => this.onError(res.message)); + this.taskService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: ITask[]) => (this.tasks = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.job.id !== undefined) { + this.subscribeToSaveResponse(this.jobService.update(this.job)); + } else { + this.subscribeToSaveResponse(this.jobService.create(this.job)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackEmployeeById(index: number, item: IEmployee) { + return item.id; + } + + trackTaskById(index: number, item: ITask) { + return item.id; + } + + getSelected(selectedVals: Array, option: any) { + if (selectedVals) { + for (let i = 0; i < selectedVals.length; i++) { + if (option.id === selectedVals[i].id) { + return selectedVals[i]; + } + } + } + return option; + } +} diff --git a/src/main/webapp/app/entities/job/job.component.html b/src/main/webapp/app/entities/job/job.component.html new file mode 100644 index 0000000..89f6e52 --- /dev/null +++ b/src/main/webapp/app/entities/job/job.component.html @@ -0,0 +1,72 @@ +
+

+ Jobs + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
ID Job Title Min Salary Max Salary Employee
{{job.id}}{{job.jobTitle}}{{job.minSalary}}{{job.maxSalary}} + + +
+ + + +
+
+
+
+
+ +
+
+ +
+
+
diff --git a/src/main/webapp/app/entities/job/job.component.ts b/src/main/webapp/app/entities/job/job.component.ts new file mode 100644 index 0000000..77d2b37 --- /dev/null +++ b/src/main/webapp/app/entities/job/job.component.ts @@ -0,0 +1,131 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IJob } from 'app/shared/model/job.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { JobService } from './job.service'; + +@Component({ + selector: 'jhi-job', + templateUrl: './job.component.html' +}) +export class JobComponent implements OnInit, OnDestroy { + currentAccount: any; + jobs: IJob[]; + error: any; + success: any; + eventSubscriber: Subscription; + routeData: any; + links: any; + totalItems: any; + itemsPerPage: any; + page: any; + predicate: any; + previousPage: any; + reverse: any; + + constructor( + protected jobService: JobService, + protected parseLinks: JhiParseLinks, + protected jhiAlertService: JhiAlertService, + protected accountService: AccountService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager + ) { + this.itemsPerPage = ITEMS_PER_PAGE; + this.routeData = this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.previousPage = data.pagingParams.page; + this.reverse = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + }); + } + + loadAll() { + this.jobService + .query({ + page: this.page - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateJobs(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + loadPage(page: number) { + if (page !== this.previousPage) { + this.previousPage = page; + this.transition(); + } + } + + transition() { + this.router.navigate(['/job'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.reverse ? 'asc' : 'desc') + } + }); + this.loadAll(); + } + + clear() { + this.page = 0; + this.router.navigate([ + '/job', + { + page: this.page, + sort: this.predicate + ',' + (this.reverse ? 'asc' : 'desc') + } + ]); + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInJobs(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IJob) { + return item.id; + } + + registerChangeInJobs() { + this.eventSubscriber = this.eventManager.subscribe('jobListModification', response => this.loadAll()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateJobs(data: IJob[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + this.jobs = data; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/job/job.module.ts b/src/main/webapp/app/entities/job/job.module.ts new file mode 100644 index 0000000..29d4c23 --- /dev/null +++ b/src/main/webapp/app/entities/job/job.module.ts @@ -0,0 +1,23 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + JobComponent, + JobDetailComponent, + JobUpdateComponent, + JobDeletePopupComponent, + JobDeleteDialogComponent, + jobRoute, + jobPopupRoute +} from './'; + +const ENTITY_STATES = [...jobRoute, ...jobPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [JobComponent, JobDetailComponent, JobUpdateComponent, JobDeleteDialogComponent, JobDeletePopupComponent], + entryComponents: [JobComponent, JobUpdateComponent, JobDeleteDialogComponent, JobDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiJobModule {} diff --git a/src/main/webapp/app/entities/job/job.route.ts b/src/main/webapp/app/entities/job/job.route.ts new file mode 100644 index 0000000..9a84486 --- /dev/null +++ b/src/main/webapp/app/entities/job/job.route.ts @@ -0,0 +1,98 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { JhiPaginationUtil, JhiResolvePagingParams } from 'ng-jhipster'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Job } from 'app/shared/model/job.model'; +import { JobService } from './job.service'; +import { JobComponent } from './job.component'; +import { JobDetailComponent } from './job-detail.component'; +import { JobUpdateComponent } from './job-update.component'; +import { JobDeletePopupComponent } from './job-delete-dialog.component'; +import { IJob } from 'app/shared/model/job.model'; + +@Injectable({ providedIn: 'root' }) +export class JobResolve implements Resolve { + constructor(private service: JobService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((job: HttpResponse) => job.body) + ); + } + return of(new Job()); + } +} + +export const jobRoute: Routes = [ + { + path: '', + component: JobComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: ['ROLE_USER'], + defaultSort: 'id,asc', + pageTitle: 'Jobs' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: JobDetailComponent, + resolve: { + job: JobResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Jobs' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: JobUpdateComponent, + resolve: { + job: JobResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Jobs' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: JobUpdateComponent, + resolve: { + job: JobResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Jobs' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const jobPopupRoute: Routes = [ + { + path: ':id/delete', + component: JobDeletePopupComponent, + resolve: { + job: JobResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Jobs' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/job/job.service.ts b/src/main/webapp/app/entities/job/job.service.ts new file mode 100644 index 0000000..fc07e05 --- /dev/null +++ b/src/main/webapp/app/entities/job/job.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { IJob } from 'app/shared/model/job.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class JobService { + public resourceUrl = SERVER_API_URL + 'api/jobs'; + + constructor(protected http: HttpClient) {} + + create(job: IJob): Observable { + return this.http.post(this.resourceUrl, job, { observe: 'response' }); + } + + update(job: IJob): Observable { + return this.http.put(this.resourceUrl, job, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/location/index.ts b/src/main/webapp/app/entities/location/index.ts new file mode 100644 index 0000000..1789788 --- /dev/null +++ b/src/main/webapp/app/entities/location/index.ts @@ -0,0 +1,6 @@ +export * from './location.service'; +export * from './location-update.component'; +export * from './location-delete-dialog.component'; +export * from './location-detail.component'; +export * from './location.component'; +export * from './location.route'; diff --git a/src/main/webapp/app/entities/location/location-delete-dialog.component.html b/src/main/webapp/app/entities/location/location-delete-dialog.component.html new file mode 100644 index 0000000..c32231a --- /dev/null +++ b/src/main/webapp/app/entities/location/location-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/location/location-delete-dialog.component.ts b/src/main/webapp/app/entities/location/location-delete-dialog.component.ts new file mode 100644 index 0000000..3bfb17e --- /dev/null +++ b/src/main/webapp/app/entities/location/location-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ILocation } from 'app/shared/model/location.model'; +import { LocationService } from './location.service'; + +@Component({ + selector: 'jhi-location-delete-dialog', + templateUrl: './location-delete-dialog.component.html' +}) +export class LocationDeleteDialogComponent { + location: ILocation; + + constructor(protected locationService: LocationService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.locationService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'locationListModification', + content: 'Deleted an location' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-location-delete-popup', + template: '' +}) +export class LocationDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ location }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(LocationDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.location = location; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/location', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/location', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/location/location-detail.component.html b/src/main/webapp/app/entities/location/location-detail.component.html new file mode 100644 index 0000000..6da0364 --- /dev/null +++ b/src/main/webapp/app/entities/location/location-detail.component.html @@ -0,0 +1,45 @@ +
+
+
+

Location {{location.id}}

+
+ +
+
Street Address
+
+ {{location.streetAddress}} +
+
Postal Code
+
+ {{location.postalCode}} +
+
City
+
+ {{location.city}} +
+
State Province
+
+ {{location.stateProvince}} +
+
Country
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/location/location-detail.component.ts b/src/main/webapp/app/entities/location/location-detail.component.ts new file mode 100644 index 0000000..dce85f0 --- /dev/null +++ b/src/main/webapp/app/entities/location/location-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ILocation } from 'app/shared/model/location.model'; + +@Component({ + selector: 'jhi-location-detail', + templateUrl: './location-detail.component.html' +}) +export class LocationDetailComponent implements OnInit { + location: ILocation; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ location }) => { + this.location = location; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/location/location-update.component.html b/src/main/webapp/app/entities/location/location-update.component.html new file mode 100644 index 0000000..22c176c --- /dev/null +++ b/src/main/webapp/app/entities/location/location-update.component.html @@ -0,0 +1,51 @@ +
+
+
+

Create or edit a Location

+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/location/location-update.component.ts b/src/main/webapp/app/entities/location/location-update.component.ts new file mode 100644 index 0000000..b5d7c2c --- /dev/null +++ b/src/main/webapp/app/entities/location/location-update.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiAlertService } from 'ng-jhipster'; +import { ILocation } from 'app/shared/model/location.model'; +import { LocationService } from './location.service'; +import { ICountry } from 'app/shared/model/country.model'; +import { CountryService } from 'app/entities/country'; + +@Component({ + selector: 'jhi-location-update', + templateUrl: './location-update.component.html' +}) +export class LocationUpdateComponent implements OnInit { + location: ILocation; + isSaving: boolean; + + countries: ICountry[]; + + constructor( + protected jhiAlertService: JhiAlertService, + protected locationService: LocationService, + protected countryService: CountryService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ location }) => { + this.location = location; + }); + this.countryService + .query({ filter: 'location-is-null' }) + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe( + (res: ICountry[]) => { + if (!this.location.country || !this.location.country.id) { + this.countries = res; + } else { + this.countryService + .find(this.location.country.id) + .pipe( + filter((subResMayBeOk: HttpResponse) => subResMayBeOk.ok), + map((subResponse: HttpResponse) => subResponse.body) + ) + .subscribe( + (subRes: ICountry) => (this.countries = [subRes].concat(res)), + (subRes: HttpErrorResponse) => this.onError(subRes.message) + ); + } + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.location.id !== undefined) { + this.subscribeToSaveResponse(this.locationService.update(this.location)); + } else { + this.subscribeToSaveResponse(this.locationService.create(this.location)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackCountryById(index: number, item: ICountry) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/location/location.component.html b/src/main/webapp/app/entities/location/location.component.html new file mode 100644 index 0000000..a19fcb6 --- /dev/null +++ b/src/main/webapp/app/entities/location/location.component.html @@ -0,0 +1,66 @@ +
+

+ Locations + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
IDStreet AddressPostal CodeCityState ProvinceCountry
{{location.id}}{{location.streetAddress}}{{location.postalCode}}{{location.city}}{{location.stateProvince}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/location/location.component.ts b/src/main/webapp/app/entities/location/location.component.ts new file mode 100644 index 0000000..0a48959 --- /dev/null +++ b/src/main/webapp/app/entities/location/location.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; + +import { ILocation } from 'app/shared/model/location.model'; +import { AccountService } from 'app/core'; +import { LocationService } from './location.service'; + +@Component({ + selector: 'jhi-location', + templateUrl: './location.component.html' +}) +export class LocationComponent implements OnInit, OnDestroy { + locations: ILocation[]; + currentAccount: any; + eventSubscriber: Subscription; + + constructor( + protected locationService: LocationService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected accountService: AccountService + ) {} + + loadAll() { + this.locationService + .query() + .pipe( + filter((res: HttpResponse) => res.ok), + map((res: HttpResponse) => res.body) + ) + .subscribe( + (res: ILocation[]) => { + this.locations = res; + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInLocations(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: ILocation) { + return item.id; + } + + registerChangeInLocations() { + this.eventSubscriber = this.eventManager.subscribe('locationListModification', response => this.loadAll()); + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/location/location.module.ts b/src/main/webapp/app/entities/location/location.module.ts new file mode 100644 index 0000000..fd54d38 --- /dev/null +++ b/src/main/webapp/app/entities/location/location.module.ts @@ -0,0 +1,29 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + LocationComponent, + LocationDetailComponent, + LocationUpdateComponent, + LocationDeletePopupComponent, + LocationDeleteDialogComponent, + locationRoute, + locationPopupRoute +} from './'; + +const ENTITY_STATES = [...locationRoute, ...locationPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + LocationComponent, + LocationDetailComponent, + LocationUpdateComponent, + LocationDeleteDialogComponent, + LocationDeletePopupComponent + ], + entryComponents: [LocationComponent, LocationUpdateComponent, LocationDeleteDialogComponent, LocationDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiLocationModule {} diff --git a/src/main/webapp/app/entities/location/location.route.ts b/src/main/webapp/app/entities/location/location.route.ts new file mode 100644 index 0000000..f378f9f --- /dev/null +++ b/src/main/webapp/app/entities/location/location.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Location } from 'app/shared/model/location.model'; +import { LocationService } from './location.service'; +import { LocationComponent } from './location.component'; +import { LocationDetailComponent } from './location-detail.component'; +import { LocationUpdateComponent } from './location-update.component'; +import { LocationDeletePopupComponent } from './location-delete-dialog.component'; +import { ILocation } from 'app/shared/model/location.model'; + +@Injectable({ providedIn: 'root' }) +export class LocationResolve implements Resolve { + constructor(private service: LocationService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((location: HttpResponse) => location.body) + ); + } + return of(new Location()); + } +} + +export const locationRoute: Routes = [ + { + path: '', + component: LocationComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Locations' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: LocationDetailComponent, + resolve: { + location: LocationResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Locations' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: LocationUpdateComponent, + resolve: { + location: LocationResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Locations' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: LocationUpdateComponent, + resolve: { + location: LocationResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Locations' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const locationPopupRoute: Routes = [ + { + path: ':id/delete', + component: LocationDeletePopupComponent, + resolve: { + location: LocationResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Locations' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/location/location.service.ts b/src/main/webapp/app/entities/location/location.service.ts new file mode 100644 index 0000000..f819b07 --- /dev/null +++ b/src/main/webapp/app/entities/location/location.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { ILocation } from 'app/shared/model/location.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class LocationService { + public resourceUrl = SERVER_API_URL + 'api/locations'; + + constructor(protected http: HttpClient) {} + + create(location: ILocation): Observable { + return this.http.post(this.resourceUrl, location, { observe: 'response' }); + } + + update(location: ILocation): Observable { + return this.http.put(this.resourceUrl, location, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/region/index.ts b/src/main/webapp/app/entities/region/index.ts new file mode 100644 index 0000000..587d678 --- /dev/null +++ b/src/main/webapp/app/entities/region/index.ts @@ -0,0 +1,6 @@ +export * from './region.service'; +export * from './region-update.component'; +export * from './region-delete-dialog.component'; +export * from './region-detail.component'; +export * from './region.component'; +export * from './region.route'; diff --git a/src/main/webapp/app/entities/region/region-delete-dialog.component.html b/src/main/webapp/app/entities/region/region-delete-dialog.component.html new file mode 100644 index 0000000..df486e7 --- /dev/null +++ b/src/main/webapp/app/entities/region/region-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/region/region-delete-dialog.component.ts b/src/main/webapp/app/entities/region/region-delete-dialog.component.ts new file mode 100644 index 0000000..d279381 --- /dev/null +++ b/src/main/webapp/app/entities/region/region-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IRegion } from 'app/shared/model/region.model'; +import { RegionService } from './region.service'; + +@Component({ + selector: 'jhi-region-delete-dialog', + templateUrl: './region-delete-dialog.component.html' +}) +export class RegionDeleteDialogComponent { + region: IRegion; + + constructor(protected regionService: RegionService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.regionService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'regionListModification', + content: 'Deleted an region' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-region-delete-popup', + template: '' +}) +export class RegionDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ region }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(RegionDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.region = region; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/region', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/region', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/region/region-detail.component.html b/src/main/webapp/app/entities/region/region-detail.component.html new file mode 100644 index 0000000..a6748f0 --- /dev/null +++ b/src/main/webapp/app/entities/region/region-detail.component.html @@ -0,0 +1,27 @@ +
+
+
+

Region {{region.id}}

+
+ +
+
Region Name
+
+ {{region.regionName}} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/region/region-detail.component.ts b/src/main/webapp/app/entities/region/region-detail.component.ts new file mode 100644 index 0000000..dfbc2e9 --- /dev/null +++ b/src/main/webapp/app/entities/region/region-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IRegion } from 'app/shared/model/region.model'; + +@Component({ + selector: 'jhi-region-detail', + templateUrl: './region-detail.component.html' +}) +export class RegionDetailComponent implements OnInit { + region: IRegion; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ region }) => { + this.region = region; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/region/region-update.component.html b/src/main/webapp/app/entities/region/region-update.component.html new file mode 100644 index 0000000..f8e713c --- /dev/null +++ b/src/main/webapp/app/entities/region/region-update.component.html @@ -0,0 +1,29 @@ +
+
+
+

Create or edit a Region

+
+ +
+ + +
+
+ + +
+ +
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/region/region-update.component.ts b/src/main/webapp/app/entities/region/region-update.component.ts new file mode 100644 index 0000000..edad784 --- /dev/null +++ b/src/main/webapp/app/entities/region/region-update.component.ts @@ -0,0 +1,51 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { IRegion } from 'app/shared/model/region.model'; +import { RegionService } from './region.service'; + +@Component({ + selector: 'jhi-region-update', + templateUrl: './region-update.component.html' +}) +export class RegionUpdateComponent implements OnInit { + region: IRegion; + isSaving: boolean; + + constructor(protected regionService: RegionService, protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ region }) => { + this.region = region; + }); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.region.id !== undefined) { + this.subscribeToSaveResponse(this.regionService.update(this.region)); + } else { + this.subscribeToSaveResponse(this.regionService.create(this.region)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/region/region.component.html b/src/main/webapp/app/entities/region/region.component.html new file mode 100644 index 0000000..bdb6ebe --- /dev/null +++ b/src/main/webapp/app/entities/region/region.component.html @@ -0,0 +1,54 @@ +
+

+ Regions + +

+ +
+
+ + + + + + + + + + + + + + + +
IDRegion Name
{{region.id}}{{region.regionName}} +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/region/region.component.ts b/src/main/webapp/app/entities/region/region.component.ts new file mode 100644 index 0000000..3dbe250 --- /dev/null +++ b/src/main/webapp/app/entities/region/region.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; + +import { IRegion } from 'app/shared/model/region.model'; +import { AccountService } from 'app/core'; +import { RegionService } from './region.service'; + +@Component({ + selector: 'jhi-region', + templateUrl: './region.component.html' +}) +export class RegionComponent implements OnInit, OnDestroy { + regions: IRegion[]; + currentAccount: any; + eventSubscriber: Subscription; + + constructor( + protected regionService: RegionService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected accountService: AccountService + ) {} + + loadAll() { + this.regionService + .query() + .pipe( + filter((res: HttpResponse) => res.ok), + map((res: HttpResponse) => res.body) + ) + .subscribe( + (res: IRegion[]) => { + this.regions = res; + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInRegions(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IRegion) { + return item.id; + } + + registerChangeInRegions() { + this.eventSubscriber = this.eventManager.subscribe('regionListModification', response => this.loadAll()); + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/region/region.module.ts b/src/main/webapp/app/entities/region/region.module.ts new file mode 100644 index 0000000..cc4cb20 --- /dev/null +++ b/src/main/webapp/app/entities/region/region.module.ts @@ -0,0 +1,23 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + RegionComponent, + RegionDetailComponent, + RegionUpdateComponent, + RegionDeletePopupComponent, + RegionDeleteDialogComponent, + regionRoute, + regionPopupRoute +} from './'; + +const ENTITY_STATES = [...regionRoute, ...regionPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [RegionComponent, RegionDetailComponent, RegionUpdateComponent, RegionDeleteDialogComponent, RegionDeletePopupComponent], + entryComponents: [RegionComponent, RegionUpdateComponent, RegionDeleteDialogComponent, RegionDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiRegionModule {} diff --git a/src/main/webapp/app/entities/region/region.route.ts b/src/main/webapp/app/entities/region/region.route.ts new file mode 100644 index 0000000..37f4e2b --- /dev/null +++ b/src/main/webapp/app/entities/region/region.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Region } from 'app/shared/model/region.model'; +import { RegionService } from './region.service'; +import { RegionComponent } from './region.component'; +import { RegionDetailComponent } from './region-detail.component'; +import { RegionUpdateComponent } from './region-update.component'; +import { RegionDeletePopupComponent } from './region-delete-dialog.component'; +import { IRegion } from 'app/shared/model/region.model'; + +@Injectable({ providedIn: 'root' }) +export class RegionResolve implements Resolve { + constructor(private service: RegionService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((region: HttpResponse) => region.body) + ); + } + return of(new Region()); + } +} + +export const regionRoute: Routes = [ + { + path: '', + component: RegionComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Regions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: RegionDetailComponent, + resolve: { + region: RegionResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Regions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: RegionUpdateComponent, + resolve: { + region: RegionResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Regions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: RegionUpdateComponent, + resolve: { + region: RegionResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Regions' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const regionPopupRoute: Routes = [ + { + path: ':id/delete', + component: RegionDeletePopupComponent, + resolve: { + region: RegionResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Regions' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/region/region.service.ts b/src/main/webapp/app/entities/region/region.service.ts new file mode 100644 index 0000000..569064b --- /dev/null +++ b/src/main/webapp/app/entities/region/region.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { IRegion } from 'app/shared/model/region.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class RegionService { + public resourceUrl = SERVER_API_URL + 'api/regions'; + + constructor(protected http: HttpClient) {} + + create(region: IRegion): Observable { + return this.http.post(this.resourceUrl, region, { observe: 'response' }); + } + + update(region: IRegion): Observable { + return this.http.put(this.resourceUrl, region, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/task/index.ts b/src/main/webapp/app/entities/task/index.ts new file mode 100644 index 0000000..2abc445 --- /dev/null +++ b/src/main/webapp/app/entities/task/index.ts @@ -0,0 +1,6 @@ +export * from './task.service'; +export * from './task-update.component'; +export * from './task-delete-dialog.component'; +export * from './task-detail.component'; +export * from './task.component'; +export * from './task.route'; diff --git a/src/main/webapp/app/entities/task/task-delete-dialog.component.html b/src/main/webapp/app/entities/task/task-delete-dialog.component.html new file mode 100644 index 0000000..f5c9d2a --- /dev/null +++ b/src/main/webapp/app/entities/task/task-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/task/task-delete-dialog.component.ts b/src/main/webapp/app/entities/task/task-delete-dialog.component.ts new file mode 100644 index 0000000..bb77623 --- /dev/null +++ b/src/main/webapp/app/entities/task/task-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ITask } from 'app/shared/model/task.model'; +import { TaskService } from './task.service'; + +@Component({ + selector: 'jhi-task-delete-dialog', + templateUrl: './task-delete-dialog.component.html' +}) +export class TaskDeleteDialogComponent { + task: ITask; + + constructor(protected taskService: TaskService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.taskService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'taskListModification', + content: 'Deleted an task' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-task-delete-popup', + template: '' +}) +export class TaskDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ task }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(TaskDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.task = task; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/task', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/task', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/task/task-detail.component.html b/src/main/webapp/app/entities/task/task-detail.component.html new file mode 100644 index 0000000..9e6963c --- /dev/null +++ b/src/main/webapp/app/entities/task/task-detail.component.html @@ -0,0 +1,31 @@ +
+
+
+

Task {{task.id}}

+
+ +
+
Title
+
+ {{task.title}} +
+
Description
+
+ {{task.description}} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/task/task-detail.component.ts b/src/main/webapp/app/entities/task/task-detail.component.ts new file mode 100644 index 0000000..60b16a5 --- /dev/null +++ b/src/main/webapp/app/entities/task/task-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ITask } from 'app/shared/model/task.model'; + +@Component({ + selector: 'jhi-task-detail', + templateUrl: './task-detail.component.html' +}) +export class TaskDetailComponent implements OnInit { + task: ITask; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ task }) => { + this.task = task; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/task/task-update.component.html b/src/main/webapp/app/entities/task/task-update.component.html new file mode 100644 index 0000000..d562869 --- /dev/null +++ b/src/main/webapp/app/entities/task/task-update.component.html @@ -0,0 +1,34 @@ +
+
+
+

Create or edit a Task

+
+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/task/task-update.component.ts b/src/main/webapp/app/entities/task/task-update.component.ts new file mode 100644 index 0000000..2405c04 --- /dev/null +++ b/src/main/webapp/app/entities/task/task-update.component.ts @@ -0,0 +1,87 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiAlertService } from 'ng-jhipster'; +import { ITask } from 'app/shared/model/task.model'; +import { TaskService } from './task.service'; +import { IJob } from 'app/shared/model/job.model'; +import { JobService } from 'app/entities/job'; + +@Component({ + selector: 'jhi-task-update', + templateUrl: './task-update.component.html' +}) +export class TaskUpdateComponent implements OnInit { + task: ITask; + isSaving: boolean; + + jobs: IJob[]; + + constructor( + protected jhiAlertService: JhiAlertService, + protected taskService: TaskService, + protected jobService: JobService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ task }) => { + this.task = task; + }); + this.jobService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IJob[]) => (this.jobs = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.task.id !== undefined) { + this.subscribeToSaveResponse(this.taskService.update(this.task)); + } else { + this.subscribeToSaveResponse(this.taskService.create(this.task)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackJobById(index: number, item: IJob) { + return item.id; + } + + getSelected(selectedVals: Array, option: any) { + if (selectedVals) { + for (let i = 0; i < selectedVals.length; i++) { + if (option.id === selectedVals[i].id) { + return selectedVals[i]; + } + } + } + return option; + } +} diff --git a/src/main/webapp/app/entities/task/task.component.html b/src/main/webapp/app/entities/task/task.component.html new file mode 100644 index 0000000..a3392a2 --- /dev/null +++ b/src/main/webapp/app/entities/task/task.component.html @@ -0,0 +1,56 @@ +
+

+ Tasks + +

+ +
+
+ + + + + + + + + + + + + + + + + +
IDTitleDescription
{{task.id}}{{task.title}}{{task.description}} +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/task/task.component.ts b/src/main/webapp/app/entities/task/task.component.ts new file mode 100644 index 0000000..4ab4f98 --- /dev/null +++ b/src/main/webapp/app/entities/task/task.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; + +import { ITask } from 'app/shared/model/task.model'; +import { AccountService } from 'app/core'; +import { TaskService } from './task.service'; + +@Component({ + selector: 'jhi-task', + templateUrl: './task.component.html' +}) +export class TaskComponent implements OnInit, OnDestroy { + tasks: ITask[]; + currentAccount: any; + eventSubscriber: Subscription; + + constructor( + protected taskService: TaskService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected accountService: AccountService + ) {} + + loadAll() { + this.taskService + .query() + .pipe( + filter((res: HttpResponse) => res.ok), + map((res: HttpResponse) => res.body) + ) + .subscribe( + (res: ITask[]) => { + this.tasks = res; + }, + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInTasks(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: ITask) { + return item.id; + } + + registerChangeInTasks() { + this.eventSubscriber = this.eventManager.subscribe('taskListModification', response => this.loadAll()); + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/task/task.module.ts b/src/main/webapp/app/entities/task/task.module.ts new file mode 100644 index 0000000..fff3cb2 --- /dev/null +++ b/src/main/webapp/app/entities/task/task.module.ts @@ -0,0 +1,23 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { IntegrationUiSharedModule } from 'app/shared'; +import { + TaskComponent, + TaskDetailComponent, + TaskUpdateComponent, + TaskDeletePopupComponent, + TaskDeleteDialogComponent, + taskRoute, + taskPopupRoute +} from './'; + +const ENTITY_STATES = [...taskRoute, ...taskPopupRoute]; + +@NgModule({ + imports: [IntegrationUiSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [TaskComponent, TaskDetailComponent, TaskUpdateComponent, TaskDeleteDialogComponent, TaskDeletePopupComponent], + entryComponents: [TaskComponent, TaskUpdateComponent, TaskDeleteDialogComponent, TaskDeletePopupComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class IntegrationUiTaskModule {} diff --git a/src/main/webapp/app/entities/task/task.route.ts b/src/main/webapp/app/entities/task/task.route.ts new file mode 100644 index 0000000..8273782 --- /dev/null +++ b/src/main/webapp/app/entities/task/task.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Task } from 'app/shared/model/task.model'; +import { TaskService } from './task.service'; +import { TaskComponent } from './task.component'; +import { TaskDetailComponent } from './task-detail.component'; +import { TaskUpdateComponent } from './task-update.component'; +import { TaskDeletePopupComponent } from './task-delete-dialog.component'; +import { ITask } from 'app/shared/model/task.model'; + +@Injectable({ providedIn: 'root' }) +export class TaskResolve implements Resolve { + constructor(private service: TaskService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((task: HttpResponse) => task.body) + ); + } + return of(new Task()); + } +} + +export const taskRoute: Routes = [ + { + path: '', + component: TaskComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Tasks' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: TaskDetailComponent, + resolve: { + task: TaskResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Tasks' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: TaskUpdateComponent, + resolve: { + task: TaskResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Tasks' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: TaskUpdateComponent, + resolve: { + task: TaskResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Tasks' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const taskPopupRoute: Routes = [ + { + path: ':id/delete', + component: TaskDeletePopupComponent, + resolve: { + task: TaskResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Tasks' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/task/task.service.ts b/src/main/webapp/app/entities/task/task.service.ts new file mode 100644 index 0000000..2f0f245 --- /dev/null +++ b/src/main/webapp/app/entities/task/task.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared'; +import { ITask } from 'app/shared/model/task.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class TaskService { + public resourceUrl = SERVER_API_URL + 'api/tasks'; + + constructor(protected http: HttpClient) {} + + create(task: ITask): Observable { + return this.http.post(this.resourceUrl, task, { observe: 'response' }); + } + + update(task: ITask): Observable { + return this.http.put(this.resourceUrl, task, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index 3d4c6a2..1a8b831 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -27,6 +27,54 @@ diff --git a/src/main/webapp/app/shared/model/country.model.ts b/src/main/webapp/app/shared/model/country.model.ts new file mode 100644 index 0000000..4a675df --- /dev/null +++ b/src/main/webapp/app/shared/model/country.model.ts @@ -0,0 +1,11 @@ +import { IRegion } from 'app/shared/model/region.model'; + +export interface ICountry { + id?: number; + countryName?: string; + region?: IRegion; +} + +export class Country implements ICountry { + constructor(public id?: number, public countryName?: string, public region?: IRegion) {} +} diff --git a/src/main/webapp/app/shared/model/department.model.ts b/src/main/webapp/app/shared/model/department.model.ts new file mode 100644 index 0000000..074ddff --- /dev/null +++ b/src/main/webapp/app/shared/model/department.model.ts @@ -0,0 +1,13 @@ +import { ILocation } from 'app/shared/model/location.model'; +import { IEmployee } from 'app/shared/model/employee.model'; + +export interface IDepartment { + id?: number; + departmentName?: string; + location?: ILocation; + employees?: IEmployee[]; +} + +export class Department implements IDepartment { + constructor(public id?: number, public departmentName?: string, public location?: ILocation, public employees?: IEmployee[]) {} +} diff --git a/src/main/webapp/app/shared/model/employee.model.ts b/src/main/webapp/app/shared/model/employee.model.ts new file mode 100644 index 0000000..d36797d --- /dev/null +++ b/src/main/webapp/app/shared/model/employee.model.ts @@ -0,0 +1,34 @@ +import { Moment } from 'moment'; +import { IDepartment } from 'app/shared/model/department.model'; +import { IJob } from 'app/shared/model/job.model'; +import { IEmployee } from 'app/shared/model/employee.model'; + +export interface IEmployee { + id?: number; + firstName?: string; + lastName?: string; + email?: string; + phoneNumber?: string; + hireDate?: Moment; + salary?: number; + commissionPct?: number; + department?: IDepartment; + jobs?: IJob[]; + manager?: IEmployee; +} + +export class Employee implements IEmployee { + constructor( + public id?: number, + public firstName?: string, + public lastName?: string, + public email?: string, + public phoneNumber?: string, + public hireDate?: Moment, + public salary?: number, + public commissionPct?: number, + public department?: IDepartment, + public jobs?: IJob[], + public manager?: IEmployee + ) {} +} diff --git a/src/main/webapp/app/shared/model/job-history.model.ts b/src/main/webapp/app/shared/model/job-history.model.ts new file mode 100644 index 0000000..7d7cb2f --- /dev/null +++ b/src/main/webapp/app/shared/model/job-history.model.ts @@ -0,0 +1,32 @@ +import { Moment } from 'moment'; +import { IJob } from 'app/shared/model/job.model'; +import { IDepartment } from 'app/shared/model/department.model'; +import { IEmployee } from 'app/shared/model/employee.model'; + +export const enum Language { + FRENCH = 'FRENCH', + ENGLISH = 'ENGLISH', + SPANISH = 'SPANISH' +} + +export interface IJobHistory { + id?: number; + startDate?: Moment; + endDate?: Moment; + language?: Language; + job?: IJob; + department?: IDepartment; + employee?: IEmployee; +} + +export class JobHistory implements IJobHistory { + constructor( + public id?: number, + public startDate?: Moment, + public endDate?: Moment, + public language?: Language, + public job?: IJob, + public department?: IDepartment, + public employee?: IEmployee + ) {} +} diff --git a/src/main/webapp/app/shared/model/job.model.ts b/src/main/webapp/app/shared/model/job.model.ts new file mode 100644 index 0000000..c2dda93 --- /dev/null +++ b/src/main/webapp/app/shared/model/job.model.ts @@ -0,0 +1,22 @@ +import { IEmployee } from 'app/shared/model/employee.model'; +import { ITask } from 'app/shared/model/task.model'; + +export interface IJob { + id?: number; + jobTitle?: string; + minSalary?: number; + maxSalary?: number; + employee?: IEmployee; + tasks?: ITask[]; +} + +export class Job implements IJob { + constructor( + public id?: number, + public jobTitle?: string, + public minSalary?: number, + public maxSalary?: number, + public employee?: IEmployee, + public tasks?: ITask[] + ) {} +} diff --git a/src/main/webapp/app/shared/model/location.model.ts b/src/main/webapp/app/shared/model/location.model.ts new file mode 100644 index 0000000..06e07cd --- /dev/null +++ b/src/main/webapp/app/shared/model/location.model.ts @@ -0,0 +1,21 @@ +import { ICountry } from 'app/shared/model/country.model'; + +export interface ILocation { + id?: number; + streetAddress?: string; + postalCode?: string; + city?: string; + stateProvince?: string; + country?: ICountry; +} + +export class Location implements ILocation { + constructor( + public id?: number, + public streetAddress?: string, + public postalCode?: string, + public city?: string, + public stateProvince?: string, + public country?: ICountry + ) {} +} diff --git a/src/main/webapp/app/shared/model/region.model.ts b/src/main/webapp/app/shared/model/region.model.ts new file mode 100644 index 0000000..6cb9478 --- /dev/null +++ b/src/main/webapp/app/shared/model/region.model.ts @@ -0,0 +1,8 @@ +export interface IRegion { + id?: number; + regionName?: string; +} + +export class Region implements IRegion { + constructor(public id?: number, public regionName?: string) {} +} diff --git a/src/main/webapp/app/shared/model/task.model.ts b/src/main/webapp/app/shared/model/task.model.ts new file mode 100644 index 0000000..b9d65de --- /dev/null +++ b/src/main/webapp/app/shared/model/task.model.ts @@ -0,0 +1,12 @@ +import { IJob } from 'app/shared/model/job.model'; + +export interface ITask { + id?: number; + title?: string; + description?: string; + jobs?: IJob[]; +} + +export class Task implements ITask { + constructor(public id?: number, public title?: string, public description?: string, public jobs?: IJob[]) {} +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/CountryResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/CountryResourceIntTest.java new file mode 100644 index 0000000..a7b9689 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/CountryResourceIntTest.java @@ -0,0 +1,251 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Country; +import com.cooperl.si.integration.ui.repository.CountryRepository; +import com.cooperl.si.integration.ui.service.CountryService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the CountryResource REST controller. + * + * @see CountryResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class CountryResourceIntTest { + + private static final String DEFAULT_COUNTRY_NAME = "AAAAAAAAAA"; + private static final String UPDATED_COUNTRY_NAME = "BBBBBBBBBB"; + + @Autowired + private CountryRepository countryRepository; + + @Autowired + private CountryService countryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restCountryMockMvc; + + private Country country; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final CountryResource countryResource = new CountryResource(countryService); + this.restCountryMockMvc = MockMvcBuilders.standaloneSetup(countryResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Country createEntity(EntityManager em) { + Country country = new Country() + .countryName(DEFAULT_COUNTRY_NAME); + return country; + } + + @Before + public void initTest() { + country = createEntity(em); + } + + @Test + @Transactional + public void createCountry() throws Exception { + int databaseSizeBeforeCreate = countryRepository.findAll().size(); + + // Create the Country + restCountryMockMvc.perform(post("/api/countries") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(country))) + .andExpect(status().isCreated()); + + // Validate the Country in the database + List countryList = countryRepository.findAll(); + assertThat(countryList).hasSize(databaseSizeBeforeCreate + 1); + Country testCountry = countryList.get(countryList.size() - 1); + assertThat(testCountry.getCountryName()).isEqualTo(DEFAULT_COUNTRY_NAME); + } + + @Test + @Transactional + public void createCountryWithExistingId() throws Exception { + int databaseSizeBeforeCreate = countryRepository.findAll().size(); + + // Create the Country with an existing ID + country.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restCountryMockMvc.perform(post("/api/countries") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(country))) + .andExpect(status().isBadRequest()); + + // Validate the Country in the database + List countryList = countryRepository.findAll(); + assertThat(countryList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllCountries() throws Exception { + // Initialize the database + countryRepository.saveAndFlush(country); + + // Get all the countryList + restCountryMockMvc.perform(get("/api/countries?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(country.getId().intValue()))) + .andExpect(jsonPath("$.[*].countryName").value(hasItem(DEFAULT_COUNTRY_NAME.toString()))); + } + + @Test + @Transactional + public void getCountry() throws Exception { + // Initialize the database + countryRepository.saveAndFlush(country); + + // Get the country + restCountryMockMvc.perform(get("/api/countries/{id}", country.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(country.getId().intValue())) + .andExpect(jsonPath("$.countryName").value(DEFAULT_COUNTRY_NAME.toString())); + } + + @Test + @Transactional + public void getNonExistingCountry() throws Exception { + // Get the country + restCountryMockMvc.perform(get("/api/countries/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateCountry() throws Exception { + // Initialize the database + countryService.save(country); + + int databaseSizeBeforeUpdate = countryRepository.findAll().size(); + + // Update the country + Country updatedCountry = countryRepository.findById(country.getId()).get(); + // Disconnect from session so that the updates on updatedCountry are not directly saved in db + em.detach(updatedCountry); + updatedCountry + .countryName(UPDATED_COUNTRY_NAME); + + restCountryMockMvc.perform(put("/api/countries") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedCountry))) + .andExpect(status().isOk()); + + // Validate the Country in the database + List countryList = countryRepository.findAll(); + assertThat(countryList).hasSize(databaseSizeBeforeUpdate); + Country testCountry = countryList.get(countryList.size() - 1); + assertThat(testCountry.getCountryName()).isEqualTo(UPDATED_COUNTRY_NAME); + } + + @Test + @Transactional + public void updateNonExistingCountry() throws Exception { + int databaseSizeBeforeUpdate = countryRepository.findAll().size(); + + // Create the Country + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restCountryMockMvc.perform(put("/api/countries") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(country))) + .andExpect(status().isBadRequest()); + + // Validate the Country in the database + List countryList = countryRepository.findAll(); + assertThat(countryList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteCountry() throws Exception { + // Initialize the database + countryService.save(country); + + int databaseSizeBeforeDelete = countryRepository.findAll().size(); + + // Delete the country + restCountryMockMvc.perform(delete("/api/countries/{id}", country.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List countryList = countryRepository.findAll(); + assertThat(countryList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Country.class); + Country country1 = new Country(); + country1.setId(1L); + Country country2 = new Country(); + country2.setId(country1.getId()); + assertThat(country1).isEqualTo(country2); + country2.setId(2L); + assertThat(country1).isNotEqualTo(country2); + country1.setId(null); + assertThat(country1).isNotEqualTo(country2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/DepartmentResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/DepartmentResourceIntTest.java new file mode 100644 index 0000000..c5f4f49 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/DepartmentResourceIntTest.java @@ -0,0 +1,269 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Department; +import com.cooperl.si.integration.ui.repository.DepartmentRepository; +import com.cooperl.si.integration.ui.service.DepartmentService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the DepartmentResource REST controller. + * + * @see DepartmentResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class DepartmentResourceIntTest { + + private static final String DEFAULT_DEPARTMENT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_DEPARTMENT_NAME = "BBBBBBBBBB"; + + @Autowired + private DepartmentRepository departmentRepository; + + @Autowired + private DepartmentService departmentService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restDepartmentMockMvc; + + private Department department; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final DepartmentResource departmentResource = new DepartmentResource(departmentService); + this.restDepartmentMockMvc = MockMvcBuilders.standaloneSetup(departmentResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Department createEntity(EntityManager em) { + Department department = new Department() + .departmentName(DEFAULT_DEPARTMENT_NAME); + return department; + } + + @Before + public void initTest() { + department = createEntity(em); + } + + @Test + @Transactional + public void createDepartment() throws Exception { + int databaseSizeBeforeCreate = departmentRepository.findAll().size(); + + // Create the Department + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(department))) + .andExpect(status().isCreated()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeCreate + 1); + Department testDepartment = departmentList.get(departmentList.size() - 1); + assertThat(testDepartment.getDepartmentName()).isEqualTo(DEFAULT_DEPARTMENT_NAME); + } + + @Test + @Transactional + public void createDepartmentWithExistingId() throws Exception { + int databaseSizeBeforeCreate = departmentRepository.findAll().size(); + + // Create the Department with an existing ID + department.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(department))) + .andExpect(status().isBadRequest()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkDepartmentNameIsRequired() throws Exception { + int databaseSizeBeforeTest = departmentRepository.findAll().size(); + // set the field null + department.setDepartmentName(null); + + // Create the Department, which fails. + + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(department))) + .andExpect(status().isBadRequest()); + + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllDepartments() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + // Get all the departmentList + restDepartmentMockMvc.perform(get("/api/departments?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(department.getId().intValue()))) + .andExpect(jsonPath("$.[*].departmentName").value(hasItem(DEFAULT_DEPARTMENT_NAME.toString()))); + } + + @Test + @Transactional + public void getDepartment() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + // Get the department + restDepartmentMockMvc.perform(get("/api/departments/{id}", department.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(department.getId().intValue())) + .andExpect(jsonPath("$.departmentName").value(DEFAULT_DEPARTMENT_NAME.toString())); + } + + @Test + @Transactional + public void getNonExistingDepartment() throws Exception { + // Get the department + restDepartmentMockMvc.perform(get("/api/departments/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateDepartment() throws Exception { + // Initialize the database + departmentService.save(department); + + int databaseSizeBeforeUpdate = departmentRepository.findAll().size(); + + // Update the department + Department updatedDepartment = departmentRepository.findById(department.getId()).get(); + // Disconnect from session so that the updates on updatedDepartment are not directly saved in db + em.detach(updatedDepartment); + updatedDepartment + .departmentName(UPDATED_DEPARTMENT_NAME); + + restDepartmentMockMvc.perform(put("/api/departments") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedDepartment))) + .andExpect(status().isOk()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeUpdate); + Department testDepartment = departmentList.get(departmentList.size() - 1); + assertThat(testDepartment.getDepartmentName()).isEqualTo(UPDATED_DEPARTMENT_NAME); + } + + @Test + @Transactional + public void updateNonExistingDepartment() throws Exception { + int databaseSizeBeforeUpdate = departmentRepository.findAll().size(); + + // Create the Department + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restDepartmentMockMvc.perform(put("/api/departments") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(department))) + .andExpect(status().isBadRequest()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteDepartment() throws Exception { + // Initialize the database + departmentService.save(department); + + int databaseSizeBeforeDelete = departmentRepository.findAll().size(); + + // Delete the department + restDepartmentMockMvc.perform(delete("/api/departments/{id}", department.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Department.class); + Department department1 = new Department(); + department1.setId(1L); + Department department2 = new Department(); + department2.setId(department1.getId()); + assertThat(department1).isEqualTo(department2); + department2.setId(2L); + assertThat(department1).isNotEqualTo(department2); + department1.setId(null); + assertThat(department1).isNotEqualTo(department2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/EmployeeResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/EmployeeResourceIntTest.java new file mode 100644 index 0000000..96a0db6 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/EmployeeResourceIntTest.java @@ -0,0 +1,303 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Employee; +import com.cooperl.si.integration.ui.repository.EmployeeRepository; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the EmployeeResource REST controller. + * + * @see EmployeeResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class EmployeeResourceIntTest { + + private static final String DEFAULT_FIRST_NAME = "AAAAAAAAAA"; + private static final String UPDATED_FIRST_NAME = "BBBBBBBBBB"; + + private static final String DEFAULT_LAST_NAME = "AAAAAAAAAA"; + private static final String UPDATED_LAST_NAME = "BBBBBBBBBB"; + + private static final String DEFAULT_EMAIL = "AAAAAAAAAA"; + private static final String UPDATED_EMAIL = "BBBBBBBBBB"; + + private static final String DEFAULT_PHONE_NUMBER = "AAAAAAAAAA"; + private static final String UPDATED_PHONE_NUMBER = "BBBBBBBBBB"; + + private static final Instant DEFAULT_HIRE_DATE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_HIRE_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Long DEFAULT_SALARY = 1L; + private static final Long UPDATED_SALARY = 2L; + + private static final Long DEFAULT_COMMISSION_PCT = 1L; + private static final Long UPDATED_COMMISSION_PCT = 2L; + + @Autowired + private EmployeeRepository employeeRepository; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restEmployeeMockMvc; + + private Employee employee; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final EmployeeResource employeeResource = new EmployeeResource(employeeRepository); + this.restEmployeeMockMvc = MockMvcBuilders.standaloneSetup(employeeResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Employee createEntity(EntityManager em) { + Employee employee = new Employee() + .firstName(DEFAULT_FIRST_NAME) + .lastName(DEFAULT_LAST_NAME) + .email(DEFAULT_EMAIL) + .phoneNumber(DEFAULT_PHONE_NUMBER) + .hireDate(DEFAULT_HIRE_DATE) + .salary(DEFAULT_SALARY) + .commissionPct(DEFAULT_COMMISSION_PCT); + return employee; + } + + @Before + public void initTest() { + employee = createEntity(em); + } + + @Test + @Transactional + public void createEmployee() throws Exception { + int databaseSizeBeforeCreate = employeeRepository.findAll().size(); + + // Create the Employee + restEmployeeMockMvc.perform(post("/api/employees") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(employee))) + .andExpect(status().isCreated()); + + // Validate the Employee in the database + List employeeList = employeeRepository.findAll(); + assertThat(employeeList).hasSize(databaseSizeBeforeCreate + 1); + Employee testEmployee = employeeList.get(employeeList.size() - 1); + assertThat(testEmployee.getFirstName()).isEqualTo(DEFAULT_FIRST_NAME); + assertThat(testEmployee.getLastName()).isEqualTo(DEFAULT_LAST_NAME); + assertThat(testEmployee.getEmail()).isEqualTo(DEFAULT_EMAIL); + assertThat(testEmployee.getPhoneNumber()).isEqualTo(DEFAULT_PHONE_NUMBER); + assertThat(testEmployee.getHireDate()).isEqualTo(DEFAULT_HIRE_DATE); + assertThat(testEmployee.getSalary()).isEqualTo(DEFAULT_SALARY); + assertThat(testEmployee.getCommissionPct()).isEqualTo(DEFAULT_COMMISSION_PCT); + } + + @Test + @Transactional + public void createEmployeeWithExistingId() throws Exception { + int databaseSizeBeforeCreate = employeeRepository.findAll().size(); + + // Create the Employee with an existing ID + employee.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restEmployeeMockMvc.perform(post("/api/employees") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(employee))) + .andExpect(status().isBadRequest()); + + // Validate the Employee in the database + List employeeList = employeeRepository.findAll(); + assertThat(employeeList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllEmployees() throws Exception { + // Initialize the database + employeeRepository.saveAndFlush(employee); + + // Get all the employeeList + restEmployeeMockMvc.perform(get("/api/employees?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(employee.getId().intValue()))) + .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME.toString()))) + .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME.toString()))) + .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL.toString()))) + .andExpect(jsonPath("$.[*].phoneNumber").value(hasItem(DEFAULT_PHONE_NUMBER.toString()))) + .andExpect(jsonPath("$.[*].hireDate").value(hasItem(DEFAULT_HIRE_DATE.toString()))) + .andExpect(jsonPath("$.[*].salary").value(hasItem(DEFAULT_SALARY.intValue()))) + .andExpect(jsonPath("$.[*].commissionPct").value(hasItem(DEFAULT_COMMISSION_PCT.intValue()))); + } + + @Test + @Transactional + public void getEmployee() throws Exception { + // Initialize the database + employeeRepository.saveAndFlush(employee); + + // Get the employee + restEmployeeMockMvc.perform(get("/api/employees/{id}", employee.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(employee.getId().intValue())) + .andExpect(jsonPath("$.firstName").value(DEFAULT_FIRST_NAME.toString())) + .andExpect(jsonPath("$.lastName").value(DEFAULT_LAST_NAME.toString())) + .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL.toString())) + .andExpect(jsonPath("$.phoneNumber").value(DEFAULT_PHONE_NUMBER.toString())) + .andExpect(jsonPath("$.hireDate").value(DEFAULT_HIRE_DATE.toString())) + .andExpect(jsonPath("$.salary").value(DEFAULT_SALARY.intValue())) + .andExpect(jsonPath("$.commissionPct").value(DEFAULT_COMMISSION_PCT.intValue())); + } + + @Test + @Transactional + public void getNonExistingEmployee() throws Exception { + // Get the employee + restEmployeeMockMvc.perform(get("/api/employees/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateEmployee() throws Exception { + // Initialize the database + employeeRepository.saveAndFlush(employee); + + int databaseSizeBeforeUpdate = employeeRepository.findAll().size(); + + // Update the employee + Employee updatedEmployee = employeeRepository.findById(employee.getId()).get(); + // Disconnect from session so that the updates on updatedEmployee are not directly saved in db + em.detach(updatedEmployee); + updatedEmployee + .firstName(UPDATED_FIRST_NAME) + .lastName(UPDATED_LAST_NAME) + .email(UPDATED_EMAIL) + .phoneNumber(UPDATED_PHONE_NUMBER) + .hireDate(UPDATED_HIRE_DATE) + .salary(UPDATED_SALARY) + .commissionPct(UPDATED_COMMISSION_PCT); + + restEmployeeMockMvc.perform(put("/api/employees") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedEmployee))) + .andExpect(status().isOk()); + + // Validate the Employee in the database + List employeeList = employeeRepository.findAll(); + assertThat(employeeList).hasSize(databaseSizeBeforeUpdate); + Employee testEmployee = employeeList.get(employeeList.size() - 1); + assertThat(testEmployee.getFirstName()).isEqualTo(UPDATED_FIRST_NAME); + assertThat(testEmployee.getLastName()).isEqualTo(UPDATED_LAST_NAME); + assertThat(testEmployee.getEmail()).isEqualTo(UPDATED_EMAIL); + assertThat(testEmployee.getPhoneNumber()).isEqualTo(UPDATED_PHONE_NUMBER); + assertThat(testEmployee.getHireDate()).isEqualTo(UPDATED_HIRE_DATE); + assertThat(testEmployee.getSalary()).isEqualTo(UPDATED_SALARY); + assertThat(testEmployee.getCommissionPct()).isEqualTo(UPDATED_COMMISSION_PCT); + } + + @Test + @Transactional + public void updateNonExistingEmployee() throws Exception { + int databaseSizeBeforeUpdate = employeeRepository.findAll().size(); + + // Create the Employee + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restEmployeeMockMvc.perform(put("/api/employees") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(employee))) + .andExpect(status().isBadRequest()); + + // Validate the Employee in the database + List employeeList = employeeRepository.findAll(); + assertThat(employeeList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteEmployee() throws Exception { + // Initialize the database + employeeRepository.saveAndFlush(employee); + + int databaseSizeBeforeDelete = employeeRepository.findAll().size(); + + // Delete the employee + restEmployeeMockMvc.perform(delete("/api/employees/{id}", employee.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List employeeList = employeeRepository.findAll(); + assertThat(employeeList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Employee.class); + Employee employee1 = new Employee(); + employee1.setId(1L); + Employee employee2 = new Employee(); + employee2.setId(employee1.getId()); + assertThat(employee1).isEqualTo(employee2); + employee2.setId(2L); + assertThat(employee1).isNotEqualTo(employee2); + employee1.setId(null); + assertThat(employee1).isNotEqualTo(employee2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResourceIntTest.java new file mode 100644 index 0000000..0e687c1 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/JobHistoryResourceIntTest.java @@ -0,0 +1,272 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.JobHistory; +import com.cooperl.si.integration.ui.repository.JobHistoryRepository; +import com.cooperl.si.integration.ui.service.JobHistoryService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.cooperl.si.integration.ui.domain.enumeration.Language; +/** + * Test class for the JobHistoryResource REST controller. + * + * @see JobHistoryResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class JobHistoryResourceIntTest { + + private static final Instant DEFAULT_START_DATE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_START_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Instant DEFAULT_END_DATE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_END_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final Language DEFAULT_LANGUAGE = Language.FRENCH; + private static final Language UPDATED_LANGUAGE = Language.ENGLISH; + + @Autowired + private JobHistoryRepository jobHistoryRepository; + + @Autowired + private JobHistoryService jobHistoryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restJobHistoryMockMvc; + + private JobHistory jobHistory; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final JobHistoryResource jobHistoryResource = new JobHistoryResource(jobHistoryService); + this.restJobHistoryMockMvc = MockMvcBuilders.standaloneSetup(jobHistoryResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static JobHistory createEntity(EntityManager em) { + JobHistory jobHistory = new JobHistory() + .startDate(DEFAULT_START_DATE) + .endDate(DEFAULT_END_DATE) + .language(DEFAULT_LANGUAGE); + return jobHistory; + } + + @Before + public void initTest() { + jobHistory = createEntity(em); + } + + @Test + @Transactional + public void createJobHistory() throws Exception { + int databaseSizeBeforeCreate = jobHistoryRepository.findAll().size(); + + // Create the JobHistory + restJobHistoryMockMvc.perform(post("/api/job-histories") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(jobHistory))) + .andExpect(status().isCreated()); + + // Validate the JobHistory in the database + List jobHistoryList = jobHistoryRepository.findAll(); + assertThat(jobHistoryList).hasSize(databaseSizeBeforeCreate + 1); + JobHistory testJobHistory = jobHistoryList.get(jobHistoryList.size() - 1); + assertThat(testJobHistory.getStartDate()).isEqualTo(DEFAULT_START_DATE); + assertThat(testJobHistory.getEndDate()).isEqualTo(DEFAULT_END_DATE); + assertThat(testJobHistory.getLanguage()).isEqualTo(DEFAULT_LANGUAGE); + } + + @Test + @Transactional + public void createJobHistoryWithExistingId() throws Exception { + int databaseSizeBeforeCreate = jobHistoryRepository.findAll().size(); + + // Create the JobHistory with an existing ID + jobHistory.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restJobHistoryMockMvc.perform(post("/api/job-histories") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(jobHistory))) + .andExpect(status().isBadRequest()); + + // Validate the JobHistory in the database + List jobHistoryList = jobHistoryRepository.findAll(); + assertThat(jobHistoryList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllJobHistories() throws Exception { + // Initialize the database + jobHistoryRepository.saveAndFlush(jobHistory); + + // Get all the jobHistoryList + restJobHistoryMockMvc.perform(get("/api/job-histories?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(jobHistory.getId().intValue()))) + .andExpect(jsonPath("$.[*].startDate").value(hasItem(DEFAULT_START_DATE.toString()))) + .andExpect(jsonPath("$.[*].endDate").value(hasItem(DEFAULT_END_DATE.toString()))) + .andExpect(jsonPath("$.[*].language").value(hasItem(DEFAULT_LANGUAGE.toString()))); + } + + @Test + @Transactional + public void getJobHistory() throws Exception { + // Initialize the database + jobHistoryRepository.saveAndFlush(jobHistory); + + // Get the jobHistory + restJobHistoryMockMvc.perform(get("/api/job-histories/{id}", jobHistory.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(jobHistory.getId().intValue())) + .andExpect(jsonPath("$.startDate").value(DEFAULT_START_DATE.toString())) + .andExpect(jsonPath("$.endDate").value(DEFAULT_END_DATE.toString())) + .andExpect(jsonPath("$.language").value(DEFAULT_LANGUAGE.toString())); + } + + @Test + @Transactional + public void getNonExistingJobHistory() throws Exception { + // Get the jobHistory + restJobHistoryMockMvc.perform(get("/api/job-histories/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateJobHistory() throws Exception { + // Initialize the database + jobHistoryService.save(jobHistory); + + int databaseSizeBeforeUpdate = jobHistoryRepository.findAll().size(); + + // Update the jobHistory + JobHistory updatedJobHistory = jobHistoryRepository.findById(jobHistory.getId()).get(); + // Disconnect from session so that the updates on updatedJobHistory are not directly saved in db + em.detach(updatedJobHistory); + updatedJobHistory + .startDate(UPDATED_START_DATE) + .endDate(UPDATED_END_DATE) + .language(UPDATED_LANGUAGE); + + restJobHistoryMockMvc.perform(put("/api/job-histories") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedJobHistory))) + .andExpect(status().isOk()); + + // Validate the JobHistory in the database + List jobHistoryList = jobHistoryRepository.findAll(); + assertThat(jobHistoryList).hasSize(databaseSizeBeforeUpdate); + JobHistory testJobHistory = jobHistoryList.get(jobHistoryList.size() - 1); + assertThat(testJobHistory.getStartDate()).isEqualTo(UPDATED_START_DATE); + assertThat(testJobHistory.getEndDate()).isEqualTo(UPDATED_END_DATE); + assertThat(testJobHistory.getLanguage()).isEqualTo(UPDATED_LANGUAGE); + } + + @Test + @Transactional + public void updateNonExistingJobHistory() throws Exception { + int databaseSizeBeforeUpdate = jobHistoryRepository.findAll().size(); + + // Create the JobHistory + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restJobHistoryMockMvc.perform(put("/api/job-histories") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(jobHistory))) + .andExpect(status().isBadRequest()); + + // Validate the JobHistory in the database + List jobHistoryList = jobHistoryRepository.findAll(); + assertThat(jobHistoryList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteJobHistory() throws Exception { + // Initialize the database + jobHistoryService.save(jobHistory); + + int databaseSizeBeforeDelete = jobHistoryRepository.findAll().size(); + + // Delete the jobHistory + restJobHistoryMockMvc.perform(delete("/api/job-histories/{id}", jobHistory.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List jobHistoryList = jobHistoryRepository.findAll(); + assertThat(jobHistoryList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(JobHistory.class); + JobHistory jobHistory1 = new JobHistory(); + jobHistory1.setId(1L); + JobHistory jobHistory2 = new JobHistory(); + jobHistory2.setId(jobHistory1.getId()); + assertThat(jobHistory1).isEqualTo(jobHistory2); + jobHistory2.setId(2L); + assertThat(jobHistory1).isNotEqualTo(jobHistory2); + jobHistory1.setId(null); + assertThat(jobHistory1).isNotEqualTo(jobHistory2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/JobResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/JobResourceIntTest.java new file mode 100644 index 0000000..8fd2c77 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/JobResourceIntTest.java @@ -0,0 +1,306 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Job; +import com.cooperl.si.integration.ui.repository.JobRepository; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.ArrayList; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the JobResource REST controller. + * + * @see JobResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class JobResourceIntTest { + + private static final String DEFAULT_JOB_TITLE = "AAAAAAAAAA"; + private static final String UPDATED_JOB_TITLE = "BBBBBBBBBB"; + + private static final Long DEFAULT_MIN_SALARY = 1L; + private static final Long UPDATED_MIN_SALARY = 2L; + + private static final Long DEFAULT_MAX_SALARY = 1L; + private static final Long UPDATED_MAX_SALARY = 2L; + + @Autowired + private JobRepository jobRepository; + + @Mock + private JobRepository jobRepositoryMock; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restJobMockMvc; + + private Job job; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final JobResource jobResource = new JobResource(jobRepository); + this.restJobMockMvc = MockMvcBuilders.standaloneSetup(jobResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Job createEntity(EntityManager em) { + Job job = new Job() + .jobTitle(DEFAULT_JOB_TITLE) + .minSalary(DEFAULT_MIN_SALARY) + .maxSalary(DEFAULT_MAX_SALARY); + return job; + } + + @Before + public void initTest() { + job = createEntity(em); + } + + @Test + @Transactional + public void createJob() throws Exception { + int databaseSizeBeforeCreate = jobRepository.findAll().size(); + + // Create the Job + restJobMockMvc.perform(post("/api/jobs") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(job))) + .andExpect(status().isCreated()); + + // Validate the Job in the database + List jobList = jobRepository.findAll(); + assertThat(jobList).hasSize(databaseSizeBeforeCreate + 1); + Job testJob = jobList.get(jobList.size() - 1); + assertThat(testJob.getJobTitle()).isEqualTo(DEFAULT_JOB_TITLE); + assertThat(testJob.getMinSalary()).isEqualTo(DEFAULT_MIN_SALARY); + assertThat(testJob.getMaxSalary()).isEqualTo(DEFAULT_MAX_SALARY); + } + + @Test + @Transactional + public void createJobWithExistingId() throws Exception { + int databaseSizeBeforeCreate = jobRepository.findAll().size(); + + // Create the Job with an existing ID + job.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restJobMockMvc.perform(post("/api/jobs") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(job))) + .andExpect(status().isBadRequest()); + + // Validate the Job in the database + List jobList = jobRepository.findAll(); + assertThat(jobList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllJobs() throws Exception { + // Initialize the database + jobRepository.saveAndFlush(job); + + // Get all the jobList + restJobMockMvc.perform(get("/api/jobs?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(job.getId().intValue()))) + .andExpect(jsonPath("$.[*].jobTitle").value(hasItem(DEFAULT_JOB_TITLE.toString()))) + .andExpect(jsonPath("$.[*].minSalary").value(hasItem(DEFAULT_MIN_SALARY.intValue()))) + .andExpect(jsonPath("$.[*].maxSalary").value(hasItem(DEFAULT_MAX_SALARY.intValue()))); + } + + @SuppressWarnings({"unchecked"}) + public void getAllJobsWithEagerRelationshipsIsEnabled() throws Exception { + JobResource jobResource = new JobResource(jobRepositoryMock); + when(jobRepositoryMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + MockMvc restJobMockMvc = MockMvcBuilders.standaloneSetup(jobResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter).build(); + + restJobMockMvc.perform(get("/api/jobs?eagerload=true")) + .andExpect(status().isOk()); + + verify(jobRepositoryMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({"unchecked"}) + public void getAllJobsWithEagerRelationshipsIsNotEnabled() throws Exception { + JobResource jobResource = new JobResource(jobRepositoryMock); + when(jobRepositoryMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + MockMvc restJobMockMvc = MockMvcBuilders.standaloneSetup(jobResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter).build(); + + restJobMockMvc.perform(get("/api/jobs?eagerload=true")) + .andExpect(status().isOk()); + + verify(jobRepositoryMock, times(1)).findAllWithEagerRelationships(any()); + } + + @Test + @Transactional + public void getJob() throws Exception { + // Initialize the database + jobRepository.saveAndFlush(job); + + // Get the job + restJobMockMvc.perform(get("/api/jobs/{id}", job.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(job.getId().intValue())) + .andExpect(jsonPath("$.jobTitle").value(DEFAULT_JOB_TITLE.toString())) + .andExpect(jsonPath("$.minSalary").value(DEFAULT_MIN_SALARY.intValue())) + .andExpect(jsonPath("$.maxSalary").value(DEFAULT_MAX_SALARY.intValue())); + } + + @Test + @Transactional + public void getNonExistingJob() throws Exception { + // Get the job + restJobMockMvc.perform(get("/api/jobs/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateJob() throws Exception { + // Initialize the database + jobRepository.saveAndFlush(job); + + int databaseSizeBeforeUpdate = jobRepository.findAll().size(); + + // Update the job + Job updatedJob = jobRepository.findById(job.getId()).get(); + // Disconnect from session so that the updates on updatedJob are not directly saved in db + em.detach(updatedJob); + updatedJob + .jobTitle(UPDATED_JOB_TITLE) + .minSalary(UPDATED_MIN_SALARY) + .maxSalary(UPDATED_MAX_SALARY); + + restJobMockMvc.perform(put("/api/jobs") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedJob))) + .andExpect(status().isOk()); + + // Validate the Job in the database + List jobList = jobRepository.findAll(); + assertThat(jobList).hasSize(databaseSizeBeforeUpdate); + Job testJob = jobList.get(jobList.size() - 1); + assertThat(testJob.getJobTitle()).isEqualTo(UPDATED_JOB_TITLE); + assertThat(testJob.getMinSalary()).isEqualTo(UPDATED_MIN_SALARY); + assertThat(testJob.getMaxSalary()).isEqualTo(UPDATED_MAX_SALARY); + } + + @Test + @Transactional + public void updateNonExistingJob() throws Exception { + int databaseSizeBeforeUpdate = jobRepository.findAll().size(); + + // Create the Job + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restJobMockMvc.perform(put("/api/jobs") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(job))) + .andExpect(status().isBadRequest()); + + // Validate the Job in the database + List jobList = jobRepository.findAll(); + assertThat(jobList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteJob() throws Exception { + // Initialize the database + jobRepository.saveAndFlush(job); + + int databaseSizeBeforeDelete = jobRepository.findAll().size(); + + // Delete the job + restJobMockMvc.perform(delete("/api/jobs/{id}", job.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List jobList = jobRepository.findAll(); + assertThat(jobList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Job.class); + Job job1 = new Job(); + job1.setId(1L); + Job job2 = new Job(); + job2.setId(job1.getId()); + assertThat(job1).isEqualTo(job2); + job2.setId(2L); + assertThat(job1).isNotEqualTo(job2); + job1.setId(null); + assertThat(job1).isNotEqualTo(job2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/LocationResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/LocationResourceIntTest.java new file mode 100644 index 0000000..558d280 --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/LocationResourceIntTest.java @@ -0,0 +1,278 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Location; +import com.cooperl.si.integration.ui.repository.LocationRepository; +import com.cooperl.si.integration.ui.service.LocationService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the LocationResource REST controller. + * + * @see LocationResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class LocationResourceIntTest { + + private static final String DEFAULT_STREET_ADDRESS = "AAAAAAAAAA"; + private static final String UPDATED_STREET_ADDRESS = "BBBBBBBBBB"; + + private static final String DEFAULT_POSTAL_CODE = "AAAAAAAAAA"; + private static final String UPDATED_POSTAL_CODE = "BBBBBBBBBB"; + + private static final String DEFAULT_CITY = "AAAAAAAAAA"; + private static final String UPDATED_CITY = "BBBBBBBBBB"; + + private static final String DEFAULT_STATE_PROVINCE = "AAAAAAAAAA"; + private static final String UPDATED_STATE_PROVINCE = "BBBBBBBBBB"; + + @Autowired + private LocationRepository locationRepository; + + @Autowired + private LocationService locationService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restLocationMockMvc; + + private Location location; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final LocationResource locationResource = new LocationResource(locationService); + this.restLocationMockMvc = MockMvcBuilders.standaloneSetup(locationResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Location createEntity(EntityManager em) { + Location location = new Location() + .streetAddress(DEFAULT_STREET_ADDRESS) + .postalCode(DEFAULT_POSTAL_CODE) + .city(DEFAULT_CITY) + .stateProvince(DEFAULT_STATE_PROVINCE); + return location; + } + + @Before + public void initTest() { + location = createEntity(em); + } + + @Test + @Transactional + public void createLocation() throws Exception { + int databaseSizeBeforeCreate = locationRepository.findAll().size(); + + // Create the Location + restLocationMockMvc.perform(post("/api/locations") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(location))) + .andExpect(status().isCreated()); + + // Validate the Location in the database + List locationList = locationRepository.findAll(); + assertThat(locationList).hasSize(databaseSizeBeforeCreate + 1); + Location testLocation = locationList.get(locationList.size() - 1); + assertThat(testLocation.getStreetAddress()).isEqualTo(DEFAULT_STREET_ADDRESS); + assertThat(testLocation.getPostalCode()).isEqualTo(DEFAULT_POSTAL_CODE); + assertThat(testLocation.getCity()).isEqualTo(DEFAULT_CITY); + assertThat(testLocation.getStateProvince()).isEqualTo(DEFAULT_STATE_PROVINCE); + } + + @Test + @Transactional + public void createLocationWithExistingId() throws Exception { + int databaseSizeBeforeCreate = locationRepository.findAll().size(); + + // Create the Location with an existing ID + location.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restLocationMockMvc.perform(post("/api/locations") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(location))) + .andExpect(status().isBadRequest()); + + // Validate the Location in the database + List locationList = locationRepository.findAll(); + assertThat(locationList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllLocations() throws Exception { + // Initialize the database + locationRepository.saveAndFlush(location); + + // Get all the locationList + restLocationMockMvc.perform(get("/api/locations?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(location.getId().intValue()))) + .andExpect(jsonPath("$.[*].streetAddress").value(hasItem(DEFAULT_STREET_ADDRESS.toString()))) + .andExpect(jsonPath("$.[*].postalCode").value(hasItem(DEFAULT_POSTAL_CODE.toString()))) + .andExpect(jsonPath("$.[*].city").value(hasItem(DEFAULT_CITY.toString()))) + .andExpect(jsonPath("$.[*].stateProvince").value(hasItem(DEFAULT_STATE_PROVINCE.toString()))); + } + + @Test + @Transactional + public void getLocation() throws Exception { + // Initialize the database + locationRepository.saveAndFlush(location); + + // Get the location + restLocationMockMvc.perform(get("/api/locations/{id}", location.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(location.getId().intValue())) + .andExpect(jsonPath("$.streetAddress").value(DEFAULT_STREET_ADDRESS.toString())) + .andExpect(jsonPath("$.postalCode").value(DEFAULT_POSTAL_CODE.toString())) + .andExpect(jsonPath("$.city").value(DEFAULT_CITY.toString())) + .andExpect(jsonPath("$.stateProvince").value(DEFAULT_STATE_PROVINCE.toString())); + } + + @Test + @Transactional + public void getNonExistingLocation() throws Exception { + // Get the location + restLocationMockMvc.perform(get("/api/locations/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateLocation() throws Exception { + // Initialize the database + locationService.save(location); + + int databaseSizeBeforeUpdate = locationRepository.findAll().size(); + + // Update the location + Location updatedLocation = locationRepository.findById(location.getId()).get(); + // Disconnect from session so that the updates on updatedLocation are not directly saved in db + em.detach(updatedLocation); + updatedLocation + .streetAddress(UPDATED_STREET_ADDRESS) + .postalCode(UPDATED_POSTAL_CODE) + .city(UPDATED_CITY) + .stateProvince(UPDATED_STATE_PROVINCE); + + restLocationMockMvc.perform(put("/api/locations") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedLocation))) + .andExpect(status().isOk()); + + // Validate the Location in the database + List locationList = locationRepository.findAll(); + assertThat(locationList).hasSize(databaseSizeBeforeUpdate); + Location testLocation = locationList.get(locationList.size() - 1); + assertThat(testLocation.getStreetAddress()).isEqualTo(UPDATED_STREET_ADDRESS); + assertThat(testLocation.getPostalCode()).isEqualTo(UPDATED_POSTAL_CODE); + assertThat(testLocation.getCity()).isEqualTo(UPDATED_CITY); + assertThat(testLocation.getStateProvince()).isEqualTo(UPDATED_STATE_PROVINCE); + } + + @Test + @Transactional + public void updateNonExistingLocation() throws Exception { + int databaseSizeBeforeUpdate = locationRepository.findAll().size(); + + // Create the Location + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restLocationMockMvc.perform(put("/api/locations") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(location))) + .andExpect(status().isBadRequest()); + + // Validate the Location in the database + List locationList = locationRepository.findAll(); + assertThat(locationList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteLocation() throws Exception { + // Initialize the database + locationService.save(location); + + int databaseSizeBeforeDelete = locationRepository.findAll().size(); + + // Delete the location + restLocationMockMvc.perform(delete("/api/locations/{id}", location.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List locationList = locationRepository.findAll(); + assertThat(locationList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Location.class); + Location location1 = new Location(); + location1.setId(1L); + Location location2 = new Location(); + location2.setId(location1.getId()); + assertThat(location1).isEqualTo(location2); + location2.setId(2L); + assertThat(location1).isNotEqualTo(location2); + location1.setId(null); + assertThat(location1).isNotEqualTo(location2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/RegionResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/RegionResourceIntTest.java new file mode 100644 index 0000000..e2f985a --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/RegionResourceIntTest.java @@ -0,0 +1,251 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Region; +import com.cooperl.si.integration.ui.repository.RegionRepository; +import com.cooperl.si.integration.ui.service.RegionService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the RegionResource REST controller. + * + * @see RegionResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class RegionResourceIntTest { + + private static final String DEFAULT_REGION_NAME = "AAAAAAAAAA"; + private static final String UPDATED_REGION_NAME = "BBBBBBBBBB"; + + @Autowired + private RegionRepository regionRepository; + + @Autowired + private RegionService regionService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restRegionMockMvc; + + private Region region; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final RegionResource regionResource = new RegionResource(regionService); + this.restRegionMockMvc = MockMvcBuilders.standaloneSetup(regionResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Region createEntity(EntityManager em) { + Region region = new Region() + .regionName(DEFAULT_REGION_NAME); + return region; + } + + @Before + public void initTest() { + region = createEntity(em); + } + + @Test + @Transactional + public void createRegion() throws Exception { + int databaseSizeBeforeCreate = regionRepository.findAll().size(); + + // Create the Region + restRegionMockMvc.perform(post("/api/regions") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(region))) + .andExpect(status().isCreated()); + + // Validate the Region in the database + List regionList = regionRepository.findAll(); + assertThat(regionList).hasSize(databaseSizeBeforeCreate + 1); + Region testRegion = regionList.get(regionList.size() - 1); + assertThat(testRegion.getRegionName()).isEqualTo(DEFAULT_REGION_NAME); + } + + @Test + @Transactional + public void createRegionWithExistingId() throws Exception { + int databaseSizeBeforeCreate = regionRepository.findAll().size(); + + // Create the Region with an existing ID + region.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restRegionMockMvc.perform(post("/api/regions") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(region))) + .andExpect(status().isBadRequest()); + + // Validate the Region in the database + List regionList = regionRepository.findAll(); + assertThat(regionList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllRegions() throws Exception { + // Initialize the database + regionRepository.saveAndFlush(region); + + // Get all the regionList + restRegionMockMvc.perform(get("/api/regions?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(region.getId().intValue()))) + .andExpect(jsonPath("$.[*].regionName").value(hasItem(DEFAULT_REGION_NAME.toString()))); + } + + @Test + @Transactional + public void getRegion() throws Exception { + // Initialize the database + regionRepository.saveAndFlush(region); + + // Get the region + restRegionMockMvc.perform(get("/api/regions/{id}", region.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(region.getId().intValue())) + .andExpect(jsonPath("$.regionName").value(DEFAULT_REGION_NAME.toString())); + } + + @Test + @Transactional + public void getNonExistingRegion() throws Exception { + // Get the region + restRegionMockMvc.perform(get("/api/regions/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateRegion() throws Exception { + // Initialize the database + regionService.save(region); + + int databaseSizeBeforeUpdate = regionRepository.findAll().size(); + + // Update the region + Region updatedRegion = regionRepository.findById(region.getId()).get(); + // Disconnect from session so that the updates on updatedRegion are not directly saved in db + em.detach(updatedRegion); + updatedRegion + .regionName(UPDATED_REGION_NAME); + + restRegionMockMvc.perform(put("/api/regions") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedRegion))) + .andExpect(status().isOk()); + + // Validate the Region in the database + List regionList = regionRepository.findAll(); + assertThat(regionList).hasSize(databaseSizeBeforeUpdate); + Region testRegion = regionList.get(regionList.size() - 1); + assertThat(testRegion.getRegionName()).isEqualTo(UPDATED_REGION_NAME); + } + + @Test + @Transactional + public void updateNonExistingRegion() throws Exception { + int databaseSizeBeforeUpdate = regionRepository.findAll().size(); + + // Create the Region + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restRegionMockMvc.perform(put("/api/regions") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(region))) + .andExpect(status().isBadRequest()); + + // Validate the Region in the database + List regionList = regionRepository.findAll(); + assertThat(regionList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteRegion() throws Exception { + // Initialize the database + regionService.save(region); + + int databaseSizeBeforeDelete = regionRepository.findAll().size(); + + // Delete the region + restRegionMockMvc.perform(delete("/api/regions/{id}", region.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List regionList = regionRepository.findAll(); + assertThat(regionList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Region.class); + Region region1 = new Region(); + region1.setId(1L); + Region region2 = new Region(); + region2.setId(region1.getId()); + assertThat(region1).isEqualTo(region2); + region2.setId(2L); + assertThat(region1).isNotEqualTo(region2); + region1.setId(null); + assertThat(region1).isNotEqualTo(region2); + } +} diff --git a/src/test/java/com/cooperl/si/integration/ui/web/rest/TaskResourceIntTest.java b/src/test/java/com/cooperl/si/integration/ui/web/rest/TaskResourceIntTest.java new file mode 100644 index 0000000..5361a3b --- /dev/null +++ b/src/test/java/com/cooperl/si/integration/ui/web/rest/TaskResourceIntTest.java @@ -0,0 +1,260 @@ +package com.cooperl.si.integration.ui.web.rest; + +import com.cooperl.si.integration.ui.IntegrationUiApp; + +import com.cooperl.si.integration.ui.domain.Task; +import com.cooperl.si.integration.ui.repository.TaskRepository; +import com.cooperl.si.integration.ui.service.TaskService; +import com.cooperl.si.integration.ui.web.rest.errors.ExceptionTranslator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.util.List; + + +import static com.cooperl.si.integration.ui.web.rest.TestUtil.createFormattingConversionService; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the TaskResource REST controller. + * + * @see TaskResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationUiApp.class) +public class TaskResourceIntTest { + + private static final String DEFAULT_TITLE = "AAAAAAAAAA"; + private static final String UPDATED_TITLE = "BBBBBBBBBB"; + + private static final String DEFAULT_DESCRIPTION = "AAAAAAAAAA"; + private static final String UPDATED_DESCRIPTION = "BBBBBBBBBB"; + + @Autowired + private TaskRepository taskRepository; + + @Autowired + private TaskService taskService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restTaskMockMvc; + + private Task task; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final TaskResource taskResource = new TaskResource(taskService); + this.restTaskMockMvc = MockMvcBuilders.standaloneSetup(taskResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Task createEntity(EntityManager em) { + Task task = new Task() + .title(DEFAULT_TITLE) + .description(DEFAULT_DESCRIPTION); + return task; + } + + @Before + public void initTest() { + task = createEntity(em); + } + + @Test + @Transactional + public void createTask() throws Exception { + int databaseSizeBeforeCreate = taskRepository.findAll().size(); + + // Create the Task + restTaskMockMvc.perform(post("/api/tasks") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(task))) + .andExpect(status().isCreated()); + + // Validate the Task in the database + List taskList = taskRepository.findAll(); + assertThat(taskList).hasSize(databaseSizeBeforeCreate + 1); + Task testTask = taskList.get(taskList.size() - 1); + assertThat(testTask.getTitle()).isEqualTo(DEFAULT_TITLE); + assertThat(testTask.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); + } + + @Test + @Transactional + public void createTaskWithExistingId() throws Exception { + int databaseSizeBeforeCreate = taskRepository.findAll().size(); + + // Create the Task with an existing ID + task.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restTaskMockMvc.perform(post("/api/tasks") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(task))) + .andExpect(status().isBadRequest()); + + // Validate the Task in the database + List taskList = taskRepository.findAll(); + assertThat(taskList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void getAllTasks() throws Exception { + // Initialize the database + taskRepository.saveAndFlush(task); + + // Get all the taskList + restTaskMockMvc.perform(get("/api/tasks?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(task.getId().intValue()))) + .andExpect(jsonPath("$.[*].title").value(hasItem(DEFAULT_TITLE.toString()))) + .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))); + } + + @Test + @Transactional + public void getTask() throws Exception { + // Initialize the database + taskRepository.saveAndFlush(task); + + // Get the task + restTaskMockMvc.perform(get("/api/tasks/{id}", task.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(task.getId().intValue())) + .andExpect(jsonPath("$.title").value(DEFAULT_TITLE.toString())) + .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())); + } + + @Test + @Transactional + public void getNonExistingTask() throws Exception { + // Get the task + restTaskMockMvc.perform(get("/api/tasks/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateTask() throws Exception { + // Initialize the database + taskService.save(task); + + int databaseSizeBeforeUpdate = taskRepository.findAll().size(); + + // Update the task + Task updatedTask = taskRepository.findById(task.getId()).get(); + // Disconnect from session so that the updates on updatedTask are not directly saved in db + em.detach(updatedTask); + updatedTask + .title(UPDATED_TITLE) + .description(UPDATED_DESCRIPTION); + + restTaskMockMvc.perform(put("/api/tasks") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(updatedTask))) + .andExpect(status().isOk()); + + // Validate the Task in the database + List taskList = taskRepository.findAll(); + assertThat(taskList).hasSize(databaseSizeBeforeUpdate); + Task testTask = taskList.get(taskList.size() - 1); + assertThat(testTask.getTitle()).isEqualTo(UPDATED_TITLE); + assertThat(testTask.getDescription()).isEqualTo(UPDATED_DESCRIPTION); + } + + @Test + @Transactional + public void updateNonExistingTask() throws Exception { + int databaseSizeBeforeUpdate = taskRepository.findAll().size(); + + // Create the Task + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restTaskMockMvc.perform(put("/api/tasks") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(task))) + .andExpect(status().isBadRequest()); + + // Validate the Task in the database + List taskList = taskRepository.findAll(); + assertThat(taskList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteTask() throws Exception { + // Initialize the database + taskService.save(task); + + int databaseSizeBeforeDelete = taskRepository.findAll().size(); + + // Delete the task + restTaskMockMvc.perform(delete("/api/tasks/{id}", task.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List taskList = taskRepository.findAll(); + assertThat(taskList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Task.class); + Task task1 = new Task(); + task1.setId(1L); + Task task2 = new Task(); + task2.setId(task1.getId()); + assertThat(task1).isEqualTo(task2); + task2.setId(2L); + assertThat(task1).isNotEqualTo(task2); + task1.setId(null); + assertThat(task1).isNotEqualTo(task2); + } +} diff --git a/src/test/javascript/spec/app/entities/country/country-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/country/country-delete-dialog.component.spec.ts new file mode 100644 index 0000000..225da04 --- /dev/null +++ b/src/test/javascript/spec/app/entities/country/country-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { CountryDeleteDialogComponent } from 'app/entities/country/country-delete-dialog.component'; +import { CountryService } from 'app/entities/country/country.service'; + +describe('Component Tests', () => { + describe('Country Management Delete Component', () => { + let comp: CountryDeleteDialogComponent; + let fixture: ComponentFixture; + let service: CountryService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [CountryDeleteDialogComponent] + }) + .overrideTemplate(CountryDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CountryDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CountryService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/country/country-detail.component.spec.ts b/src/test/javascript/spec/app/entities/country/country-detail.component.spec.ts new file mode 100644 index 0000000..b5d86db --- /dev/null +++ b/src/test/javascript/spec/app/entities/country/country-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { CountryDetailComponent } from 'app/entities/country/country-detail.component'; +import { Country } from 'app/shared/model/country.model'; + +describe('Component Tests', () => { + describe('Country Management Detail Component', () => { + let comp: CountryDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ country: new Country(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [CountryDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(CountryDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CountryDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.country).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/country/country-update.component.spec.ts b/src/test/javascript/spec/app/entities/country/country-update.component.spec.ts new file mode 100644 index 0000000..bfa77fe --- /dev/null +++ b/src/test/javascript/spec/app/entities/country/country-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { CountryUpdateComponent } from 'app/entities/country/country-update.component'; +import { CountryService } from 'app/entities/country/country.service'; +import { Country } from 'app/shared/model/country.model'; + +describe('Component Tests', () => { + describe('Country Management Update Component', () => { + let comp: CountryUpdateComponent; + let fixture: ComponentFixture; + let service: CountryService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [CountryUpdateComponent] + }) + .overrideTemplate(CountryUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(CountryUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CountryService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Country(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.country = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Country(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.country = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/country/country.component.spec.ts b/src/test/javascript/spec/app/entities/country/country.component.spec.ts new file mode 100644 index 0000000..ba888f7 --- /dev/null +++ b/src/test/javascript/spec/app/entities/country/country.component.spec.ts @@ -0,0 +1,51 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { CountryComponent } from 'app/entities/country/country.component'; +import { CountryService } from 'app/entities/country/country.service'; +import { Country } from 'app/shared/model/country.model'; + +describe('Component Tests', () => { + describe('Country Management Component', () => { + let comp: CountryComponent; + let fixture: ComponentFixture; + let service: CountryService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [CountryComponent], + providers: [] + }) + .overrideTemplate(CountryComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(CountryComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CountryService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Country(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.countries[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/country/country.service.spec.ts b/src/test/javascript/spec/app/entities/country/country.service.spec.ts new file mode 100644 index 0000000..cb9724c --- /dev/null +++ b/src/test/javascript/spec/app/entities/country/country.service.spec.ts @@ -0,0 +1,104 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { CountryService } from 'app/entities/country/country.service'; +import { ICountry, Country } from 'app/shared/model/country.model'; + +describe('Service Tests', () => { + describe('Country Service', () => { + let injector: TestBed; + let service: CountryService; + let httpMock: HttpTestingController; + let elemDefault: ICountry; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(CountryService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Country(0, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Country', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Country(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Country', async () => { + const returnedFromService = Object.assign( + { + countryName: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Country', async () => { + const returnedFromService = Object.assign( + { + countryName: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Country', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts new file mode 100644 index 0000000..7c1af26 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { DepartmentDeleteDialogComponent } from 'app/entities/department/department-delete-dialog.component'; +import { DepartmentService } from 'app/entities/department/department.service'; + +describe('Component Tests', () => { + describe('Department Management Delete Component', () => { + let comp: DepartmentDeleteDialogComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [DepartmentDeleteDialogComponent] + }) + .overrideTemplate(DepartmentDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DepartmentDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts new file mode 100644 index 0000000..1e520b3 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { DepartmentDetailComponent } from 'app/entities/department/department-detail.component'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Detail Component', () => { + let comp: DepartmentDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ department: new Department(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [DepartmentDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(DepartmentDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DepartmentDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.department).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts new file mode 100644 index 0000000..dd988c9 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { DepartmentUpdateComponent } from 'app/entities/department/department-update.component'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Update Component', () => { + let comp: DepartmentUpdateComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [DepartmentUpdateComponent] + }) + .overrideTemplate(DepartmentUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DepartmentUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Department(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.department = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Department(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.department = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department.component.spec.ts b/src/test/javascript/spec/app/entities/department/department.component.spec.ts new file mode 100644 index 0000000..6d88ac1 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department.component.spec.ts @@ -0,0 +1,51 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { DepartmentComponent } from 'app/entities/department/department.component'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Component', () => { + let comp: DepartmentComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [DepartmentComponent], + providers: [] + }) + .overrideTemplate(DepartmentComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DepartmentComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Department(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.departments[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department.service.spec.ts b/src/test/javascript/spec/app/entities/department/department.service.spec.ts new file mode 100644 index 0000000..cf0529c --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department.service.spec.ts @@ -0,0 +1,104 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { IDepartment, Department } from 'app/shared/model/department.model'; + +describe('Service Tests', () => { + describe('Department Service', () => { + let injector: TestBed; + let service: DepartmentService; + let httpMock: HttpTestingController; + let elemDefault: IDepartment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(DepartmentService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Department(0, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Department', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Department(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Department', async () => { + const returnedFromService = Object.assign( + { + departmentName: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Department', async () => { + const returnedFromService = Object.assign( + { + departmentName: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Department', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/employee/employee-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/employee/employee-delete-dialog.component.spec.ts new file mode 100644 index 0000000..5b16a41 --- /dev/null +++ b/src/test/javascript/spec/app/entities/employee/employee-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { EmployeeDeleteDialogComponent } from 'app/entities/employee/employee-delete-dialog.component'; +import { EmployeeService } from 'app/entities/employee/employee.service'; + +describe('Component Tests', () => { + describe('Employee Management Delete Component', () => { + let comp: EmployeeDeleteDialogComponent; + let fixture: ComponentFixture; + let service: EmployeeService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [EmployeeDeleteDialogComponent] + }) + .overrideTemplate(EmployeeDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(EmployeeDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(EmployeeService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/employee/employee-detail.component.spec.ts b/src/test/javascript/spec/app/entities/employee/employee-detail.component.spec.ts new file mode 100644 index 0000000..a5ca219 --- /dev/null +++ b/src/test/javascript/spec/app/entities/employee/employee-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { EmployeeDetailComponent } from 'app/entities/employee/employee-detail.component'; +import { Employee } from 'app/shared/model/employee.model'; + +describe('Component Tests', () => { + describe('Employee Management Detail Component', () => { + let comp: EmployeeDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ employee: new Employee(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [EmployeeDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(EmployeeDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(EmployeeDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.employee).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/employee/employee-update.component.spec.ts b/src/test/javascript/spec/app/entities/employee/employee-update.component.spec.ts new file mode 100644 index 0000000..95e2163 --- /dev/null +++ b/src/test/javascript/spec/app/entities/employee/employee-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { EmployeeUpdateComponent } from 'app/entities/employee/employee-update.component'; +import { EmployeeService } from 'app/entities/employee/employee.service'; +import { Employee } from 'app/shared/model/employee.model'; + +describe('Component Tests', () => { + describe('Employee Management Update Component', () => { + let comp: EmployeeUpdateComponent; + let fixture: ComponentFixture; + let service: EmployeeService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [EmployeeUpdateComponent] + }) + .overrideTemplate(EmployeeUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(EmployeeUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(EmployeeService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Employee(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.employee = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Employee(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.employee = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/employee/employee.component.spec.ts b/src/test/javascript/spec/app/entities/employee/employee.component.spec.ts new file mode 100644 index 0000000..5230322 --- /dev/null +++ b/src/test/javascript/spec/app/entities/employee/employee.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { EmployeeComponent } from 'app/entities/employee/employee.component'; +import { EmployeeService } from 'app/entities/employee/employee.service'; +import { Employee } from 'app/shared/model/employee.model'; + +describe('Component Tests', () => { + describe('Employee Management Component', () => { + let comp: EmployeeComponent; + let fixture: ComponentFixture; + let service: EmployeeService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [EmployeeComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(EmployeeComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(EmployeeComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(EmployeeService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Employee(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.employees[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Employee(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.employees[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Employee(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.employees[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/employee/employee.service.spec.ts b/src/test/javascript/spec/app/entities/employee/employee.service.spec.ts new file mode 100644 index 0000000..9b9c384 --- /dev/null +++ b/src/test/javascript/spec/app/entities/employee/employee.service.spec.ts @@ -0,0 +1,141 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; +import { EmployeeService } from 'app/entities/employee/employee.service'; +import { IEmployee, Employee } from 'app/shared/model/employee.model'; + +describe('Service Tests', () => { + describe('Employee Service', () => { + let injector: TestBed; + let service: EmployeeService; + let httpMock: HttpTestingController; + let elemDefault: IEmployee; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(EmployeeService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Employee(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', currentDate, 0, 0); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + hireDate: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Employee', async () => { + const returnedFromService = Object.assign( + { + id: 0, + hireDate: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + hireDate: currentDate + }, + returnedFromService + ); + service + .create(new Employee(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Employee', async () => { + const returnedFromService = Object.assign( + { + firstName: 'BBBBBB', + lastName: 'BBBBBB', + email: 'BBBBBB', + phoneNumber: 'BBBBBB', + hireDate: currentDate.format(DATE_TIME_FORMAT), + salary: 1, + commissionPct: 1 + }, + elemDefault + ); + + const expected = Object.assign( + { + hireDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Employee', async () => { + const returnedFromService = Object.assign( + { + firstName: 'BBBBBB', + lastName: 'BBBBBB', + email: 'BBBBBB', + phoneNumber: 'BBBBBB', + hireDate: currentDate.format(DATE_TIME_FORMAT), + salary: 1, + commissionPct: 1 + }, + elemDefault + ); + const expected = Object.assign( + { + hireDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Employee', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job-history/job-history-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/job-history/job-history-delete-dialog.component.spec.ts new file mode 100644 index 0000000..2e96e7c --- /dev/null +++ b/src/test/javascript/spec/app/entities/job-history/job-history-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobHistoryDeleteDialogComponent } from 'app/entities/job-history/job-history-delete-dialog.component'; +import { JobHistoryService } from 'app/entities/job-history/job-history.service'; + +describe('Component Tests', () => { + describe('JobHistory Management Delete Component', () => { + let comp: JobHistoryDeleteDialogComponent; + let fixture: ComponentFixture; + let service: JobHistoryService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobHistoryDeleteDialogComponent] + }) + .overrideTemplate(JobHistoryDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(JobHistoryDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobHistoryService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job-history/job-history-detail.component.spec.ts b/src/test/javascript/spec/app/entities/job-history/job-history-detail.component.spec.ts new file mode 100644 index 0000000..163d693 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job-history/job-history-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobHistoryDetailComponent } from 'app/entities/job-history/job-history-detail.component'; +import { JobHistory } from 'app/shared/model/job-history.model'; + +describe('Component Tests', () => { + describe('JobHistory Management Detail Component', () => { + let comp: JobHistoryDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ jobHistory: new JobHistory(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobHistoryDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(JobHistoryDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(JobHistoryDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.jobHistory).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job-history/job-history-update.component.spec.ts b/src/test/javascript/spec/app/entities/job-history/job-history-update.component.spec.ts new file mode 100644 index 0000000..76bad56 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job-history/job-history-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobHistoryUpdateComponent } from 'app/entities/job-history/job-history-update.component'; +import { JobHistoryService } from 'app/entities/job-history/job-history.service'; +import { JobHistory } from 'app/shared/model/job-history.model'; + +describe('Component Tests', () => { + describe('JobHistory Management Update Component', () => { + let comp: JobHistoryUpdateComponent; + let fixture: ComponentFixture; + let service: JobHistoryService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobHistoryUpdateComponent] + }) + .overrideTemplate(JobHistoryUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(JobHistoryUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobHistoryService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new JobHistory(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.jobHistory = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new JobHistory(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.jobHistory = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job-history/job-history.component.spec.ts b/src/test/javascript/spec/app/entities/job-history/job-history.component.spec.ts new file mode 100644 index 0000000..37345af --- /dev/null +++ b/src/test/javascript/spec/app/entities/job-history/job-history.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobHistoryComponent } from 'app/entities/job-history/job-history.component'; +import { JobHistoryService } from 'app/entities/job-history/job-history.service'; +import { JobHistory } from 'app/shared/model/job-history.model'; + +describe('Component Tests', () => { + describe('JobHistory Management Component', () => { + let comp: JobHistoryComponent; + let fixture: ComponentFixture; + let service: JobHistoryService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobHistoryComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(JobHistoryComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(JobHistoryComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobHistoryService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new JobHistory(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.jobHistories[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new JobHistory(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.jobHistories[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new JobHistory(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.jobHistories[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job-history/job-history.service.spec.ts b/src/test/javascript/spec/app/entities/job-history/job-history.service.spec.ts new file mode 100644 index 0000000..218e3b7 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job-history/job-history.service.spec.ts @@ -0,0 +1,138 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; +import { JobHistoryService } from 'app/entities/job-history/job-history.service'; +import { IJobHistory, JobHistory, Language } from 'app/shared/model/job-history.model'; + +describe('Service Tests', () => { + describe('JobHistory Service', () => { + let injector: TestBed; + let service: JobHistoryService; + let httpMock: HttpTestingController; + let elemDefault: IJobHistory; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(JobHistoryService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new JobHistory(0, currentDate, currentDate, Language.FRENCH); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a JobHistory', async () => { + const returnedFromService = Object.assign( + { + id: 0, + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate + }, + returnedFromService + ); + service + .create(new JobHistory(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a JobHistory', async () => { + const returnedFromService = Object.assign( + { + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + language: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of JobHistory', async () => { + const returnedFromService = Object.assign( + { + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + language: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a JobHistory', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job/job-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/job/job-delete-dialog.component.spec.ts new file mode 100644 index 0000000..78a8849 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job/job-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobDeleteDialogComponent } from 'app/entities/job/job-delete-dialog.component'; +import { JobService } from 'app/entities/job/job.service'; + +describe('Component Tests', () => { + describe('Job Management Delete Component', () => { + let comp: JobDeleteDialogComponent; + let fixture: ComponentFixture; + let service: JobService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobDeleteDialogComponent] + }) + .overrideTemplate(JobDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(JobDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job/job-detail.component.spec.ts b/src/test/javascript/spec/app/entities/job/job-detail.component.spec.ts new file mode 100644 index 0000000..0985c83 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job/job-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobDetailComponent } from 'app/entities/job/job-detail.component'; +import { Job } from 'app/shared/model/job.model'; + +describe('Component Tests', () => { + describe('Job Management Detail Component', () => { + let comp: JobDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ job: new Job(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(JobDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(JobDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.job).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job/job-update.component.spec.ts b/src/test/javascript/spec/app/entities/job/job-update.component.spec.ts new file mode 100644 index 0000000..79356bd --- /dev/null +++ b/src/test/javascript/spec/app/entities/job/job-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobUpdateComponent } from 'app/entities/job/job-update.component'; +import { JobService } from 'app/entities/job/job.service'; +import { Job } from 'app/shared/model/job.model'; + +describe('Component Tests', () => { + describe('Job Management Update Component', () => { + let comp: JobUpdateComponent; + let fixture: ComponentFixture; + let service: JobService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobUpdateComponent] + }) + .overrideTemplate(JobUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(JobUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Job(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.job = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Job(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.job = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job/job.component.spec.ts b/src/test/javascript/spec/app/entities/job/job.component.spec.ts new file mode 100644 index 0000000..73f23a1 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job/job.component.spec.ts @@ -0,0 +1,138 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { JobComponent } from 'app/entities/job/job.component'; +import { JobService } from 'app/entities/job/job.service'; +import { Job } from 'app/shared/model/job.model'; + +describe('Component Tests', () => { + describe('Job Management Component', () => { + let comp: JobComponent; + let fixture: ComponentFixture; + let service: JobService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [JobComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(JobComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(JobComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JobService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Job(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.jobs[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Job(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.jobs[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should not load a page is the page is the same as the previous page', () => { + spyOn(service, 'query').and.callThrough(); + + // WHEN + comp.loadPage(0); + + // THEN + expect(service.query).toHaveBeenCalledTimes(0); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Job(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.clear(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.jobs[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/job/job.service.spec.ts b/src/test/javascript/spec/app/entities/job/job.service.spec.ts new file mode 100644 index 0000000..81db291 --- /dev/null +++ b/src/test/javascript/spec/app/entities/job/job.service.spec.ts @@ -0,0 +1,108 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { JobService } from 'app/entities/job/job.service'; +import { IJob, Job } from 'app/shared/model/job.model'; + +describe('Service Tests', () => { + describe('Job Service', () => { + let injector: TestBed; + let service: JobService; + let httpMock: HttpTestingController; + let elemDefault: IJob; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(JobService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Job(0, 'AAAAAAA', 0, 0); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Job', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Job(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Job', async () => { + const returnedFromService = Object.assign( + { + jobTitle: 'BBBBBB', + minSalary: 1, + maxSalary: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Job', async () => { + const returnedFromService = Object.assign( + { + jobTitle: 'BBBBBB', + minSalary: 1, + maxSalary: 1 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Job', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/location/location-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/location/location-delete-dialog.component.spec.ts new file mode 100644 index 0000000..7cdaa45 --- /dev/null +++ b/src/test/javascript/spec/app/entities/location/location-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { LocationDeleteDialogComponent } from 'app/entities/location/location-delete-dialog.component'; +import { LocationService } from 'app/entities/location/location.service'; + +describe('Component Tests', () => { + describe('Location Management Delete Component', () => { + let comp: LocationDeleteDialogComponent; + let fixture: ComponentFixture; + let service: LocationService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [LocationDeleteDialogComponent] + }) + .overrideTemplate(LocationDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(LocationDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(LocationService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/location/location-detail.component.spec.ts b/src/test/javascript/spec/app/entities/location/location-detail.component.spec.ts new file mode 100644 index 0000000..0537c4e --- /dev/null +++ b/src/test/javascript/spec/app/entities/location/location-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { LocationDetailComponent } from 'app/entities/location/location-detail.component'; +import { Location } from 'app/shared/model/location.model'; + +describe('Component Tests', () => { + describe('Location Management Detail Component', () => { + let comp: LocationDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ location: new Location(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [LocationDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(LocationDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(LocationDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.location).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/location/location-update.component.spec.ts b/src/test/javascript/spec/app/entities/location/location-update.component.spec.ts new file mode 100644 index 0000000..edf7308 --- /dev/null +++ b/src/test/javascript/spec/app/entities/location/location-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { LocationUpdateComponent } from 'app/entities/location/location-update.component'; +import { LocationService } from 'app/entities/location/location.service'; +import { Location } from 'app/shared/model/location.model'; + +describe('Component Tests', () => { + describe('Location Management Update Component', () => { + let comp: LocationUpdateComponent; + let fixture: ComponentFixture; + let service: LocationService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [LocationUpdateComponent] + }) + .overrideTemplate(LocationUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(LocationUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(LocationService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Location(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.location = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Location(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.location = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/location/location.component.spec.ts b/src/test/javascript/spec/app/entities/location/location.component.spec.ts new file mode 100644 index 0000000..5162d92 --- /dev/null +++ b/src/test/javascript/spec/app/entities/location/location.component.spec.ts @@ -0,0 +1,51 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { LocationComponent } from 'app/entities/location/location.component'; +import { LocationService } from 'app/entities/location/location.service'; +import { Location } from 'app/shared/model/location.model'; + +describe('Component Tests', () => { + describe('Location Management Component', () => { + let comp: LocationComponent; + let fixture: ComponentFixture; + let service: LocationService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [LocationComponent], + providers: [] + }) + .overrideTemplate(LocationComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(LocationComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(LocationService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Location(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.locations[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/location/location.service.spec.ts b/src/test/javascript/spec/app/entities/location/location.service.spec.ts new file mode 100644 index 0000000..b068a8d --- /dev/null +++ b/src/test/javascript/spec/app/entities/location/location.service.spec.ts @@ -0,0 +1,110 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { LocationService } from 'app/entities/location/location.service'; +import { ILocation, Location } from 'app/shared/model/location.model'; + +describe('Service Tests', () => { + describe('Location Service', () => { + let injector: TestBed; + let service: LocationService; + let httpMock: HttpTestingController; + let elemDefault: ILocation; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(LocationService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Location(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Location', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Location(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Location', async () => { + const returnedFromService = Object.assign( + { + streetAddress: 'BBBBBB', + postalCode: 'BBBBBB', + city: 'BBBBBB', + stateProvince: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Location', async () => { + const returnedFromService = Object.assign( + { + streetAddress: 'BBBBBB', + postalCode: 'BBBBBB', + city: 'BBBBBB', + stateProvince: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Location', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/region/region-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/region/region-delete-dialog.component.spec.ts new file mode 100644 index 0000000..77d2f51 --- /dev/null +++ b/src/test/javascript/spec/app/entities/region/region-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { RegionDeleteDialogComponent } from 'app/entities/region/region-delete-dialog.component'; +import { RegionService } from 'app/entities/region/region.service'; + +describe('Component Tests', () => { + describe('Region Management Delete Component', () => { + let comp: RegionDeleteDialogComponent; + let fixture: ComponentFixture; + let service: RegionService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [RegionDeleteDialogComponent] + }) + .overrideTemplate(RegionDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(RegionDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(RegionService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/region/region-detail.component.spec.ts b/src/test/javascript/spec/app/entities/region/region-detail.component.spec.ts new file mode 100644 index 0000000..5df348d --- /dev/null +++ b/src/test/javascript/spec/app/entities/region/region-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { RegionDetailComponent } from 'app/entities/region/region-detail.component'; +import { Region } from 'app/shared/model/region.model'; + +describe('Component Tests', () => { + describe('Region Management Detail Component', () => { + let comp: RegionDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ region: new Region(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [RegionDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(RegionDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(RegionDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.region).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/region/region-update.component.spec.ts b/src/test/javascript/spec/app/entities/region/region-update.component.spec.ts new file mode 100644 index 0000000..4398a49 --- /dev/null +++ b/src/test/javascript/spec/app/entities/region/region-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { RegionUpdateComponent } from 'app/entities/region/region-update.component'; +import { RegionService } from 'app/entities/region/region.service'; +import { Region } from 'app/shared/model/region.model'; + +describe('Component Tests', () => { + describe('Region Management Update Component', () => { + let comp: RegionUpdateComponent; + let fixture: ComponentFixture; + let service: RegionService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [RegionUpdateComponent] + }) + .overrideTemplate(RegionUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(RegionUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(RegionService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Region(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.region = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Region(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.region = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/region/region.component.spec.ts b/src/test/javascript/spec/app/entities/region/region.component.spec.ts new file mode 100644 index 0000000..229aa3f --- /dev/null +++ b/src/test/javascript/spec/app/entities/region/region.component.spec.ts @@ -0,0 +1,51 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { RegionComponent } from 'app/entities/region/region.component'; +import { RegionService } from 'app/entities/region/region.service'; +import { Region } from 'app/shared/model/region.model'; + +describe('Component Tests', () => { + describe('Region Management Component', () => { + let comp: RegionComponent; + let fixture: ComponentFixture; + let service: RegionService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [RegionComponent], + providers: [] + }) + .overrideTemplate(RegionComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(RegionComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(RegionService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Region(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.regions[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/region/region.service.spec.ts b/src/test/javascript/spec/app/entities/region/region.service.spec.ts new file mode 100644 index 0000000..42a00ef --- /dev/null +++ b/src/test/javascript/spec/app/entities/region/region.service.spec.ts @@ -0,0 +1,104 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { RegionService } from 'app/entities/region/region.service'; +import { IRegion, Region } from 'app/shared/model/region.model'; + +describe('Service Tests', () => { + describe('Region Service', () => { + let injector: TestBed; + let service: RegionService; + let httpMock: HttpTestingController; + let elemDefault: IRegion; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(RegionService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Region(0, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Region', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Region(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Region', async () => { + const returnedFromService = Object.assign( + { + regionName: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Region', async () => { + const returnedFromService = Object.assign( + { + regionName: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Region', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/task/task-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/task/task-delete-dialog.component.spec.ts new file mode 100644 index 0000000..6ee151d --- /dev/null +++ b/src/test/javascript/spec/app/entities/task/task-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { TaskDeleteDialogComponent } from 'app/entities/task/task-delete-dialog.component'; +import { TaskService } from 'app/entities/task/task.service'; + +describe('Component Tests', () => { + describe('Task Management Delete Component', () => { + let comp: TaskDeleteDialogComponent; + let fixture: ComponentFixture; + let service: TaskService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [TaskDeleteDialogComponent] + }) + .overrideTemplate(TaskDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(TaskDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TaskService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/task/task-detail.component.spec.ts b/src/test/javascript/spec/app/entities/task/task-detail.component.spec.ts new file mode 100644 index 0000000..a439fe4 --- /dev/null +++ b/src/test/javascript/spec/app/entities/task/task-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { TaskDetailComponent } from 'app/entities/task/task-detail.component'; +import { Task } from 'app/shared/model/task.model'; + +describe('Component Tests', () => { + describe('Task Management Detail Component', () => { + let comp: TaskDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ task: new Task(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [TaskDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(TaskDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(TaskDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.task).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/task/task-update.component.spec.ts b/src/test/javascript/spec/app/entities/task/task-update.component.spec.ts new file mode 100644 index 0000000..ea6f64e --- /dev/null +++ b/src/test/javascript/spec/app/entities/task/task-update.component.spec.ts @@ -0,0 +1,66 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { TaskUpdateComponent } from 'app/entities/task/task-update.component'; +import { TaskService } from 'app/entities/task/task.service'; +import { Task } from 'app/shared/model/task.model'; + +describe('Component Tests', () => { + describe('Task Management Update Component', () => { + let comp: TaskUpdateComponent; + let fixture: ComponentFixture; + let service: TaskService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [TaskUpdateComponent] + }) + .overrideTemplate(TaskUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(TaskUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TaskService); + }); + + describe('save', () => { + it( + 'Should call update service on save for existing entity', + fakeAsync(() => { + // GIVEN + const entity = new Task(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.task = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + + it( + 'Should call create service on save for new entity', + fakeAsync(() => { + // GIVEN + const entity = new Task(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.task = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }) + ); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/task/task.component.spec.ts b/src/test/javascript/spec/app/entities/task/task.component.spec.ts new file mode 100644 index 0000000..c158a4e --- /dev/null +++ b/src/test/javascript/spec/app/entities/task/task.component.spec.ts @@ -0,0 +1,51 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { IntegrationUiTestModule } from '../../../test.module'; +import { TaskComponent } from 'app/entities/task/task.component'; +import { TaskService } from 'app/entities/task/task.service'; +import { Task } from 'app/shared/model/task.model'; + +describe('Component Tests', () => { + describe('Task Management Component', () => { + let comp: TaskComponent; + let fixture: ComponentFixture; + let service: TaskService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [IntegrationUiTestModule], + declarations: [TaskComponent], + providers: [] + }) + .overrideTemplate(TaskComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(TaskComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TaskService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Task(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.tasks[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/task/task.service.spec.ts b/src/test/javascript/spec/app/entities/task/task.service.spec.ts new file mode 100644 index 0000000..9dac3e9 --- /dev/null +++ b/src/test/javascript/spec/app/entities/task/task.service.spec.ts @@ -0,0 +1,106 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; +import { TaskService } from 'app/entities/task/task.service'; +import { ITask, Task } from 'app/shared/model/task.model'; + +describe('Service Tests', () => { + describe('Task Service', () => { + let injector: TestBed; + let service: TaskService; + let httpMock: HttpTestingController; + let elemDefault: ITask; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(TaskService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Task(0, 'AAAAAAA', 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Task', async () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new Task(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Task', async () => { + const returnedFromService = Object.assign( + { + title: 'BBBBBB', + description: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Task', async () => { + const returnedFromService = Object.assign( + { + title: 'BBBBBB', + description: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Task', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/test.jh b/test.jh new file mode 100644 index 0000000..8b310ed --- /dev/null +++ b/test.jh @@ -0,0 +1,114 @@ +entity Region { + regionName String +} + +entity Country { + countryName String +} + +// an ignored comment +/** not an ignored comment */ +entity Location { + streetAddress String, + postalCode String, + city String, + stateProvince String +} + +entity Department { + departmentName String required +} + +/** + * Task entity. + * @author The JHipster team. + */ +entity Task { + title String, + description String +} + +/** + * The Employee entity. + */ +entity Employee { + /** + * The firstname attribute. + */ + firstName String, + lastName String, + email String, + phoneNumber String, + hireDate Instant, + salary Long, + commissionPct Long +} + +entity Job { + jobTitle String, + minSalary Long, + maxSalary Long +} + +entity JobHistory { + startDate Instant, + endDate Instant, + language Language +} + +enum Language { + FRENCH, ENGLISH, SPANISH +} + +relationship OneToOne { + Country{region} to Region +} + +relationship OneToOne { + Location{country} to Country +} + +relationship OneToOne { + Department{location} to Location +} + +relationship ManyToMany { + Job{task(title)} to Task{job} +} + +// defining multiple OneToMany relationships with comments +relationship OneToMany { + Employee{job} to Job, + /** + * A relationship + */ + Department{employee} to + /** + * Another side of the same relationship + */ + Employee +} + +relationship ManyToOne { + Employee{manager} to Employee +} + +// defining multiple oneToOne relationships +relationship OneToOne { + JobHistory{job} to Job, + JobHistory{department} to Department, + JobHistory{employee} to Employee +} + +// Set pagination options +paginate JobHistory, Employee with infinite-scroll +paginate Job with pagination + +// Use Data Transfert Objects (DTO) +// dto * with mapstruct + +// Set service options to all except few +service all with serviceImpl except Employee, Job + +// Set an angular suffix +// angularSuffix * with mySuffix