Example usage for java.util ArrayList getClass

List of usage examples for java.util ArrayList getClass

Introduction

In this page you can find the example usage for java.util ArrayList getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:InlineTestStringsProvider.java

@SuppressWarnings("unchecked")
@Override/* w  w  w.  j a v a 2  s  .  c o  m*/
void provideStrings() throws Exception {

    // Setup errors are set by the constructor - if any.
    if (!isBlank(getErrors()) || !isSetupValid())
        return;

    String testItemsGeneratorClassName = getClassName();
    String testItemsGeneratorMethod = getMethodName();

    // Invoke a method in an 'inline' items provide class
    // This code is here by design in order to keep the inline test item provider with no dependency on any of the main classes (such as TestItem)
    try {
        Class c = loadInlineClassIfNeeded(testItemsGeneratorClassName);
        try {
            Object o = c.newInstance();
            ArrayList<String[]> testData = new ArrayList<>();
            Method m = c.getDeclaredMethod(testItemsGeneratorMethod, testData.getClass());
            m.setAccessible(true);
            // Invoke the method on the instance with testData as a parameter to be created and returned
            m.invoke(o, testData);
            stringifyTestItems(testData);
        } catch (InvocationTargetException e) {
            throw (new Exception(
                    "InvocationTargetException generated by invoking Inline Items Generator Class: "
                            + sq(testItemsGeneratorClassName) + " / Method: " + sq(testItemsGeneratorMethod)));
        } catch (Exception e) {
            throw (new Exception("Exception generated by invoking Inline Items Generator Class: "
                    + sq(testItemsGeneratorClassName) + " / Method: " + sq(testItemsGeneratorMethod)));
        }
    } catch (Exception e) {
        System.out.println("failed to get class for class named: " + sq(testItemsGeneratorClassName));
    }
}

From source file:com.devicehive.resource.DeviceNotificationResourceTest.java

@Test
public void should_get_response_with_status_200_and_notification_when_waitTimeout_is_0_and_polling_for_device() {
    DeviceClassEquipmentVO equipment = DeviceFixture.createEquipmentVO();
    DeviceClassUpdate deviceClass = DeviceFixture.createDeviceClass();
    deviceClass.setEquipment(Optional.of(Collections.singleton(equipment)));
    NetworkVO network = DeviceFixture.createNetwork();
    String guid = UUID.randomUUID().toString();
    DeviceUpdate deviceUpdate = DeviceFixture.createDevice(guid);
    deviceUpdate.setDeviceClass(Optional.of(deviceClass));
    deviceUpdate.setNetwork(Optional.of(network));
    DateTime timeStamp = new DateTime(DateTimeZone.UTC);

    // register device
    Response response = performRequest("/device/" + guid, "PUT", emptyMap(),
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), deviceUpdate, NO_CONTENT,
            null);/*from w  ww.  j a v a2  s  . c o  m*/
    assertNotNull(response);

    // Create notification
    DeviceNotification notification = DeviceFixture.createDeviceNotification();
    notification = performRequest("/device/" + guid + "/notification", "POST", emptyMap(),
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), notification, CREATED,
            DeviceNotification.class);
    assertNotNull(notification.getId());

    // poll notification
    Map<String, Object> params = new HashMap<>();
    params.put("waitTimeout", 0);
    params.put("timestamp", timeStamp);
    ArrayList notifications = new ArrayList();
    notifications = performRequest("/device/" + guid + "/notification/poll", "GET", params,
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), null, OK,
            notifications.getClass());
    assertNotNull(notifications);
    assertEquals(1, notifications.size());
}

From source file:com.devicehive.resource.DeviceCommandResourceTest.java

@Test
public void should_get_response_with_status_200_and_updated_command_when_command_was_processed_and_waitTimeout_is_0_and_polling_for_device()
        throws Exception {
    DeviceClassEquipmentVO equipment = DeviceFixture.createEquipmentVO();
    DeviceClassUpdate deviceClass = DeviceFixture.createDeviceClass();
    deviceClass.setEquipment(Optional.of(Collections.singleton(equipment)));
    NetworkVO network = DeviceFixture.createNetwork();
    String guid = UUID.randomUUID().toString();
    DeviceUpdate deviceUpdate = DeviceFixture.createDevice(guid);
    deviceUpdate.setDeviceClass(Optional.of(deviceClass));
    deviceUpdate.setNetwork(Optional.of(network));
    DateTime timeStamp = new DateTime(DateTimeZone.UTC);

    // register device
    Response response = performRequest("/device/" + guid, "PUT", emptyMap(),
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), deviceUpdate, NO_CONTENT,
            null);/*ww  w  .j a v a2 s. c o  m*/
    assertNotNull(response);
    TimeUnit.SECONDS.sleep(1);

    // create command
    DeviceCommand command = DeviceFixture.createDeviceCommand();
    command = performRequest("/device/" + guid + "/command", "POST", emptyMap(),
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), command, CREATED,
            DeviceCommand.class);
    assertNotNull(command.getId());
    TimeUnit.SECONDS.sleep(1);

    // poll command
    Map<String, Object> params = new HashMap<>();
    params.put("waitTimeout", 0);
    params.put("timestamp", timeStamp);
    ArrayList updatedCommands = new ArrayList();
    updatedCommands = performRequest("/device/" + guid + "/command/poll", "GET", params,
            singletonMap(HttpHeaders.AUTHORIZATION, tokenAuthHeader(ACCESS_KEY)), null, OK,
            updatedCommands.getClass());
    assertNotNull(updatedCommands);
    assertEquals(1, updatedCommands.size());

}

From source file:com.circles.model.ApplicationJSON.java

public Object PopulateFromJSONObjectArray(ArrayList jobj) {
    ArrayList childhash = new ArrayList();
    System.out.println("array" + jobj.getClass().toString());

    for (int i = 0; i < jobj.size(); i++) {
        Object objchild = processObject(jobj.get(i));
        childhash.add(objchild);/*from w w  w  .j av  a2 s  .co m*/

    }
    return childhash;
}

From source file:org.openlmis.restapi.service.RestRequisitionServiceTest.java

@Test
public void sdpShouldNotInitiateRnrIfRnrAlreadyExists() throws Exception {

    RnrLineItem rnrLineItem = make(a(defaultRnrLineItem, with(productCode, "P10")));
    List<RnrLineItem> products = asList(rnrLineItem);
    requisition.setFullSupplyLineItems(products);
    requisition.setProgram(new Program());

    RegimenLineItem regimenLineItem = make(a(defaultRegimenLineItem));
    requisition.setRegimenLineItems(asList(regimenLineItem));

    report.setProducts(products);//from  w  ww . java  2 s. c  o m
    RegimenLineItem reportRegimenLineItem = make(
            a(defaultRegimenLineItem, with(patientsOnTreatment, 10), with(patientsStoppedTreatment, 5)));
    report.setRegimens(asList(reportRegimenLineItem));
    report.setPeriodId(1L);
    report.setEmergency(false);

    Long facility_id = 5L;

    ProgramSupported programSupported = make(a(defaultProgramSupported));
    Facility facility = make(a(defaultFacility, with(facilityId, facility_id),
            with(programSupportedList, asList(programSupported)), with(virtualFacility, true)));

    when(facilityService.getOperativeFacilityByCode(DEFAULT_AGENT_CODE)).thenReturn(facility);
    when(programService.getValidatedProgramByCode(DEFAULT_PROGRAM_CODE)).thenReturn(new Program(PROGRAM_ID));

    expectedException.expect(DataException.class);
    doThrow(new DataException("rnr.error")).when(restRequisitionCalculator).validateCustomPeriod(
            any(Facility.class), any(Program.class), any(ProcessingPeriod.class), any(Long.class));

    ArrayList<ProcessingPeriod> array = new ArrayList<>();
    when(requisitionService.getRequisitionsFor(any(RequisitionSearchCriteria.class), any(array.getClass())))
            .thenReturn(asList(new Rnr()));

    service.submitSdpReport(report, 1L);
    verify(requisitionService, never()).initiate(any(Facility.class), any(Program.class), any(Long.class),
            any(Boolean.class), any(ProcessingPeriod.class));

}

From source file:org.wso2.developerstudio.datamapper.diagram.tree.generator.SchemaTransformer.java

/**
 * Gets the namespaces value//w w w  .jav  a2  s .  c om
 * 
 * @param jsonSchemaMap
 *            schema
 * @return value
 */
@SuppressWarnings("unchecked")
private String getNamespaces(Map<String, Object> jsonSchemaMap) {
    if (jsonSchemaMap.containsKey(JSON_SCHEMA_NAMESPACES)) {
        ArrayList<HashMap<String, String>> namespaces = (ArrayList<HashMap<String, String>>) jsonSchemaMap
                .get(JSON_SCHEMA_NAMESPACES);
        if (namespaces instanceof ArrayList) {
            String value = StringUtils.join(namespaces, ',');
            return value;
        } else {
            log.error("Invalid input schema, invalid namespaces value found");
            displayUserError("WARNING", "Invalid schema, Illegal format " + namespaces.getClass()
                    + " value found under key : " + JSON_SCHEMA_NAMESPACES);
            throw new IllegalArgumentException("Illegal format " + namespaces.getClass()
                    + " value found under key : " + JSON_SCHEMA_NAMESPACES);
        }
    }
    return null;
}

From source file:org.wso2.developerstudio.datamapper.diagram.tree.generator.SchemaTransformer.java

/**
 * Gets the elementIdentifiers value//from w  ww  .j  ava2s  . co  m
 * 
 * @param jsonSchemaMap
 *            schema
 * @return value
 */
@SuppressWarnings("unchecked")
private String getElementIdentifiers(Map<String, Object> jsonSchemaMap) {
    if (jsonSchemaMap.containsKey(JSON_SCHEMA_ELEMENT_IDENTIFIERS)) {
        ArrayList<String> identifiers = (ArrayList<String>) jsonSchemaMap.get(JSON_SCHEMA_ELEMENT_IDENTIFIERS);
        if (identifiers instanceof ArrayList) {
            String value = StringUtils.join(identifiers, ',');
            return value;
        } else {
            log.error("Invalid input schema, invalid element identifiers value found");
            displayUserError("WARNING", "Invalid schema, Illegal format " + identifiers.getClass()
                    + " value found under key : " + JSON_SCHEMA_ELEMENT_IDENTIFIERS);
            throw new IllegalArgumentException("Illegal format " + identifiers.getClass()
                    + " value found under key : " + JSON_SCHEMA_ELEMENT_IDENTIFIERS);
        }

    }
    return null;
}

From source file:org.wso2.developerstudio.datamapper.diagram.tree.generator.SchemaTransformer.java

/**
 * Gets the required value/*from   www  .j a  v  a 2s  .  c  o  m*/
 * 
 * @param jsonSchemaMap
 *            schema
 * @return value
 */
@SuppressWarnings("rawtypes")
private String getRequiredValue(Map<String, Object> jsonSchemaMap) {
    if (jsonSchemaMap.containsKey(JSON_SCHEMA_REQUIRED)) {
        ArrayList type = (ArrayList) jsonSchemaMap.get(JSON_SCHEMA_REQUIRED);
        if (type instanceof ArrayList) {
            String value = StringUtils.join(type, ',');
            return value;
        } else {
            log.error("Invalid input schema, invalid required value found");
            displayUserError("WARNING", "Invalid schema, Illegal format " + type.getClass()
                    + " value found under key : " + JSON_SCHEMA_REQUIRED);
            throw new IllegalArgumentException(
                    "Illegal format " + type.getClass() + " value found under key : " + JSON_SCHEMA_REQUIRED);
        }
    }
    return null;
}