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
3 changes: 0 additions & 3 deletions ScriptBeeWebApp/src/Common/Model/Unit.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using MongoDB.Driver;
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Project;
using ScriptBee.Persistence.Mongodb.Entity;
Expand All @@ -15,9 +15,9 @@ public class ProjectPersistenceAdapter(
ILogger<ProjectPersistenceAdapter> logger
) : ICreateProject, IDeleteProject, IGetAllProjects, IGetProject, IUpdateProject
{
public async Task<OneOf<Unit, ProjectIdAlreadyInUseError>> Create(
public async Task<OneOf<Success, ProjectIdAlreadyInUseError>> Create(
ProjectDetails projectDetails,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
)
{
try
Expand All @@ -33,7 +33,7 @@ await mongoRepository.CreateDocument(
return new ProjectIdAlreadyInUseError(projectDetails.Id);
}

return new Unit();
return new Success();
}

public async Task Delete(ProjectId projectId, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Project;

namespace ScriptBee.Ports.Project;

public interface ICreateProject
{
Task<OneOf<Unit, ProjectIdAlreadyInUseError>> Create(
Task<OneOf<Success, ProjectIdAlreadyInUseError>> Create(
ProjectDetails projectDetails,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Ports.Instance;
using ScriptBee.UseCases.Project.Context;

namespace ScriptBee.Service.Project.Context;

using ClearContextResult = OneOf<Unit, InstanceDoesNotExistsError>;
using ClearContextResult = OneOf<Success, InstanceDoesNotExistsError>;

public class ClearInstanceContextService(
IGetProjectInstance getProjectInstance,
Expand All @@ -15,7 +15,7 @@ IClearInstanceContext clearInstanceContext
{
public async Task<ClearContextResult> Clear(
ClearContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
)
{
var result = await getProjectInstance.Get(command.InstanceId, cancellationToken);
Expand All @@ -24,7 +24,7 @@ public async Task<ClearContextResult> Clear(
async instanceInfo =>
{
await clearInstanceContext.Clear(instanceInfo, cancellationToken);
return new Unit();
return new Success();
},
error => Task.FromResult<ClearContextResult>(error)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
Expand All @@ -9,7 +9,7 @@

namespace ScriptBee.Service.Project.Context;

using LinkContextResult = OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;
using LinkContextResult = OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;

public class LinkInstanceContextService(
IGetProject getProject,
Expand All @@ -20,7 +20,7 @@ IUpdateProject updateProject
{
public async Task<LinkContextResult> Link(
LinkContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
)
{
var result = await getProject.GetById(command.ProjectId, cancellationToken);
Expand Down Expand Up @@ -50,7 +50,7 @@ private async Task<LinkContextResult> Link(
async instanceInfo =>
{
await Link(projectDetails, instanceInfo, linkerIds.ToList(), cancellationToken);
return new Unit();
return new Success();
},
error => Task.FromResult<LinkContextResult>(error)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.File;
using ScriptBee.Domain.Model.Instance;
Expand All @@ -10,7 +10,7 @@

namespace ScriptBee.Service.Project.Context;

using LoadContextResult = OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;
using LoadContextResult = OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;

public class LoadInstanceContextService(
IGetProject getProject,
Expand All @@ -21,7 +21,7 @@ IUpdateProject updateProject
{
public async Task<LoadContextResult> Load(
LoadContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
)
{
var result = await getProject.GetById(command.ProjectId, cancellationToken);
Expand All @@ -45,7 +45,7 @@ CancellationToken cancellationToken
async instanceInfo =>
{
await Load(projectDetails, instanceInfo, loaderIds, cancellationToken);
return new Unit();
return new Success();
},
error => Task.FromResult<LoadContextResult>(error)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
Expand All @@ -9,7 +9,7 @@

namespace ScriptBee.Service.Project.Context;

using ReloadContextResult = OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;
using ReloadContextResult = OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>;

public class ReloadInstanceContextService(
IGetProject getProject,
Expand All @@ -21,7 +21,7 @@ ILinkInstanceContext linkInstanceContext
{
public async Task<ReloadContextResult> Reload(
ReloadContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
)
{
var result = await getProject.GetById(command.ProjectId, cancellationToken);
Expand All @@ -45,7 +45,7 @@ CancellationToken cancellationToken
async instanceInfo =>
{
await ReloadContext(projectDetails, instanceInfo, cancellationToken);
return new Unit();
return new Success();
},
error => Task.FromResult<ReloadContextResult>(error)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;

namespace ScriptBee.UseCases.Project.Context;

public interface IClearInstanceContextUseCase
{
Task<OneOf<Unit, InstanceDoesNotExistsError>> Clear(
Task<OneOf<Success, InstanceDoesNotExistsError>> Clear(
ClearContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;

namespace ScriptBee.UseCases.Project.Context;

public interface ILinkInstanceContextUseCase
{
Task<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Link(
Task<OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Link(
LinkContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;

namespace ScriptBee.UseCases.Project.Context;

public interface ILoadInstanceContextUseCase
{
Task<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Load(
Task<OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Load(
LoadContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;

namespace ScriptBee.UseCases.Project.Context;

public interface IReloadInstanceContextUseCase
{
Task<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Reload(
Task<OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>> Reload(
ReloadContextCommand command,
CancellationToken cancellationToken = default
CancellationToken cancellationToken
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
Expand All @@ -27,7 +27,7 @@ public async Task ContexClearSuccessful_ShouldReturnNoContent()
var useCase = Substitute.For<IClearInstanceContextUseCase>();
useCase
.Clear(new ClearContextCommand(projectId, instanceId), Arg.Any<CancellationToken>())
.Returns(Task.FromResult<OneOf<Unit, InstanceDoesNotExistsError>>(new Unit()));
.Returns(Task.FromResult<OneOf<Success, InstanceDoesNotExistsError>>(new Success()));

var response = await _api.PostApi<object>(
new TestWebApplicationFactory<Program>(
Expand All @@ -51,7 +51,7 @@ public async Task InstanceNotExists_ShouldReturnNotFound()
useCase
.Clear(new ClearContextCommand(projectId, instanceId), Arg.Any<CancellationToken>())
.Returns(
Task.FromResult<OneOf<Unit, InstanceDoesNotExistsError>>(
Task.FromResult<OneOf<Success, InstanceDoesNotExistsError>>(
new InstanceDoesNotExistsError(instanceId)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
Expand Down Expand Up @@ -48,7 +48,7 @@ public async Task EmptyBody_ShouldReturnBadRequest()
}

[Fact]
public async Task ContexLinkSuccessful_ShouldReturnNoContent()
public async Task ContextLinkSuccessful_ShouldReturnNoContent()
{
var projectId = ProjectId.FromValue("project-id");
var instanceId = new InstanceId("8be03260-c9e4-4597-94b3-c97ba047724e");
Expand All @@ -62,9 +62,9 @@ public async Task ContexLinkSuccessful_ShouldReturnNoContent()
Arg.Any<CancellationToken>()
)
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new Unit()
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new Success())
);

var response = await _api.PostApi(
Expand All @@ -89,9 +89,9 @@ public async Task ProjectNotExists_ShouldReturnNotFound()
useCase
.Link(Arg.Any<LinkContextCommand>(), Arg.Any<CancellationToken>())
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new ProjectDoesNotExistsError(projectId)
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new ProjectDoesNotExistsError(projectId))
);

var response = await _api.PostApi(
Expand All @@ -116,9 +116,9 @@ public async Task InstanceNotExists_ShouldReturnNotFound()
useCase
.Link(Arg.Any<LinkContextCommand>(), Arg.Any<CancellationToken>())
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new InstanceDoesNotExistsError(instanceId)
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new InstanceDoesNotExistsError(instanceId))
);

var response = await _api.PostApi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using OneOf;
using ScriptBee.Domain.Model;
using OneOf.Types;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.Instance;
using ScriptBee.Domain.Model.Project;
Expand Down Expand Up @@ -62,9 +62,9 @@ public async Task ContexLoadSuccessful_ShouldReturnNoContent()
Arg.Any<CancellationToken>()
)
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new Unit()
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new Success())
);

var response = await _api.PostApi(
Expand All @@ -88,9 +88,9 @@ public async Task ProjectNotExists_ShouldReturnNotFound()
useCase
.Load(Arg.Any<LoadContextCommand>(), Arg.Any<CancellationToken>())
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new ProjectDoesNotExistsError(ProjectId.FromValue("project-id"))
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new ProjectDoesNotExistsError(ProjectId.FromValue("project-id")))
);

var response = await _api.PostApi(
Expand All @@ -115,9 +115,9 @@ public async Task InstanceNotExists_ShouldReturnNotFound()
useCase
.Load(Arg.Any<LoadContextCommand>(), Arg.Any<CancellationToken>())
.Returns(
Task.FromResult<OneOf<Unit, ProjectDoesNotExistsError, InstanceDoesNotExistsError>>(
new InstanceDoesNotExistsError(instanceId)
)
Task.FromResult<
OneOf<Success, ProjectDoesNotExistsError, InstanceDoesNotExistsError>
>(new InstanceDoesNotExistsError(instanceId))
);

var response = await _api.PostApi(
Expand Down
Loading
Loading