use of co.cask.cdap.NoProgramsApp in project cdap by caskdata.
the class DefaultStoreTest method testCheckDeletedProgramSpecs.
@Test
public void testCheckDeletedProgramSpecs() throws Exception {
// Deploy program with all types of programs.
ApplicationSpecification spec = Specifications.from(new AllProgramsApp());
ApplicationId appId = NamespaceId.DEFAULT.app(spec.getName());
store.addApplication(appId, spec);
Set<String> specsToBeVerified = Sets.newHashSet();
specsToBeVerified.addAll(spec.getMapReduce().keySet());
specsToBeVerified.addAll(spec.getWorkflows().keySet());
specsToBeVerified.addAll(spec.getFlows().keySet());
specsToBeVerified.addAll(spec.getServices().keySet());
specsToBeVerified.addAll(spec.getWorkers().keySet());
specsToBeVerified.addAll(spec.getSpark().keySet());
// Verify if there are 6 program specs in AllProgramsApp
Assert.assertEquals(7, specsToBeVerified.size());
// Check the diff with the same app - re-deployment scenario where programs are not removed.
List<ProgramSpecification> deletedSpecs = store.getDeletedProgramSpecifications(appId, spec);
Assert.assertEquals(0, deletedSpecs.size());
// Get the spec for app that contains no programs.
spec = Specifications.from(new NoProgramsApp());
// Get the deleted program specs by sending a spec with same name as AllProgramsApp but with no programs
deletedSpecs = store.getDeletedProgramSpecifications(appId, spec);
Assert.assertEquals(7, deletedSpecs.size());
for (ProgramSpecification specification : deletedSpecs) {
// Remove the spec that is verified, to check the count later.
specsToBeVerified.remove(specification.getName());
}
// All the 6 specs should have been deleted.
Assert.assertEquals(0, specsToBeVerified.size());
}
Aggregations