/
OpenShiftSpringBootProfileDetectorTest.java
70 lines (60 loc) · 2.77 KB
/
OpenShiftSpringBootProfileDetectorTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
* Copyright (c) 2017-2018 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.openshift.test.core.server.behavior.springboot;
import static org.assertj.core.api.Assertions.assertThat;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.ui.PartInitException;
import org.jboss.tools.openshift.core.server.behavior.springboot.OpenShiftSpringBootProfileDetector;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.TestProjectProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class OpenShiftSpringBootProfileDetectorTest {
private static final String SPRING_BOOT_PROJECT_NAME = "SpringBootProject";
private static final String CONTAINING_PLUGIN = "org.jboss.tools.openshift.test";
private IProject project;
@Before
public void before() throws CoreException, InterruptedException {
this.project = createSpringBootProject();
}
@Test
public void shouldDetectSpringBootProject() {
assertThat(new OpenShiftSpringBootProfileDetector().detect(null, null, project))
.describedAs(
"Wasn't able to detect the " + SPRING_BOOT_PROJECT_NAME + " project as spring boot project")
.isTrue();
}
@SuppressWarnings("restriction")
protected IProject createSpringBootProject() throws CoreException, InterruptedException {
TestProjectProvider projectProvider = new TestProjectProvider(CONTAINING_PLUGIN, null, SPRING_BOOT_PROJECT_NAME,
false);
JobUtils.waitForIdle();
IProject project = projectProvider.getProject();
MavenPluginActivator mavenPlugin = MavenPluginActivator.getDefault();
IProjectConfigurationManager configurationManager = mavenPlugin.getProjectConfigurationManager();
MavenUpdateRequest request = new MavenUpdateRequest(project, false, true);
configurationManager.updateProjectConfiguration(request, new NullProgressMonitor());
JobUtils.waitForIdle();
return project;
}
@After
public void after() throws CoreException {
if (project != null) {
project.delete(true, new NullProgressMonitor());
}
}
}