Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add unit tests for Links and Share persistence classes #95

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: add UTs and javadoc for the LinkRepositoryEbean class
  • Loading branch information
federicorispo committed Feb 13, 2024
commit 3b7cd978d89abbe8ba2bcb47a5ac2275c699fe15
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Link createLink(

ebeanDatabaseManager.getEbeanDatabase().save(link);

return getLinkById(linkId).get();
return link;
}

public Optional<Link> getLinkById(String linkId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,95 @@
import java.util.stream.Stream;

/**
* <p>This is the only class allowed to execute CRUD operations on a {@link Link} element.</p>
* <p>In particular it can create a new {@link Link}, update it, access to and delete an existing
* one.</p>
* This is the only class allowed to execute CRUD operations on a {@link Link} element. In
* particular, it can create a new {@link Link}, update it, access to and delete an existing one.
*/
public interface LinkRepository {

/**
* Creates a new {@link Link} and, after saving it in the database, it returns the {@link Link}
* just created.
*
* @param linkId is a {@link String} representing the internal unique identifier (UUID) of the
* link to create
* @param nodeId is a {@link String} representing the unique identifier of the node which the link
* is created to
* @param publicId is a {@link String} of 32 characters representing the public identifier (hash)
* of the link to create
* @param optExpiresAt is an {@link Optional} of {@link Long} representing the expiration
* timestamp of the link to create if the value is present
* @param optDescription is an {@link Optional} of {@link String} representing the description of
* the link to create if the value is present
* @return the {@link Link} just created and saved in the database.
*/
Link createLink(
String linkId,
String nodeId,
String publicId,
Optional<Long> optExpiresAt,
Optional<String> optDescription
);
String linkId,
String nodeId,
String publicId,
Optional<Long> optExpiresAt,
Optional<String> optDescription);

/**
* Given an internal link identifier, it allows to retrieve a {@link Link} from the database if it
* exists.
*
* @param linkId is a {@link String} representing the unique identifier (UUDI) of the link to
* retrieve
* @return an {@link Optional} containing the requested {@link Link} if it exists, otherwise it
* returns an {@link Optional#empty()}.
*/
Optional<Link> getLinkById(String linkId);

/**
* Given a public link identifier, it allows to retrieve a not expired {@link Link} from the
* database if it exists.
*
* @param publicId is a {@link String} of 32 characters representing the public identifier (hash)
* of the link to retrieve
* @return an {@link Optional} containing the requested {@link Link} if it exists, otherwise it
* returns an {@link Optional#empty()}.
*/
Optional<Link> getLinkByNotExpiredPublicId(String publicId);

Stream<Link> getLinksByNodeId(
String nodeId,
LinkSort sort
);
/**
* Given a node identifier, it allows to retrieve a stream of {@link Link} from the database if
* there are links associated to the related node.
*
* @param nodeId is a {@link String} representing the unique identifier of the node which a list
* of links are associated to
* @return a {@link Stream} containing the requested {@link Link}s if they exist, otherwise it
* returns an empty {@link Stream}.
*/
Stream<Link> getLinksByNodeId(String nodeId, LinkSort sort);

/**
* Given an updated {@link Link}, it updates it in the database and returns the {@link Link} just
* saved.
*
* @param link is the updated {@link Link} to save in the database
* @return the {@link Link} just updated in the database.
*/
Link updateLink(Link link);

/**
* Given a link identifier, it deletes the existing {@link Link} from the database.
*
* <p>if the link identifier is not associated to a {@link Link} then the delete operation does
* nothing.
*
* @param linkId is a {@link String} representing the unique identifier of the link to delete
*/
void deleteLink(String linkId);

/**
* Given a collection of identifiers, it deletes the existing {@link Link}s from the database.
*
* <p>if a link identifier is not associated to a {@link Link} then the delete operation for that
* specific identifier does nothing.
*
* @param linkIds is a {@link Collection} of {@link String}s representing the unique identifier of
* links to delete
*/
void deleteLinksBulk(Collection<String> linkIds);

/**
Expand Down
Loading