Search in sources :

Example 6 with BuildParameter

use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.

the class JobsByParamReportTests method invalidParamNameShouldReturnEmptyResults.

@Test
public void invalidParamNameShouldReturnEmptyResults() {
    final JobsByParamReport report = new JobsByParamReportImpl();
    report.setRepository(TestUtils.getTestRepository());
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
    // after each test run
    for (final List<BuildDetails> detailsList : dataset.values()) {
        TestUtils.getTestRepository().saveBuildDetailsList(detailsList);
    }
    final BuildParameter param = dataset.values().iterator().next().get(0).getParameters().get(0);
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(param.getName() + " INVALID", param.getValue(), TestUtils.NOW, TestUtils.NOW);
    Assert.assertTrue("Unexpected results collection", results.isEmpty());
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobsByParamReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobsByParamReportImpl) List(java.util.List) JobsByParamReport(org.jenkins.plugins.audit2db.reports.JobsByParamReport) Test(org.junit.Test)

Example 7 with BuildParameter

use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.

the class BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingParamNameShouldReturnEmptyList.

@Test
public void retrievalByNonMatchingParamNameShouldReturnEmptyList() {
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
    // ideally we should persist dataset in a transaction and roll it back
    // at the end of the test
    final TransactionStatus tx = txmgr.getTransaction(null);
    tx.setRollbackOnly();
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    final Calendar fromDate = Calendar.getInstance();
    fromDate.add(Calendar.YEAR, -1);
    final Calendar toDate = Calendar.getInstance();
    // get the first parameterised build details from the dataset
    BuildDetails expected = null;
    while (dataset.entrySet().iterator().hasNext()) {
        expected = dataset.entrySet().iterator().next().getValue().get(0);
        if (!expected.getParameters().isEmpty()) {
            break;
        }
    }
    final BuildParameter param = expected.getParameters().get(0);
    final List<BuildDetails> buildDetails = repository.getBuildDetailsByParams(hostName, param.getName() + "-WRONGNAME", param.getValue(), fromDate.getTime(), toDate.getTime());
    txmgr.rollback(tx);
    Assert.assertNotNull("Unexpected null list of project names", buildDetails);
    Assert.assertEquals("Unexpected non-empty list retrieved", 0, buildDetails.size());
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) Calendar(java.util.Calendar) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) Test(org.junit.Test)

Example 8 with BuildParameter

use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.

the class BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingParamValueShouldReturnEmptyList.

@Test
public void retrievalByNonMatchingParamValueShouldReturnEmptyList() {
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
    // ideally we should persist dataset in a transaction and roll it back
    // at the end of the test
    final TransactionStatus tx = txmgr.getTransaction(null);
    tx.setRollbackOnly();
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    final Calendar fromDate = Calendar.getInstance();
    fromDate.add(Calendar.YEAR, -1);
    final Calendar toDate = Calendar.getInstance();
    // get the first parameterised build details from the dataset
    BuildDetails expected = null;
    while (dataset.entrySet().iterator().hasNext()) {
        expected = dataset.entrySet().iterator().next().getValue().get(0);
        if (!expected.getParameters().isEmpty()) {
            break;
        }
    }
    final BuildParameter param = expected.getParameters().get(0);
    final List<BuildDetails> buildDetails = repository.getBuildDetailsByParams(hostName, param.getName(), param.getValue() + "-WRONGVALUE", fromDate.getTime(), toDate.getTime());
    txmgr.rollback(tx);
    Assert.assertNotNull("Unexpected null list of project names", buildDetails);
    Assert.assertEquals("Unexpected non-empty list retrieved", 0, buildDetails.size());
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) Calendar(java.util.Calendar) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) Test(org.junit.Test)

Example 9 with BuildParameter

use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.

the class BuildDetailsImplTests method getBuildDetails.

private BuildDetails getBuildDetails() {
    final BuildDetails build = new BuildDetailsImpl();
    build.setDuration(Long.valueOf(60));
    build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
    build.setFullName("BUILD FULL NAME");
    build.setId("BUILD ID");
    build.setName("BUILD NAME");
    build.setUserId("BUILD USER ID");
    build.setUserName("BUILD USER NAME");
    final List<BuildParameter> params = new ArrayList<BuildParameter>();
    params.add(new BuildParameterImpl("PARAM_ID", "PARAM NAME", "PARAM VALUE", build));
    build.setParameters(params);
    return build;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Date(java.util.Date)

Example 10 with BuildParameter

use of org.jenkins.plugins.audit2db.model.BuildParameter in project selenium_java by sergueik.

the class BuildParameterImplTests method differentIdShouldBreakEquality.

@Test
public void differentIdShouldBreakEquality() {
    final BuildParameter actual = new BuildParameterImpl(expected.getId() + "DIFFERENT", expected.getName(), expected.getValue(), expected.getBuildDetails());
    Assert.assertFalse("Broken inequality logic", actual.equals(expected));
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Test(org.junit.Test)

Aggregations

BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)14 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)11 Test (org.junit.Test)11 List (java.util.List)8 BuildParameterImpl (org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl)5 JobsByParamReportImpl (org.jenkins.plugins.audit2db.internal.reports.JobsByParamReportImpl)5 JobsByParamReport (org.jenkins.plugins.audit2db.reports.JobsByParamReport)5 Calendar (java.util.Calendar)4 ArrayList (java.util.ArrayList)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 Date (java.util.Date)2 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)2 Action (hudson.model.Action)1 ParameterValue (hudson.model.ParameterValue)1 ParametersAction (hudson.model.ParametersAction)1 BuildNodeImpl (org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl)1 BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)1