use of org.junit.jupiter.api.TestInfo in project harvest-client by 3AP-AG.
the class ProjectAssignmentsApiImplTest method listSelf.
@Test
void listSelf(TestInfo testInfo) {
Project project = null;
try {
final Project tempProject = harvest.projects().create(ImmutableProject.builder().name("Project for " + testInfo.getDisplayName()).billBy(Project.BillingMethod.PROJECT).budgetBy(Project.BudgetMethod.HOURS_PER_PROJECT).billable(false).client(ExistingData.getInstance().getClientReference()).build());
project = tempProject;
User self = harvest.users().getSelf();
// remove self from tempProject
harvest.userAssignments().list(project, new UserAssignmentFilter()).stream().filter(ua -> ua.getUser().getId().equals(self.getId())).forEach(ua -> harvest.userAssignments().delete(tempProject, ua));
List<ProjectAssignment> projectAssignments = projectAssignmentsApi.listSelf();
assertThat(projectAssignments).isNotEmpty();
assertThat(projectAssignments).extracting("project").extracting("id").doesNotContain(tempProject.getId());
} finally {
if (project != null) {
harvest.projects().delete(project);
}
}
}
use of org.junit.jupiter.api.TestInfo in project component-runtime by Talend.
the class ComponentResourceTest method getDependency.
@Test
void getDependency(final TestInfo info, final TemporaryFolder folder) {
final Function<String, File> download = id -> {
final InputStream stream = base.path("component/dependency/{id}").resolveTemplate("id", id).request(APPLICATION_OCTET_STREAM_TYPE).get(InputStream.class);
final File file = new File(folder.getRoot(), info.getTestMethod().get().getName() + ".jar");
try (final OutputStream outputStream = new FileOutputStream(file)) {
IO.copy(stream, outputStream);
} catch (final IOException e) {
throw new IllegalStateException(e);
}
return file;
};
final Consumer<File> jarValidator = file -> {
assertTrue(file.exists());
try (final JarFile jar = new JarFile(file)) {
assertTrue(jar.entries().hasMoreElements());
} catch (final IOException e) {
fail(e.getMessage());
}
};
final File zipLock = download.apply("org.apache.tomee:ziplock:jar:7.0.4");
jarValidator.accept(zipLock);
final File component = download.apply(client.getJdbcId());
jarValidator.accept(component);
}
use of org.junit.jupiter.api.TestInfo in project component-runtime by Talend.
the class StudioInstallerTest method run.
@Test
void run(final TemporaryFolder temporaryFolder, final TestInfo info) throws IOException {
final String testName = info.getTestMethod().get().getName();
final File studioHome = new File(temporaryFolder.getRoot(), testName);
final File configuration = org.apache.ziplock.Files.mkdir(new File(studioHome, "configuration"));
try (final Writer configIni = new FileWriter(new File(configuration, "config.ini"))) {
// no-op
}
final File artifact = new File(temporaryFolder.getRoot(), testName + ".jar");
try (final JarOutputStream out = new JarOutputStream(new FileOutputStream(artifact))) {
out.putNextEntry(new JarEntry("META-INF/MANIFEST.MF"));
out.closeEntry();
}
final StudioInstaller installer = new StudioInstaller("gtest:atest:1.0-SNAPSHOT", studioHome, singletonMap("gtest:atest:1.0-SNAPSHOT", artifact), new Log() {
@Override
public void debug(final String s) {
log.info(s);
}
@Override
public void error(final String s) {
log.error(s);
}
@Override
public void info(final String s) {
log.info(s);
}
});
installer.run();
final File backup = new File(studioHome, "configuration/backup");
{
assertTrue(backup.exists());
assertEquals(1, backup.listFiles((dir, name) -> name.startsWith("config.ini")).length);
assertSetup(studioHome);
}
installer.run();
{
assertSetup(studioHome);
// 1 again cause already here so no other backup
assertEquals(1, backup.listFiles((dir, name) -> name.startsWith("config.ini")).length);
}
}
Aggregations