Package azkaban.common.utils

Examples of azkaban.common.utils.Props


                return null;
            }
        }).once();

        Props mockFlow1Props = new Props();
        mockFlow1Props.put("1", "1");
        mockFlow1Props.put("2", "1");

        EasyMock.expect(mockFlow1.getStatus()).andReturn(Status.SUCCEEDED).times(2);
        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(mockFlow1Props).once();

        /**** Setup mockFlow2 ****/
        final Capture<FlowCallback> flow2Callback = new Capture<FlowCallback>();
        mockFlow2.execute(EasyMock.eq(props), EasyMock.capture(flow2Callback));
        EasyMock.expectLastCall().andAnswer(new IAnswer<Void>() {
            @Override
            public Void answer() throws Throwable {
                Assert.assertEquals(Status.RUNNING, flow.getStatus());
                Assert.assertEquals(2, numJobsComplete.incrementAndGet());

                flow2Callback.getValue().completed(Status.SUCCEEDED);

                Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());

                return null;
            }
        }).once();

        EasyMock.expect(mockFlow2.getStatus()).andAnswer(new IAnswer<Status>()
        {
            private volatile AtomicInteger count = new AtomicInteger(0);

            @Override
            public Status answer() throws Throwable
            {
                switch (count.getAndIncrement()) {
                    case 0: return Status.READY;
                    case 1: return Status.SUCCEEDED;
                    default: Assert.fail("mockFlow2.getStatus() should only be called 2 times.");
                }
                return null;
            }
        }).times(2);

        Props mockFlow2Props = new Props();
        mockFlow2Props.put("2", "2");
        mockFlow2Props.put("3", "2");
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(mockFlow2Props).once();

        EasyMock.expect(props.equalsProps(props)).andReturn(true).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        /**** Start the test ****/
        AtomicBoolean callbackRan = new AtomicBoolean(false);
        flow.execute(
                props,
                new OneCallFlowCallback(callbackRan) {
                    @Override
                    public void theCallback(Status status) {
                        Assert.assertEquals(Status.SUCCEEDED, status);
                        Assert.assertEquals(2, numJobsComplete.get());
                    }
                });

        Assert.assertTrue("Callback wasn't run.", callbackRan.get());
        Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());
        Assert.assertEquals(emptyExceptions, flow.getExceptions());
        Assert.assertEquals(props, flow.getParentProps());

        callbackRan = new AtomicBoolean(false);
        flow.execute(
                props,
                new OneCallFlowCallback(callbackRan)
                {
                    @Override
                    protected void theCallback(Status status)
                    {
                        Assert.assertEquals(Status.SUCCEEDED, status);
                        Assert.assertEquals(2, numJobsComplete.get());
                    }
                });

        Assert.assertTrue("Callback wasn't run.", callbackRan.get());
        Assert.assertEquals(Status.SUCCEEDED, flow.getStatus());
        Assert.assertEquals(emptyExceptions, flow.getExceptions());

        Props retProps = flow.getReturnProps();
        Assert.assertEquals(3, retProps.size());
        Assert.assertEquals("1", retProps.get("1"));
        Assert.assertEquals("2", retProps.get("2"));
        Assert.assertEquals("2", retProps.get("3"));

        EasyMock.verify(props);
        EasyMock.reset(props);

        EasyMock.expect(props.equalsProps(props)).andReturn(false).once();
View Full Code Here


    {
    }
     
    @Test
    public void testResolveProps() throws Exception {
        Props inputProps = new Props();
        Props genProps = new Props();
        Props outputProps;
       
        inputProps.put("firstName", "Francesco");
        inputProps.put("fillIn", "the guilty party is ${firstName} ${lastName}");
        genProps.put("lastName", "Estaban");

        Props theProps = new Props(inputProps, genProps);
       
        outputProps = PropsUtils.resolveProps(theProps);
        String answer = outputProps.get("fillIn");
        System.out.println(answer);
       
View Full Code Here

                }
                return null;
            }
        }).times(2);

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();
       
        EasyMock.expect(props.equalsProps(props)).andReturn(true).times(2);

        EasyMock.replay(mockFlow1, mockFlow2, props);
View Full Code Here

        EasyMock.expect(props.equalsProps(props)).andReturn(true).once();

        EasyMock.expect(mockFlow1.getName()).andReturn("1").once();
        EasyMock.expect(mockFlow2.getName()).andReturn("2").once();

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        flow = new GroupedExecutableFlow("blah", mockFlow1, mockFlow2);
View Full Code Here

        EasyMock.expect(props.equalsProps(props)).andReturn(true).once();

        EasyMock.expect(mockFlow1.getName()).andReturn("1").once();
        EasyMock.expect(mockFlow2.getName()).andReturn("2").once();

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        flow = new GroupedExecutableFlow("blah", mockFlow1, mockFlow2);
View Full Code Here

        EasyMock.expect(props.equalsProps(props)).andReturn(true).once();

        EasyMock.expect(mockFlow1.getName()).andReturn("1").once();
        EasyMock.expect(mockFlow2.getName()).andReturn("2").once();

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        flow = new GroupedExecutableFlow("blah", mockFlow1, mockFlow2);
View Full Code Here

        EasyMock.expect(props.equalsProps(props)).andReturn(true).once();

        EasyMock.expect(mockFlow1.getName()).andReturn("1").once();
        EasyMock.expect(mockFlow2.getName()).andReturn("2").once();

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        flow = new GroupedExecutableFlow("blah", mockFlow1, mockFlow2);
View Full Code Here

        EasyMock.reset(mockFlow1, mockFlow2, props);

        EasyMock.expect(mockFlow1.getStatus()).andReturn(Status.SUCCEEDED).once();
        EasyMock.expect(mockFlow2.getStatus()).andReturn(Status.SUCCEEDED).once();

        EasyMock.expect(mockFlow1.getReturnProps()).andReturn(new Props()).once();
        EasyMock.expect(mockFlow2.getReturnProps()).andReturn(new Props()).once();

        EasyMock.replay(mockFlow1, mockFlow2, props);

        DateTime beforeTheEnd = new DateTime();
        callbackCapture2.getValue().completed(Status.SUCCEEDED);
View Full Code Here

       }
    @Override
    public Props getJobGeneratedProperties()
    {
      return new Props();
    }
View Full Code Here

    }

    @Override
    public Props getJobGeneratedProperties()
    {
        return new Props();
    }
View Full Code Here

TOP

Related Classes of azkaban.common.utils.Props

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.