public void VisitHBaseBackupStep()
        {
            //Init args
            HBaseBackupStep hBaseBackupStep = new HBaseBackupStep();

            hBaseBackupStep.HBaseJarPath = "{hbaseJar}";
            hBaseBackupStep.BackupPath   = "{myBucket}/hbase/backUp";

            //Expectations
            List <string> expectedArgs = new List <string>()
            {
                "--backup", "--backup-dir", "s3://myBucket/hbase/backUp"
            };

            //Init settings
            BuilderSettings settings = BuildRequestVisitorTest.GetSettings();

            //Init visitor
            BuildRequestVisitor visitor           = new BuildRequestVisitor(settings);
            VisitorSubscriber   visitorSubscriber = new VisitorSubscriber(visitor);

            //Action
            hBaseBackupStep.Accept(visitor);

            //Verify
            Assert.AreEqual(1, visitorSubscriber.TotalObjCount, "Unexpected number of objects created");

            StepConfig actual = visitorSubscriber.stepList[0];

            Assert.AreEqual("Backup HBase", actual.Name, "Unexpected Name");
            Assert.AreEqual(ActionOnFailure.TERMINATE_JOB_FLOW, actual.ActionOnFailure, "Unexpected ActionOnFailure");
            Assert.AreEqual("/home/hadoop/lib/2.2.0/hbase-0.94.7.jar", actual.HadoopJarStep.Jar, "Unexpected Jar");
            Assert.AreEqual("emr.hbase.backup.Main", actual.HadoopJarStep.MainClass, "Unexpected MainClass");
            Assert.IsTrue(expectedArgs.SequenceEqual(actual.HadoopJarStep.Args), "Unexpected args list");
        }
        public void HBaseBackupPathIsMissing()
        {
            //Input
            HBaseBackupStep hBaseBackupStep = new HBaseBackupStep()
            {
                HBaseJarPath = "/home/hadoop/lib/hbase-0.94.7.jar"
            };

            //Init settings
            BuilderSettings settings = BuildRequestVisitorTest.GetSettings();

            //Init visitor
            BuildRequestVisitor visitor           = new BuildRequestVisitor(settings);
            VisitorSubscriber   visitorSubscriber = new VisitorSubscriber(visitor);

            //Action
            try
            {
                hBaseBackupStep.Accept(visitor);
                Assert.Fail("Exception has not been thrown!!!");
            }
            catch (InvalidOperationException ex)
            {
                Assert.IsFalse(visitorSubscriber.wasAnyEventFired, "None of the visitor's events should be fired!");
                Assert.AreEqual <string>("BackupPath property is missing for the HBase Backup Step. Example: \"s3://myBucket/hBaseBackup\"", ex.Message, "Unexpected exception message");
            }
        }
        public void Visit(HBaseBackupStep hBaseBackupStep)
        {
            if (String.IsNullOrEmpty(hBaseBackupStep.HBaseJarPath))
            {
                throw new InvalidOperationException(Resources.E_HBaseBackupJarIsMissing);
            }

            if (String.IsNullOrEmpty(hBaseBackupStep.BackupPath))
            {
                throw new InvalidOperationException(Resources.E_HBaseBackupPathIsMissing);
            }

            this.CreateStepConfig(
                Resources.HBaseBackupStepName,
                hBaseBackupStep.HBaseJarPath,
                Resources.HBaseMainClass,
                ActionOnFailure.TERMINATE_JOB_FLOW,
                new List <String>()
            {
                "--backup", "--backup-dir", hBaseBackupStep.BackupPath
            });
        }