Skip to content

Commit

Permalink
Change upsert video to update video
Browse files Browse the repository at this point in the history
  • Loading branch information
Muttalip committed Dec 15, 2019
1 parent 3ccfd7f commit d5cfd6c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Create {
@Value
@Builder
@AllArgsConstructor
class Upsert {
class Update {
@NonNull
@Builder.Default
Option<String> name = Option.none();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface VideoService extends Service {

ServiceCall<NotUsed, Video> get(UUID id);

ServiceCall<VideoRequest.Upsert, Video> upsert(UUID id);
ServiceCall<VideoRequest.Update, Video> update(UUID id);

ServiceCall<NotUsed, Done> remove(UUID id);

Expand All @@ -34,7 +34,7 @@ default Descriptor descriptor() {
restCall(Method.GET, "/health", this::health),
restCall(Method.POST, "api/video", this::create),
restCall(Method.GET, "api/video?id", this::get),
restCall(Method.PUT, "api/video?id", this::upsert),
restCall(Method.PUT, "api/video?id", this::update),
restCall(Method.DELETE, "api/video?id", this::remove)
)
.withTopics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Get implements VideoCommand, CompressedJsonable, PersistentEntity.Re
@Wither
@Immutable
@Getter
final class Upsert implements VideoCommand, CompressedJsonable, PersistentEntity.ReplyType<VideoState> {
final class Update implements VideoCommand, CompressedJsonable, PersistentEntity.ReplyType<VideoState> {
@NonNull
@Builder.Default
Option<String> name = Option.none();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public ServiceCall<NotUsed, Video> get(UUID id) {
}

@Override
public ServiceCall<VideoRequest.Upsert, Video> upsert(UUID id) {
public ServiceCall<VideoRequest.Update, Video> update(UUID id) {
return req -> RequestValidator.validate(req)
.map(validatedRequest -> upsertVideo(id, CommandBuilder.build(validatedRequest)))
.map(validatedRequest -> updateVideo(id, CommandBuilder.build(validatedRequest)))
.fold(
err -> {
throw ErrorHandler.handle(err);
Expand Down Expand Up @@ -95,7 +95,7 @@ private CompletionStage<VideoState> getVideo(UUID id) {
.ask(CommandBuilder.buildGet());
}

private CompletionStage<VideoState> upsertVideo(UUID id, VideoCommand.Upsert cmd) {
private CompletionStage<VideoState> updateVideo(UUID id, VideoCommand.Update cmd) {
return persistentEntityRegistry
.refFor(VideoEntity.class, id.toString())
.ask(cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static VideoCommand.Get buildGet() {
return VideoCommand.Get.builder().build();
}

public static VideoCommand.Upsert build(VideoRequest.Upsert req) {
return VideoCommand.Upsert.builder()
public static VideoCommand.Update build(VideoRequest.Update req) {
return VideoCommand.Update.builder()
.name(req.getName())
.description(req.getDescription())
.likes(req.getLikes())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static Validation<Seq<DomainError>, VideoRequest.Create> validate(VideoRe
).ap((notUsed, notUsed2) -> request);
}

public static Validation<Seq<DomainError>, VideoRequest.Upsert> validate(VideoRequest.Upsert request) {
public static Validation<Seq<DomainError>, VideoRequest.Update> validate(VideoRequest.Update request) {
return Validation.valid(request);
}

Expand Down

0 comments on commit d5cfd6c

Please sign in to comment.