use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class PomTest method testHasDependencyExcludingVersionWhenDependencyHasDifferentGroupId.
@Test
public void testHasDependencyExcludingVersionWhenDependencyHasDifferentGroupId() {
// Set up
final Dependency mockExistingDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, "1.0", DependencyType.JAR);
final Pom pom = getMinimalPom(JAR, mockExistingDependency);
final Dependency mockOtherDependency = getMockDependency("au." + DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, "1.0", DependencyType.JAR);
// Invoke and check
assertFalse(pom.hasDependencyExcludingVersion(mockOtherDependency));
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class PomTest method testHasDependencyExcludingVersionWhenDependencyHasDifferentVersion.
@Test
public void testHasDependencyExcludingVersionWhenDependencyHasDifferentVersion() {
// Set up
final String existingVersion = "1.0";
final Dependency mockExistingDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, existingVersion, DependencyType.JAR);
final Pom pom = getMinimalPom(JAR, mockExistingDependency);
final Dependency mockOtherDependency = getMockDependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, existingVersion + ".1", DependencyType.JAR);
// Invoke and check
assertTrue(pom.hasDependencyExcludingVersion(mockOtherDependency));
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class PomTest method getMockDependency.
private Dependency getMockDependency(final String groupId, final String artifactId, final String version, final DependencyType type) {
final Dependency mockDependency = mock(Dependency.class);
when(mockDependency.getGroupId()).thenReturn(groupId);
when(mockDependency.getArtifactId()).thenReturn(artifactId);
when(mockDependency.getVersion()).thenReturn(version);
when(mockDependency.getType()).thenReturn(type);
return mockDependency;
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class JpaOperationsImpl method addTestScopedDependency.
/**
* Gets database dependency from config file and adds it with test scope
*
* @param moduleName
* the module which dependency should be added
* @param databaseConfigPrefix
* the prefix name for choosing the dependency to add
* @param configuration
* the configuration file with the dependencies to copy from
*/
private void addTestScopedDependency(String moduleName, String databaseConfigPrefix, final Element configuration) {
final List<Element> databaseDependencies = XmlUtils.findElements(databaseConfigPrefix + "/dependencies/dependency", configuration);
for (final Element dependencyElement : databaseDependencies) {
// Change scope from provided to test
NodeList childNodes = dependencyElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
final Node node = childNodes.item(i);
if (node != null && node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("scope")) {
node.setTextContent("test");
}
}
// Add dependency
getProjectOperations().addDependency(moduleName, new Dependency(dependencyElement));
}
}
use of org.springframework.roo.project.Dependency in project spring-roo by spring-projects.
the class JpaOperationsImpl method newEmbeddableClass.
@Override
public void newEmbeddableClass(final JavaType name, final boolean serializable) {
Validate.notNull(name, "Embeddable name required");
final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, getPathResolver().getFocusedPath(Path.SRC_MAIN_JAVA));
final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(Arrays.asList(new AnnotationMetadataBuilder(ROO_JAVA_BEAN), new AnnotationMetadataBuilder(ROO_TO_STRING), new AnnotationMetadataBuilder(EMBEDDABLE)));
if (serializable) {
annotations.add(new AnnotationMetadataBuilder(ROO_SERIALIZABLE));
}
final int modifier = Modifier.PUBLIC;
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, modifier, name, PhysicalTypeCategory.CLASS);
cidBuilder.setAnnotations(annotations);
getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build());
getProjectOperations().addDependency(name.getModule(), new Dependency("org.springframework.boot", "spring-boot-starter-data-jpa", null));
}
Aggregations