@Test public void testWriteDatabase() throws Exception { final ILSLog log = TestUtil.createJavaUtilGlobalLog(); final LicenseStoreData licenseStoreData = TestUtil.readLicenseStoreData(log); final BuildInfo buildInfo = createBuildInformation(); final List<Archive> archives = new ArrayList<>(); final Archive archive1 = createArchive1(licenseStoreData); archives.add(archive1); final Archive archive2 = createArchive2(); archives.add(archive2); final ExecutionDatabaseConfiguration databaseConfiguration = createDatabaseConfiguration(); DatabaseWriter.writeToDatabase(buildInfo, archives, databaseConfiguration, log); final List<String> tablesNamesToCheck = Arrays.asList("Builds", "LibraryData", "DetectedLicenses"); final IDataSet expectedDataSet = new FlatXmlDataSetBuilder() .build(new File("src/test/resources/database/expectedForDatabaseWriterTest.xml")); assertDatabase(expectedDataSet, tablesNamesToCheck); }
public static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives, final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log) { if (log.isDebugEnabled()) { DatabaseUtil.dumpDrivers(log); } try (final Connection connection = DatabaseUtil.getConnection(databaseConfiguration)) { final int buildPK = insertBuild(buildInfo, connection); for (final Archive archive : archives) { final int libraryPK = insertLibrary(buildPK, archive, connection); final Set<License> detectedLicenses = archive.getDetectedLicenses(); List<License> detectedLicensesList = new ArrayList<>(detectedLicenses); Collections.sort(detectedLicensesList); for (final License detectedLicense : detectedLicensesList) { insertDetectedLicense(libraryPK, detectedLicense, connection); } } } catch (SQLException e) { log.error(e); } }
DatabaseWriter { public static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives, final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log) { if (log.isDebugEnabled()) { DatabaseUtil.dumpDrivers(log); } try (final Connection connection = DatabaseUtil.getConnection(databaseConfiguration)) { final int buildPK = insertBuild(buildInfo, connection); for (final Archive archive : archives) { final int libraryPK = insertLibrary(buildPK, archive, connection); final Set<License> detectedLicenses = archive.getDetectedLicenses(); List<License> detectedLicensesList = new ArrayList<>(detectedLicenses); Collections.sort(detectedLicensesList); for (final License detectedLicense : detectedLicensesList) { insertDetectedLicense(libraryPK, detectedLicense, connection); } } } catch (SQLException e) { log.error(e); } } }
DatabaseWriter { public static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives, final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log) { if (log.isDebugEnabled()) { DatabaseUtil.dumpDrivers(log); } try (final Connection connection = DatabaseUtil.getConnection(databaseConfiguration)) { final int buildPK = insertBuild(buildInfo, connection); for (final Archive archive : archives) { final int libraryPK = insertLibrary(buildPK, archive, connection); final Set<License> detectedLicenses = archive.getDetectedLicenses(); List<License> detectedLicensesList = new ArrayList<>(detectedLicenses); Collections.sort(detectedLicensesList); for (final License detectedLicense : detectedLicensesList) { insertDetectedLicense(libraryPK, detectedLicense, connection); } } } catch (SQLException e) { log.error(e); } } private  DatabaseWriter(); }
DatabaseWriter { public static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives, final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log) { if (log.isDebugEnabled()) { DatabaseUtil.dumpDrivers(log); } try (final Connection connection = DatabaseUtil.getConnection(databaseConfiguration)) { final int buildPK = insertBuild(buildInfo, connection); for (final Archive archive : archives) { final int libraryPK = insertLibrary(buildPK, archive, connection); final Set<License> detectedLicenses = archive.getDetectedLicenses(); List<License> detectedLicensesList = new ArrayList<>(detectedLicenses); Collections.sort(detectedLicensesList); for (final License detectedLicense : detectedLicensesList) { insertDetectedLicense(libraryPK, detectedLicense, connection); } } } catch (SQLException e) { log.error(e); } } private  DatabaseWriter(); static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives,
                                       final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log); }
DatabaseWriter { public static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives, final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log) { if (log.isDebugEnabled()) { DatabaseUtil.dumpDrivers(log); } try (final Connection connection = DatabaseUtil.getConnection(databaseConfiguration)) { final int buildPK = insertBuild(buildInfo, connection); for (final Archive archive : archives) { final int libraryPK = insertLibrary(buildPK, archive, connection); final Set<License> detectedLicenses = archive.getDetectedLicenses(); List<License> detectedLicensesList = new ArrayList<>(detectedLicenses); Collections.sort(detectedLicensesList); for (final License detectedLicense : detectedLicensesList) { insertDetectedLicense(libraryPK, detectedLicense, connection); } } } catch (SQLException e) { log.error(e); } } private  DatabaseWriter(); static void writeToDatabase(final BuildInfo buildInfo, final List<Archive> archives,
                                       final ExecutionDatabaseConfiguration databaseConfiguration, final ILSLog log);  }