Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/getting-started/running/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ yarn --cwd web-ui test
```

Or simply `cd` to the `web-ui` directory and run `yarn test`.

# Running the Server

## Running Tests

To skip building the UI when running unit tests in the Server application add the environment variable `SKIP_WEB_UI=true` to your system or run configuration.
2 changes: 1 addition & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ tasks.withType(JavaCompile) {
}
}

if(System.getenv("SKIP_WEB_UI") == null) {
if(System.getenv("SKIP_WEB_UI") == null || System.getenv("SKIP_WEB_UI") == "false") {
processResources {
into('public') {
from tasks.getByPath(':web-ui:yarnBuild').outputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.UUID;

Expand Down Expand Up @@ -50,23 +51,36 @@ public class ReviewPeriod {
@Schema(description = "the id of the self-review template to be used for this review period")
private UUID selfReviewTemplateId;

@Column(name = "launch_date")
private LocalDateTime launchDate;

@Column(name = "self_review_close_date")
private LocalDateTime selfReviewCloseDate;

@Column(name = "close_date")
private LocalDateTime closeDate;

public ReviewPeriod() {
}

public ReviewPeriod(String name) {
this(name, true, null, null);
this(name, true, null, null, null, null, null);
}

public ReviewPeriod(UUID id, String name, Boolean open) {
this(name, open, null, null);
this(name, open, null, null, null, null, null);
this.id = id;
}

public ReviewPeriod(String name, Boolean open, @Nullable UUID reviewTemplateId, @Nullable UUID selfReviewTemplateId) {
public ReviewPeriod(String name, Boolean open, @Nullable UUID reviewTemplateId, @Nullable UUID selfReviewTemplateId,
LocalDateTime launchDate, LocalDateTime selfReviewCloseDate, LocalDateTime closeDate) {
this.name = name;
this.open = open;
this.reviewTemplateId = reviewTemplateId;
this.selfReviewTemplateId = selfReviewTemplateId;
this.launchDate = launchDate;
this.selfReviewCloseDate = selfReviewCloseDate;
this.closeDate = closeDate;
}

public UUID getId() {
Expand Down Expand Up @@ -99,17 +113,43 @@ public void setName(String name) {

public void setSelfReviewTemplateId(@Nullable UUID selfReviewTemplateId) { this.selfReviewTemplateId = selfReviewTemplateId; }

public LocalDateTime getLaunchDate() {
return launchDate;
}

public void setLaunchDate(LocalDateTime launchDate) {
this.launchDate = launchDate;
}

public LocalDateTime getSelfReviewCloseDate() {
return selfReviewCloseDate;
}

public void setSelfReviewCloseDate(LocalDateTime selfReviewCloseDate) {
this.selfReviewCloseDate = selfReviewCloseDate;
}

public LocalDateTime getCloseDate() {
return closeDate;
}

public void setCloseDate(LocalDateTime closeDate) {
this.closeDate = closeDate;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ReviewPeriod that = (ReviewPeriod) o;
return open == that.open && Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(reviewTemplateId, that.reviewTemplateId) && Objects.equals(selfReviewTemplateId, that.selfReviewTemplateId);
return open == that.open && Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(reviewTemplateId, that.reviewTemplateId)
&& Objects.equals(selfReviewTemplateId, that.selfReviewTemplateId) && Objects.equals(launchDate, that.launchDate)
&& Objects.equals(selfReviewCloseDate, that.selfReviewCloseDate) && Objects.equals(closeDate, that.closeDate);
}

@Override
public int hashCode() {
return Objects.hash(id, name, open, reviewTemplateId, selfReviewTemplateId);
return Objects.hash(id, name, open, reviewTemplateId, selfReviewTemplateId, launchDate, selfReviewCloseDate, closeDate);
}

@Override
Expand All @@ -120,6 +160,10 @@ public String toString() {
sb.append(", open=").append(open);
sb.append(", reviewTemplateId=").append(reviewTemplateId);
sb.append(", selfReviewTemplateId=").append(selfReviewTemplateId);
sb.append(", launchDate=").append(launchDate);
sb.append(", selfReviewCloseDate=").append(selfReviewCloseDate);
sb.append(", closeDate=").append(closeDate);

sb.append('}');
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public ReviewPeriodController(ReviewPeriodServices reviewPeriodServices, EventLo
@Post()
public Mono<HttpResponse<ReviewPeriod>> createReviewPeriod(@Body @Valid ReviewPeriodCreateDTO period, HttpRequest<ReviewPeriodCreateDTO> request) {

return Mono.fromCallable(() -> reviewPeriodServices.save(new ReviewPeriod(period.getName(), period.isOpen(), period.getReviewTemplateId(), period.getSelfReviewTemplateId())))
return Mono.fromCallable(() -> reviewPeriodServices.save(new ReviewPeriod(period.getName(), period.isOpen(), period.getReviewTemplateId(),
period.getSelfReviewTemplateId(), period.getLaunchDate(), period.getSelfReviewCloseDate(), period.getCloseDate())))
.publishOn(Schedulers.fromExecutor(eventLoopGroup))
.map(reviewPeriod -> {
return (HttpResponse<ReviewPeriod>) HttpResponse.created(reviewPeriod)
.headers(headers -> headers.location(
URI.create(String.format("%s/%s", request.getPath(), reviewPeriod.getId()))));
}).subscribeOn(Schedulers.fromExecutor(ioExecutorService));
.map(reviewPeriod -> (HttpResponse<ReviewPeriod>) HttpResponse.created(reviewPeriod)
.headers(headers -> headers.location(
URI.create(String.format("%s/%s", request.getPath(), reviewPeriod.getId())))))
.subscribeOn(Schedulers.fromExecutor(ioExecutorService));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.UUID;

@Introspected
Expand All @@ -21,6 +22,12 @@ public class ReviewPeriodCreateDTO {

private UUID selfReviewTemplateId;

private LocalDateTime launchDate;

private LocalDateTime selfReviewCloseDate;

private LocalDateTime closeDate;

public String getName() {
return name;
}
Expand All @@ -46,4 +53,28 @@ public UUID getReviewTemplateId() {
public UUID getSelfReviewTemplateId() { return selfReviewTemplateId; }

public void setSelfReviewTemplateId(UUID selfReviewTemplateId) { this.selfReviewTemplateId = selfReviewTemplateId; }

public LocalDateTime getLaunchDate() {
return launchDate;
}

public void setLaunchDate(LocalDateTime launchDate) {
this.launchDate = launchDate;
}

public LocalDateTime getSelfReviewCloseDate() {
return selfReviewCloseDate;
}

public void setSelfReviewCloseDate(LocalDateTime selfReviewCloseDate) {
this.selfReviewCloseDate = selfReviewCloseDate;
}

public LocalDateTime getCloseDate() {
return closeDate;
}

public void setCloseDate(LocalDateTime closeDate) {
this.closeDate = closeDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import java.util.UUID;

@JdbcRepository(dialect = Dialect.POSTGRES)
public interface ReviewPeriodRepository extends CrudRepository<ReviewPeriod, UUID> {
public interface ReviewPeriodRepository extends CrudRepository<ReviewPeriod,UUID>{

Optional<ReviewPeriod> findByName(String name);

List<ReviewPeriod> findByNameIlike(String name);

List<ReviewPeriod> findByOpen(boolean open);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE review_periods ADD COLUMN launch_date TIMESTAMP;
ALTER TABLE review_periods ADD COLUMN self_review_close_date TIMESTAMP;
ALTER TABLE review_periods ADD COLUMN close_date TIMESTAMP;
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import io.micronaut.http.multipart.CompletedFileUpload;
import io.micronaut.test.annotation.MockBean;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

import jakarta.inject.Inject;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -27,15 +27,9 @@

import static com.objectcomputing.checkins.services.role.RoleType.Constants.MEMBER_ROLE;
import static io.micronaut.http.MediaType.MULTIPART_FORM_DATA;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

@MicronautTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package com.objectcomputing.checkins.services.fixture;

import com.objectcomputing.checkins.services.reviews.ReviewPeriod;
import com.objectcomputing.checkins.services.skills.Skill;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public interface ReviewPeriodFixture extends RepositoryFixture {

default ReviewPeriod createADefaultReviewPeriod() {
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Time", true, null, null));
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Time", true, null, null,
LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS), LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MILLIS),
LocalDateTime.now().plusDays(2).truncatedTo(ChronoUnit.MILLIS)));
}

default ReviewPeriod createASecondaryReviewPeriod() {
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Play", true, null, null));
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Play", true, null, null,
LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS), LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MILLIS),
LocalDateTime.now().plusDays(2).truncatedTo(ChronoUnit.MILLIS)));
}

default ReviewPeriod createAClosedReviewPeriod() {
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Closure", false, null, null));
return getReviewPeriodRepository().save(new ReviewPeriod("Period of Closure", false, null, null,
LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS), LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MILLIS),
LocalDateTime.now().plusDays(2).truncatedTo(ChronoUnit.MILLIS)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import static com.objectcomputing.checkins.services.role.RoleType.Constants.ADMIN_ROLE;
import static com.objectcomputing.checkins.services.role.RoleType.Constants.MEMBER_ROLE;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

public class ReviewPeriodControllerTest extends TestContainersSuite implements ReviewPeriodFixture, MemberProfileFixture, RoleFixture {

Expand Down Expand Up @@ -131,6 +130,34 @@ public void testPOSTCreateAReviewPeriod() {
assertEquals(String.format("%s/%s", request.getPath(), response.body().getId()), response.getHeaders().get("location"));
}

@Test
public void testPOSTCreateAReviewPeriodWithTimelines() {
LocalDateTime launchDate = LocalDateTime.now();
LocalDateTime selfReviewCloseDate = LocalDateTime.now().plusDays(1);
LocalDateTime closeDate = LocalDateTime.now().plusDays(2);

ReviewPeriodCreateDTO reviewPeriodCreateDTO = new ReviewPeriodCreateDTO();
reviewPeriodCreateDTO.setName("reincarnation");
reviewPeriodCreateDTO.setOpen(true);
reviewPeriodCreateDTO.setLaunchDate(launchDate);
reviewPeriodCreateDTO.setSelfReviewCloseDate(selfReviewCloseDate);
reviewPeriodCreateDTO.setCloseDate(closeDate);

final HttpRequest<ReviewPeriodCreateDTO> request = HttpRequest.
POST("/", reviewPeriodCreateDTO).basicAuth(MEMBER_ROLE, MEMBER_ROLE);
final HttpResponse<ReviewPeriod> response = client.toBlocking().exchange(request, ReviewPeriod.class);

assertNotNull(response);
assertNotNull(response.body());
assertEquals(HttpStatus.CREATED, response.getStatus());
assertEquals(reviewPeriodCreateDTO.getName(), response.body().getName());
assertEquals(reviewPeriodCreateDTO.isOpen(), response.body().isOpen());
assertEquals(String.format("%s/%s", request.getPath(), response.body().getId()), response.getHeaders().get("location"));
assertEquals(reviewPeriodCreateDTO.getLaunchDate(), response.body().getLaunchDate());
assertEquals(reviewPeriodCreateDTO.getSelfReviewCloseDate(), response.body().getSelfReviewCloseDate());
assertEquals(reviewPeriodCreateDTO.getCloseDate(), response.body().getCloseDate());
}

@Test
public void testPOSTCreateAReviewPeriodAlreadyExists() {
ReviewPeriod reviewPeriod = createADefaultReviewPeriod();
Expand Down