Skip to content

Commit

Permalink
Merge branch 'main' into sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
ariwk authored Aug 22, 2024
2 parents d6fdbb4 + fb4fd58 commit e192689
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
name: maven-build
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
branches: ['**/**']
jobs:
build:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [6.6.3](https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic/compare/v6.6.2...v6.6.3) (2024-08-22)


### Bug Fixes

* show revision in the exception message if it was provided as a p… ([#128](https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic/issues/128)) ([107e96e](https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic/commit/107e96e91a80ccbe96b971b358cb6ad524ef8fcb))

## [6.6.2](https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic/compare/v6.6.1...v6.6.2) (2024-08-09)


Expand Down
2 changes: 1 addition & 1 deletion app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ch.sbb.polarion.extensions</groupId>
<artifactId>ch.sbb.polarion.extension.generic</artifactId>
<version>6.6.3-SNAPSHOT</version>
<version>6.6.3</version>
</parent>

<name>Versatile extension for developing additional extensions within Polarion ALM: common code and resources</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public IProject getProject(@NotNull String projectId, @Nullable String revision)

//Note: it seems that there is no way to get project for already deleted project (unlike workitems/modules & collections)
//so method below will throw exception in this case
return getResolvableObjectOrThrow(projectService.getProject(projectId), revision, String.format("Project '%s' not found", projectId));
return getResolvableObjectOrThrow(projectService.getProject(projectId), revision, String.format("Project '%s'%s not found", projectId, getRevisionMessagePart(revision)));
}

@NotNull
Expand All @@ -120,7 +120,7 @@ public IWorkItem getWorkItem(@NotNull String projectId, @NotNull String workItem
throw new IllegalArgumentException("Parameter 'workItemId' should be provided");
}

return getResolvableObjectOrThrow(trackerProject.getWorkItem(workItemId), revision, String.format("WorkItem '%s' not found in project '%s'", workItemId, projectId));
return getResolvableObjectOrThrow(trackerProject.getWorkItem(workItemId), revision, String.format("WorkItem '%s'%s not found in project '%s'", workItemId, getRevisionMessagePart(revision), projectId));
}

@NotNull
Expand All @@ -139,7 +139,7 @@ public IModule getModule(@NotNull String projectId, @NotNull String spaceId, @No
}

ILocation location = Location.getLocation(spaceId + "/" + documentName);
return getResolvableObjectOrThrow(getModule(project, location), revision, String.format("Document '%s' not found in space '%s' of project '%s'", documentName, spaceId, projectId));
return getResolvableObjectOrThrow(getModule(project, location), revision, String.format("Document '%s'%s not found in space '%s' of project '%s'", documentName, getRevisionMessagePart(revision), spaceId, projectId));
}

@NotNull
Expand All @@ -166,7 +166,7 @@ public IBaselineCollection getCollection(@NotNull String projectId, @NotNull Str
.getOldApi()
)
);
return getResolvableObjectOrThrow(collection, revision, String.format("Collection with id '%s' not found in project '%s'", collectionId, projectId));
return getResolvableObjectOrThrow(collection, revision, String.format("Collection with id '%s'%s not found in project '%s'", collectionId, getRevisionMessagePart(revision), projectId));
}

public <T extends IPObject> T getResolvableObjectOrThrow(@NotNull IPObject object, @Nullable String revision, @NotNull String notFoundMessage) {
Expand Down Expand Up @@ -293,4 +293,8 @@ public IRepositoryConnection getConnection(@NotNull ILocation location) {
public IRepositoryReadOnlyConnection getReadOnlyConnection(@NotNull ILocation location) {
return repositoryService.getReadOnlyConnection(location);
}

private String getRevisionMessagePart(String revision) {
return StringUtils.isEmpty(revision) ? "" : " (rev. %s)".formatted(revision);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,35 @@ void init() {
void testGetNotExistentProject() {
mockProject(Boolean.FALSE);

assertThrows(ObjectNotFoundException.class, () -> polarionService.getProject(PROJECT_ID, null));
ObjectNotFoundException exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getProject(PROJECT_ID, null));
assertEquals("Project 'project_id' not found", exception.getMessage());

exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getProject(PROJECT_ID, "123"));
assertEquals("Project 'project_id' (rev. 123) not found", exception.getMessage());
}

@Test
void testGetNotExistentWorkItem() {
IProject project = mockProject(Boolean.TRUE);
mockWorkItem(project, Boolean.FALSE);

assertThrows(ObjectNotFoundException.class, () -> polarionService.getWorkItem(PROJECT_ID, WI_ID));
ObjectNotFoundException exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getWorkItem(PROJECT_ID, WI_ID));
assertEquals("WorkItem 'wi_id' not found in project 'project_id'", exception.getMessage());

exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getWorkItem(PROJECT_ID, WI_ID, "123"));
assertEquals("WorkItem 'wi_id' (rev. 123) not found in project 'project_id'", exception.getMessage());
}

@Test
void testGetNotExistentModule() {
IProject project = mockProject(Boolean.TRUE);
mockModule(project, Boolean.FALSE);

assertThrows(ObjectNotFoundException.class, () -> polarionService.getModule(PROJECT_ID, SPACE_ID, DOCUMENT_NAME));
ObjectNotFoundException exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getModule(PROJECT_ID, SPACE_ID, DOCUMENT_NAME));
assertEquals("Document 'document_name' not found in space 'space_id' of project 'project_id'", exception.getMessage());

exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getModule(PROJECT_ID, SPACE_ID, DOCUMENT_NAME, "123"));
assertEquals("Document 'document_name' (rev. 123) not found in space 'space_id' of project 'project_id'", exception.getMessage());
}

@Test
Expand All @@ -113,7 +125,11 @@ void testGetNotExistentCollection() {
IBaselineCollection collection = mockCollection(Boolean.FALSE);
transactionalExecutorMockedStatic.when(() -> TransactionalExecutor.executeSafelyInReadOnlyTransaction(any())).thenReturn(collection);

assertThrows(ObjectNotFoundException.class, () -> polarionService.getCollection(PROJECT_ID, COLLECTION_ID));
ObjectNotFoundException exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getCollection(PROJECT_ID, COLLECTION_ID));
assertEquals("Collection with id '1' not found in project 'project_id'", exception.getMessage());

exception = assertThrows(ObjectNotFoundException.class, () -> polarionService.getCollection(PROJECT_ID, COLLECTION_ID, "123"));
assertEquals("Collection with id '1' (rev. 123) not found in project 'project_id'", exception.getMessage());
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ch.sbb.polarion.extensions</groupId>
<artifactId>ch.sbb.polarion.extension.generic</artifactId>
<version>6.6.3-SNAPSHOT</version>
<version>6.6.3</version>
<packaging>pom</packaging>

<name>Versatile extension for developing additional extensions within Polarion ALM: parent POM</name>
Expand Down

0 comments on commit e192689

Please sign in to comment.