-
Notifications
You must be signed in to change notification settings - Fork 90
3.0.0-M3 Support for Apache Solr Removed #371
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6dc6a59
3.0.0-M3 Support for Apache Solr Removed # 226
ravigkant e7dacc7
Merge branch 'main' into main
fabapp2 53efc72
OpenRewriteJavaSource getExtends return empty optional if the source …
ravigkant 0dfd7e0
Merge remote-tracking branch 'origin/main'
ravigkant b6583a5
Merge branch 'main' into main
ravig-kant 9913686
Merge branch 'main' into main
fabapp2 ce97437
Merge branch 'main' into main
fabapp2 c373390
Merge branch 'spring-projects-experimental:main' into main
ravig-kant 406fb73
M3 Support for Apache Solr Removed
ravigkant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...ava/org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositoryBeanFinder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2021 - 2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.sbm.boot.upgrade_27_30.checks; | ||
|
||
import org.springframework.sbm.java.api.JavaSourceAndType; | ||
import org.springframework.sbm.java.impl.OpenRewriteJavaSource; | ||
import org.springframework.sbm.java.impl.OpenRewriteType; | ||
import org.springframework.sbm.project.resource.ProjectResourceSet; | ||
import org.springframework.sbm.project.resource.filter.ProjectResourceFinder; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
public class ApacheSolrRepositoryBeanFinder implements ProjectResourceFinder<List<JavaSourceAndType>> { | ||
private static final String SOLR_REPOSITORY_CLASS = "org.springframework.data.solr.repository.SolrCrudRepository"; | ||
|
||
@Override | ||
public List<JavaSourceAndType> apply(ProjectResourceSet projectResourceSet) { | ||
return projectResourceSet.stream() | ||
.filter(OpenRewriteJavaSource.class::isInstance) | ||
.map(OpenRewriteJavaSource.class::cast) | ||
.filter(js -> js.getTypes().stream().anyMatch(t -> t.getFullyQualifiedName().equals(SOLR_REPOSITORY_CLASS))) | ||
.map(js -> { | ||
Optional<OpenRewriteType> type = js.getTypes().stream() | ||
.filter(t -> t.getFullyQualifiedName().equals(SOLR_REPOSITORY_CLASS)) | ||
.findFirst(); | ||
if(type.isPresent()) { | ||
return new JavaSourceAndType(js, type.get()); | ||
} else { | ||
return null; | ||
} | ||
}) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositorySectionBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2021 - 2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.sbm.boot.upgrade_27_30.checks; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.sbm.boot.asciidoctor.ChangeSection; | ||
import org.springframework.sbm.boot.asciidoctor.Section; | ||
import org.springframework.sbm.boot.asciidoctor.TodoList; | ||
import org.springframework.sbm.boot.upgrade_27_30.Sbu30_UpgradeSectionBuilder; | ||
import org.springframework.sbm.engine.context.ProjectContext; | ||
import org.springframework.sbm.java.api.JavaSourceAndType; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ApacheSolrRepositorySectionBuilder implements Sbu30_UpgradeSectionBuilder { | ||
|
||
private final ApacheSolrRepositoryBeanFinder finder; | ||
|
||
@Override | ||
public boolean isApplicable(ProjectContext projectContext) { | ||
return ! projectContext.search(finder).isEmpty(); | ||
} | ||
|
||
@Override | ||
public Section build(ProjectContext projectContext) { | ||
List<JavaSourceAndType> solrRepositories = projectContext.search(finder); | ||
|
||
return ChangeSection.RelevantChangeSection.builder() | ||
.title("`Spring Data ApacheSolr` support has been removed") | ||
.paragraph("Support for `Spring Data ApacheSolr` has been removed in Spring Framework 6") | ||
.relevanceSection() | ||
.paragraph("The scan found bean declarations of type `SolrCrudRepository`.") | ||
.todoSection() | ||
.paragraph("Remove repositories of type `SolrCrudRepository`") | ||
.todoList(this.buildTodoList(solrRepositories)) | ||
.build(); | ||
} | ||
|
||
private TodoList buildTodoList(List<JavaSourceAndType> solrRepositories) { | ||
TodoList.TodoListBuilder todoListBuilder = TodoList.builder(); | ||
solrRepositories.forEach(m -> { | ||
todoListBuilder.todo( | ||
TodoList.Todo.builder() | ||
.text(String.format("Remove from class `%s`", m.getType().getFullyQualifiedName())) | ||
.build() | ||
); | ||
}); | ||
return todoListBuilder.build(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositorySectionBuilderTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2021 - 2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.sbm.boot.upgrade_27_30.checks; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.sbm.boot.asciidoctor.Section; | ||
import org.springframework.sbm.engine.context.ProjectContext; | ||
import org.springframework.sbm.java.api.JavaSource; | ||
import org.springframework.sbm.java.api.JavaSourceAndType; | ||
import org.springframework.sbm.java.api.Type; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class ApacheSolrRepositorySectionBuilderTest { | ||
|
||
@Test | ||
void givenAContextWithSolrRepository_applySectionBuilder_validateReport() { | ||
ApacheSolrRepositoryBeanFinder finder = mock(ApacheSolrRepositoryBeanFinder.class); | ||
|
||
Type type = mock(Type.class); | ||
Type type1 = mock(Type.class); | ||
JavaSource javaSource = mock(JavaSource.class); | ||
JavaSource javaSource1 = mock(JavaSource.class); | ||
JavaSourceAndType javaSourceAndType = new JavaSourceAndType(javaSource,type); | ||
JavaSourceAndType javaSourceAndType1 = new JavaSourceAndType(javaSource1,type1); | ||
|
||
ProjectContext context = mock(ProjectContext.class); | ||
ApacheSolrRepositorySectionBuilder sut = new ApacheSolrRepositorySectionBuilder(finder); | ||
List<JavaSourceAndType> matches = List.of( | ||
javaSourceAndType, | ||
javaSourceAndType1 | ||
); | ||
|
||
when(context.search(finder)).thenReturn(matches); | ||
when(type.getFullyQualifiedName()).thenReturn("com.foo.bar.SomeClass"); | ||
when(type1.getFullyQualifiedName()).thenReturn("com.foo.baz.AnotherClass"); | ||
|
||
Section section = sut.build(context); | ||
|
||
String rendered = SectionRendererTestUtil.render(section); | ||
assertThat(rendered).isEqualTo( | ||
""" | ||
=== `Spring Data ApacheSolr` support has been removed | ||
Support for `Spring Data ApacheSolr` has been removed in Spring Framework 6 | ||
|
||
==== Relevance | ||
|
||
The scan found bean declarations of type `SolrCrudRepository`. | ||
|
||
==== Todo | ||
|
||
Remove repositories of type `SolrCrudRepository` | ||
|
||
|
||
* [ ] Remove from class `com.foo.bar.SomeClass` | ||
* [ ] Remove from class `com.foo.baz.AnotherClass` | ||
""" | ||
); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.