Example usage for java.lang Short valueOf

List of usage examples for java.lang Short valueOf

Introduction

In this page you can find the example usage for java.lang Short valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Short valueOf(short s) 

Source Link

Document

Returns a Short instance representing the specified short value.

Usage

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testMeetingNotMatchingForCustomerAndLoanOffering() throws Exception {
    createInitialCustomers();//from   w  w  w . j a  va  2  s .  c o  m
    MeetingBO meeting = TestObjectFactory
            .createMeeting(TestObjectFactory.getNewMeetingForToday(MONTHLY, EVERY_MONTH, CUSTOMER_MEETING));
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = createOfferingNoPrincipalInLastInstallment(startDate, meeting);
    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();

    try {
        LoanBO.createLoan(TestUtils.makeUser(), loanOffering, null, AccountState.LOAN_APPROVED,
                new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 10.0, (short) 0, null,
                new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
                DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
                eligibleInstallmentRange.getMinNoOfInstall(), false, null);
        Assert.assertFalse("The Loan object is created even if meetings do not match", true);
    } catch (AccountException ae) {
        Assert.assertTrue("The Loan object is not created if meetings do not match", true);
    }
    TestObjectFactory.removeObject(loanOffering);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testMeetingRecurrenceOfLoanOfferingInMultipleOfCustomer() throws Exception {
    Date startDate = new Date(System.currentTimeMillis());
    createInitialCustomers();//from w  ww . j  a v  a2s.  c o m
    MeetingBO meeting = TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_SECOND_WEEK, CUSTOMER_MEETING));
    LoanOfferingBO loanOffering = createOfferingNoPrincipalInLastInstallment(startDate, meeting);

    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();

    LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_APPROVED,
            new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 10.0, (short) 0, null,
            new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
            DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
            eligibleInstallmentRange.getMinNoOfInstall(), false, null);
    Assert.assertTrue(
            "The Loan object is created if meeting recurrence of loan offering is in multiples of customer",
            true);
    TestObjectFactory.removeObject(loanOffering);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testBuildLoanWithoutLoanAmount() throws Exception {
    createInitialCustomers();//from   w w w .jav  a  2  s .  co  m
    LoanOfferingBO loanOffering = createLoanOffering(false);
    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();

    try {
        LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_APPROVED, null,
                Short.valueOf("6"), new Date(System.currentTimeMillis()), false, 10.0, (short) 0, null,
                new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
                DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
                eligibleInstallmentRange.getMinNoOfInstall(), false, null);
        Assert.assertFalse("The Loan object is created for null customer", true);
    } catch (AccountException ae) {
        Assert.assertTrue("The Loan object is not created for null customer", true);
    }
    TestObjectFactory.removeObject(loanOffering);
}

From source file:org.apache.ambari.server.controller.AmbariManagementControllerTest.java

@Test
public void testCreateCustomActions() throws Exception {
    setupClusterWithHosts("c1", "HDP-2.0.6", new ArrayList<String>() {
        {/*from   w  w  w .  j a  va  2 s  .c  om*/
            add("h1");
            add("h2");
            add("h3");
        }
    }, "centos6");

    Cluster cluster = clusters.getCluster("c1");
    cluster.setDesiredStackVersion(new StackId("HDP-2.0.6"));
    cluster.setCurrentStackVersion(new StackId("HDP-2.0.6"));

    ConfigFactory cf = injector.getInstance(ConfigFactory.class);
    Config config1 = cf.createNew(cluster, "global", new HashMap<String, String>() {
        {
            put("key1", "value1");
        }
    }, new HashMap<String, Map<String, String>>());
    config1.setTag("version1");

    Config config2 = cf.createNew(cluster, "core-site", new HashMap<String, String>() {
        {
            put("key1", "value1");
        }
    }, new HashMap<String, Map<String, String>>());
    config2.setTag("version1");

    cluster.addConfig(config1);
    cluster.addConfig(config2);

    Service hdfs = cluster.addService("HDFS");
    hdfs.persist();

    Service mapred = cluster.addService("YARN");
    mapred.persist();

    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
    hdfs.addServiceComponent(Role.DATANODE.name()).persist();

    mapred.addServiceComponent(Role.RESOURCEMANAGER.name()).persist();

    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition("a1", ActionType.SYSTEM,
            "test,[optional1]", "", "", "Does file exist", TargetHostType.SPECIFIC, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition("a2", ActionType.SYSTEM, "", "HDFS",
            "DATANODE", "Does file exist", TargetHostType.ALL, Short.valueOf("100")));

    Map<String, String> params = new HashMap<String, String>() {
        {
            put("test", "test");
        }
    };

    Map<String, String> requestProperties = new HashMap<String, String>();
    requestProperties.put(REQUEST_CONTEXT_PROPERTY, "Called from a test");
    requestProperties.put("datanode", "abc");

    ArrayList<String> hosts = new ArrayList<String>() {
        {
            add("h1");
        }
    };
    RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", "DATANODE", hosts);
    List<RequestResourceFilter> resourceFilters = new ArrayList<RequestResourceFilter>();
    resourceFilters.add(resourceFilter);

    ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1", null, "a1", resourceFilters, null,
            params, false);
    RequestStatusResponse response = controller.createAction(actionRequest, requestProperties);
    assertEquals(1, response.getTasks().size());
    ShortTaskStatus taskStatus = response.getTasks().get(0);
    Assert.assertEquals("h1", taskStatus.getHostName());

    List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
    Stage stage = actionDB.getAllStages(response.getRequestId()).get(0);
    Assert.assertNotNull(stage);

    Assert.assertEquals(1, storedTasks.size());
    HostRoleCommand task = storedTasks.get(0);
    Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
    Assert.assertEquals("a1", task.getRole().name());
    Assert.assertEquals("h1", task.getHostName());
    ExecutionCommand cmd = task.getExecutionCommandWrapper().getExecutionCommand();
    Type type = new TypeToken<Map<String, String>>() {
    }.getType();
    Map<String, String> hostParametersStage = StageUtils.getGson().fromJson(stage.getHostParamsStage(), type);
    Map<String, String> commandParametersStage = StageUtils.getGson().fromJson(stage.getCommandParamsStage(),
            type);

    Assert.assertTrue(commandParametersStage.containsKey("test"));
    Assert.assertEquals("HDFS", cmd.getServiceName());
    Assert.assertEquals("DATANODE", cmd.getComponentName());
    Assert.assertNotNull(hostParametersStage.get("jdk_location"));

    resourceFilters.clear();
    resourceFilter = new RequestResourceFilter("", "", null);
    resourceFilters.add(resourceFilter);
    actionRequest = new ExecuteActionRequest("c1", null, "a2", resourceFilters, null, params, false);
    response = controller.createAction(actionRequest, requestProperties);
    assertEquals(2, response.getTasks().size());

    final List<HostRoleCommand> storedTasks2 = actionDB.getRequestTasks(response.getRequestId());
    task = storedTasks2.get(1);
    Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
    Assert.assertEquals("a2", task.getRole().name());
    HashSet<String> expectedHosts = new HashSet<String>() {
        {
            add("h2");
            add("h1");
        }
    };
    HashSet<String> actualHosts = new HashSet<String>() {
        {
            add(storedTasks2.get(1).getHostName());
            add(storedTasks2.get(0).getHostName());
        }
    };
    Assert.assertEquals(expectedHosts, actualHosts);

    cmd = task.getExecutionCommandWrapper().getExecutionCommand();
    commandParametersStage = StageUtils.getGson().fromJson(stage.getCommandParamsStage(), type);

    Assert.assertTrue(commandParametersStage.containsKey("test"));
    Assert.assertEquals("HDFS", cmd.getServiceName());
    Assert.assertEquals("DATANODE", cmd.getComponentName());

    hosts = new ArrayList<String>() {
        {
            add("h3");
        }
    };
    resourceFilters.clear();
    resourceFilter = new RequestResourceFilter("", "", hosts);
    resourceFilters.add(resourceFilter);

    actionRequest = new ExecuteActionRequest("c1", null, "a1", resourceFilters, null, params, false);
    response = controller.createAction(actionRequest, requestProperties);
    assertEquals(1, response.getTasks().size());
    taskStatus = response.getTasks().get(0);
    Assert.assertEquals("h3", taskStatus.getHostName());
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testGracePeriodGraterThanMaxNoOfInst() throws Exception {
    createInitialCustomers();// w  ww  .  j  a v  a 2s  .  co m
    LoanOfferingBO loanOffering = createLoanOffering(false);
    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();

    try {
        LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_APPROVED, null,
                Short.valueOf("6"), new Date(System.currentTimeMillis()), false, 10.0, (short) 5, null,
                new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
                DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
                eligibleInstallmentRange.getMinNoOfInstall(), false, null);
        Assert.assertFalse("The Loan object is created for grace period greather than max installments", true);
    } catch (AccountException ae) {
        Assert.assertTrue("The Loan object is not created for grace period greather than max installments",
                true);
    }
    TestObjectFactory.removeObject(loanOffering);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testGracePeriodForInterestNotDedAtDisb() throws Exception {
    createInitialCustomers();/*from w  w  w . j av a 2 s.  c  o  m*/
    LoanOfferingBO product = createLoanOffering(false);
    // product.updateLoanOfferingSameForAllLoan(product);
    LoanOfferingInstallmentRange eligibleInstallmentRange = product.getEligibleInstallmentSameForAllLoan();

    LoanBO loan = LoanBO.createLoan(TestUtils.makeUser(), product, group, AccountState.LOAN_APPROVED,
            new Money(getCurrency(), "300.0"), Short.valueOf("6"), new Date(System.currentTimeMillis()), false,
            10.0, (short) 1, null, new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(),
            DEFAULT_LOAN_AMOUNT, DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
            eligibleInstallmentRange.getMinNoOfInstall(), false, null);
    Assert.assertEquals(product.getGraceType(), loan.getGraceType());
    Assert.assertEquals(1, loan.getGracePeriodDuration().intValue());
    assertNotSame(new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime()).toString(),
            loan.getAccountActionDate((short) 1).getActionDate().toString());

    TestObjectFactory.removeObject(product);
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSEditLogOp.java

public static void fsPermissionToXml(ContentHandler contentHandler, FsPermission mode) throws SAXException {
    XMLUtils.addSaxString(contentHandler, "MODE", Short.valueOf(mode.toShort()).toString());
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSEditLogOp.java

public static FsPermission fsPermissionFromXml(Stanza st) throws InvalidXmlException {
    short mode = Short.valueOf(st.getValue("MODE"));
    return new FsPermission(mode);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testBuildLoanWithValidDisbDate() throws Exception {
    createInitialCustomers();//ww  w . j  a va  2s .  c o m
    LoanOfferingBO loanOffering = createLoanOffering(false);
    Date disbursementDate = new Date(System.currentTimeMillis());
    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();
    try {

        LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_APPROVED,
                new Money(getCurrency(), "300.0"), Short.valueOf("6"), disbursementDate, false, 10.0, (short) 0,
                null, new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
                DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
                eligibleInstallmentRange.getMinNoOfInstall(), false, null);
        Assert.assertTrue("The Loan object is created for valid disbursement date", true);
    } catch (AccountException ae) {
        Assert.assertFalse("The Loan object is created for valid disbursement date", true);
    }
    TestObjectFactory.removeObject(loanOffering);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testBuildLoanWithDisbDateOlderThanCurrentDate() throws Exception {
    createInitialCustomers();/*  ww  w.j  a va  2 s  .  c  om*/
    LoanOfferingBO loanOffering = createLoanOffering(false);
    Date disbursementDate = offSetCurrentDate(15);
    LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan();

    try {

        LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_APPROVED,
                new Money(getCurrency(), "300.0"), Short.valueOf("6"), disbursementDate, false, 10.0, (short) 0,
                null, new ArrayList<FeeView>(), new ArrayList<CustomFieldView>(), DEFAULT_LOAN_AMOUNT,
                DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(),
                eligibleInstallmentRange.getMinNoOfInstall(), false, null);
        Assert.assertFalse("The Loan object is created for invalid disbursement date", true);
    } catch (AccountException ae) {
        Assert.assertTrue("The Loan object is created for invalid disbursement date", true);
    }
    TestObjectFactory.removeObject(loanOffering);
}