Skip to main content
summaryrefslogtreecommitdiffstats
blob: f9f335a562f83ea22ccf50feb19132c7ddc55bcc (plain) (blame)
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
71
72
73
74
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are 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:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.skynet.core.mocks.DbTestUtil;
import org.eclipse.osee.framework.skynet.core.util.FrameworkTestUtil;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
import org.eclipse.osee.support.test.util.TestUtil;

/**
 * This test is intended to be run against a demo database. It tests the purge logic by counting the rows of the version
 * and txs tables, creating artifacts, changing them and then purging them. If it works properly, all rows should be
 * equal.
 * 
 * @author Donald G. Dunne
 */
public class ArtifactPurgeTest extends AbstractPurgeTest {
   private static final List<String> tables = Arrays.asList("osee_attribute", "osee_artifact", "osee_relation_link",
      "osee_tx_details", "osee_txs");

   @Override
   public void runPurgeOperation() throws OseeCoreException {
      // Count rows in tables prior to purge
      getPostTableCount();

      // Create some software artifacts
      Branch branch = BranchManager.getBranch(DemoSawBuilds.SAW_Bld_2.getName());
      Collection<Artifact> softArts =
         FrameworkTestUtil.createSimpleArtifacts(CoreArtifactTypes.SoftwareRequirement, 10, getClass().getSimpleName(),
            branch);
      Artifacts.persistInTransaction("Test purge artifacts", softArts);

      // make more changes to artifacts
      for (Artifact softArt : softArts) {
         softArt.addAttribute(CoreAttributeTypes.StaticId, getClass().getSimpleName());
         softArt.persist(getClass().getSimpleName());
      }

      // Count rows and check that increased
      DbTestUtil.getTableRowCounts(postCreateArtifactsCount, getTables());
      TestUtil.checkThatIncreased(preCreateArtifactsCount, postCreateArtifactsCount);

      Operations.executeWorkAndCheckStatus(new PurgeArtifacts(softArts));

      // Count rows and check that same as when began
      getPostTableCount();
      // TODO Looks like attributes created after initial artifact creation are not getting purged.  Needs Fix.
      TestUtil.checkThatEqual(preCreateArtifactsCount, postPurgeCount);

   }

   @Override
   public List<String> getTables() {
      return tables;
   }

}

Back to the top