Skip to content

Docs fix and test #608

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 5 commits into from
Jan 3, 2023
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
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

image:https://img.shields.io/github/license/spring-projects-experimental/spring-boot-migrator[GitHub]
image:https://img.shields.io/github/v/release/spring-projects-experimental/spring-boot-migrator[GitHub release (latest by date)]
image:https://img.shields.io/github/downloads/spring-projects-experimental/spring-boot-migrator/0.12.0/total[GitHub release (latest by date)]
image:https://img.shields.io/github/downloads/spring-projects-experimental/spring-boot-migrator/0.13.0/total[GitHub release (latest by date)]

image:https://img.shields.io/badge/Join-Slack-green?logo=slack&color=007EC6&style=for-the-badge[link="https://join.slack.com/t/springbootmigrator/shared_invite/zt-1k6yxfi3b-MEQ_MM67qXufWtc~Tw6y9w"]
image:https://img.shields.io/github/discussions/spring-projects-experimental/spring-boot-migrator?label=GitHub%20discussions&logo=GitHUb&style=for-the-badge[GitHub Discussions]
image:https://img.shields.io/gitter/room/spring-boot-migrator/community?color=007EC6&logo=gitter&style=for-the-badge[Gitter]
image:https://img.shields.io/gitter/room/spring-boot-migrator/community?color=007EC6&logo=gitter&style=for-the-badge[link="https://gitter.im/spring-boot-migrator/community"]

[quote]
____
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface ProjectJavaSources {

List<MethodCall> findMethodCalls(String pattern);

List<JavaSourceAndType> findTypesImplementing(String jpaRepositoryInterface);
List<JavaSourceAndType> findTypesImplementing(String interfaceType);

List<? extends JavaSource> findClassesUsingType(String databaseDriverGAE);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* 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.java.impl;

import org.junit.jupiter.api.Test;
import org.springframework.sbm.engine.context.ProjectContext;
import org.springframework.sbm.java.api.JavaSourceAndType;
import org.springframework.sbm.project.resource.TestProjectContext;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Fabian Krüger
*/
class ProjectJavaSourcesImplTest {

@Test
void findTypesImplementing() {
ProjectContext context = TestProjectContext.buildProjectContext().addJavaSource("src/main/java", """
package com.example;

public interface TheInterface {}
""").addJavaSource("src/main/java", """
package com.example;

public class TheClass implements TheInterface {}
""").build();

List<JavaSourceAndType> typesImplementingInterface = context
.getProjectJavaSources()
.findTypesImplementing("com.example.TheInterface");

assertThat(typesImplementingInterface).isNotEmpty();
assertThat(typesImplementingInterface.get(0).getType().getFullyQualifiedName()).isEqualTo("com.example.TheClass");
}

@Test
void findTypesImplementingInterfaceFromJdk() {
ProjectContext context = TestProjectContext.buildProjectContext()
.addJavaSource("src/main/java", """
package com.example;

import java.io.Serializable;

public class TheClass implements Serializable {}
""").build();

List<JavaSourceAndType> typesImplementingInterface = context
.getProjectJavaSources()
.findTypesImplementing("java.io.Serializable");

assertThat(typesImplementingInterface).isNotEmpty();
assertThat(typesImplementingInterface.get(0).getType().getFullyQualifiedName()).isEqualTo("com.example.TheClass");
}

@Test
void findTypesImplementingWithInterfaceFromJar() {
ProjectContext context = TestProjectContext.buildProjectContext()
.withBuildFileHavingDependencies("org.springframework:spring-context:5.3.23")
.addJavaSource("src/main/java", """
package com.example;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class TheClass implements ApplicationContextAware {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
}
}
""").build();

List<JavaSourceAndType> typesImplementingInterface = context
.getProjectJavaSources()
.findTypesImplementing("org.springframework.context.ApplicationContextAware");

assertThat(typesImplementingInterface).isNotEmpty();
assertThat(typesImplementingInterface.get(0).getType().getFullyQualifiedName()).isEqualTo("com.example.TheClass");
}


}
4 changes: 2 additions & 2 deletions docs/boot-3.0.0-M3-upgrade.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Every section is declared in YAML
==== The Helper

The `Helper` is condition and data provider for the template.
It must implement `ìsApplicable` and `getData` from `SpringBootUpgradeReportSection.Helper`.
It must implement `ìsApplicable` and `getData` from `SpringBootUpgradeReportSectionHelper`.
All variables used in the template must be provided by `getData`.

[source,java]
....
public interface Helper<T> extends Condition {
public abstract class SpringBootUpgradeReportSectionHelper<T> extends Condition {
Map<String, T> getData(ProjectContext context);
}
....
Expand Down