Skip to content

Commit

Permalink
Add missing mock methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 18, 2024
1 parent 020740c commit 44ffbb8
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
return new ArtifactStub(
request.getGroupId(), request.getArtifactId(), classifier, request.getVersion(), extension);
});
when(artifactFactory.createProduced(any())).then(iom -> {
ArtifactFactoryRequest request = iom.getArgument(0, ArtifactFactoryRequest.class);
String classifier = request.getClassifier();
String extension = request.getExtension();
String type = request.getType();
if (classifier == null) {
classifier = "";
}
if (extension == null) {
extension = type != null ? type : "";
}
return new ProducedArtifactStub(
request.getGroupId(), request.getArtifactId(), classifier, request.getVersion(), extension);
});
when(session.createArtifact(any(), any(), any(), any(), any(), any())).thenAnswer(iom -> {
String groupId = iom.getArgument(0, String.class);
String artifactId = iom.getArgument(1, String.class);
Expand Down Expand Up @@ -308,6 +322,39 @@ public static InternalSession getMockSession(LocalRepository localRepository) {
.extension(extension)
.build());
});
when(session.createProducedArtifact(any(), any(), any(), any(), any(), any()))
.thenAnswer(iom -> {
String groupId = iom.getArgument(0, String.class);
String artifactId = iom.getArgument(1, String.class);
String version = iom.getArgument(2, String.class);
String classifier = iom.getArgument(3, String.class);
String extension = iom.getArgument(4, String.class);
String type = iom.getArgument(5, String.class);
return session.getService(ArtifactFactory.class)
.createProduced(ArtifactFactoryRequest.builder()
.session(session)
.groupId(groupId)
.artifactId(artifactId)
.version(version)
.classifier(classifier)
.extension(extension)
.type(type)
.build());
});
when(session.createProducedArtifact(any(), any(), any(), any())).thenAnswer(iom -> {
String groupId = iom.getArgument(0, String.class);
String artifactId = iom.getArgument(1, String.class);
String version = iom.getArgument(2, String.class);
String extension = iom.getArgument(3, String.class);
return session.getService(ArtifactFactory.class)
.createProduced(ArtifactFactoryRequest.builder()
.session(session)
.groupId(groupId)
.artifactId(artifactId)
.version(version)
.extension(extension)
.build());
});
when(session.getService(ArtifactFactory.class)).thenReturn(artifactFactory);

//
Expand Down

0 comments on commit 44ffbb8

Please sign in to comment.