コード例 #1
0
  @org.junit.Test
  public void addCompany() {

    Map<String, Object> fieldMap0 = new HashMap<String, Object>();
    fieldMap0.put("hcCompanyId", "0");
    dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap0);
    String fullUrl0 = wsBaseUrl + "device/company/addCompany";
    WebResource.Builder builder0 = getBuilder(fullUrl0);
    Company Company0 = new Company();
    Company0.setCompanyName("V0");
    Company0.setCompanyId(0 + "");
    BaseResponse response0 = builder0.post(BaseResponse.class, Company0);
    logger.info(response0.getMessage());
    Assert.assertEquals(response0.getCode(), "0000");
    String CompanyName0 =
        dao.getEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap0)
            .getCompanyName();
    Assert.assertEquals(CompanyName0, Company0.getCompanyName());

    Map<String, Object> fieldMap1 = new HashMap<String, Object>();
    fieldMap1.put("hcCompanyId", "1");
    dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap1);
    String fullUrl = wsBaseUrl + "device/company/addCompany";
    WebResource.Builder builder = getBuilder(fullUrl);
    Company Company = new Company();
    Company.setCompanyName("V1");
    Company.setCompanyId("1");
    BaseResponse response = builder.post(BaseResponse.class, Company);
    logger.info(response.getMessage());
    Assert.assertEquals(response.getCode(), "0000");
    String CompanyName =
        dao.getEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap1)
            .getCompanyName();
    Assert.assertEquals(CompanyName, Company.getCompanyName());

    Map<String, Object> fieldMap2 = new HashMap<String, Object>();
    fieldMap2.put("hcCompanyId", "2");
    dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap2);
    String fullUrl2 = wsBaseUrl + "device/company/addCompany";
    WebResource.Builder builder2 = getBuilder(fullUrl2);
    Company Company2 = new Company();
    Company2.setCompanyName("V2");
    Company2.setCompanyId("2");
    BaseResponse response2 = builder2.post(BaseResponse.class, Company2);
    logger.info(response2.getMessage());
    Assert.assertEquals(response2.getCode(), "0000");
    String CompanyName2 =
        dao.getEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Company.class, fieldMap2)
            .getCompanyName();
    Assert.assertEquals(CompanyName2, Company2.getCompanyName());
  }
コード例 #2
0
  @org.junit.Test
  public void testGetTankerList() {
    for (int i = 10; i < 34; i++) {
      Map<String, Object> fieldMap2 = new HashMap<String, Object>();
      fieldMap2.put("stationCode", i + "");
      dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Tanker.class, fieldMap2);
      com.hcwins.vehicle.fleet.entity.mongo.device.Tanker tanker =
          new com.hcwins.vehicle.fleet.entity.mongo.device.Tanker();
      tanker.setStationCode(i + "");
      tanker.setStationName("test_tanker_" + i);
      tankerDao.addEntity(tanker);
    }

    String fullUrl = baseUrl + "device/tanker/getTankerList?stationName=test_tan&pageSize=2000";
    WebResource.Builder builder = getBuilder(fullUrl);
    GetTankerPageResponse response = builder.get(GetTankerPageResponse.class);
    List<Tanker> cardList = response.getData().getTankerList();
    Assert.assertEquals(response.getCode(), "0000");
    Assert.assertEquals(cardList.size(), 24);

    fullUrl = baseUrl + "device/tanker/getTankerList?pageSize=2000";
    builder = getBuilder(fullUrl);
    response = builder.get(GetTankerPageResponse.class);
    cardList = response.getData().getTankerList();
    logger.info(JSONArray.fromObject(cardList).toString());
    Assert.assertEquals(response.getCode(), "0000");
    logger.info("cardList.size : " + cardList.size());
  }
コード例 #3
0
  @org.junit.Test
  public void testAddDevHsbox() {
    addModel();
    addCompany();
    String fullUrl = wsBaseUrl + "device/hsbox/add";
    // 0404131
    Map<String, Object> fieldMap = new HashMap<String, Object>();
    fieldMap.put("hcVehicleId", 404131 + "");
    dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Hsbox.class, fieldMap);
    WebResource.Builder builder = getBuilder(fullUrl);

    Hsbox hsbox = new Hsbox();
    hsbox.setVehicleId(404131 + "");
    hsbox.setBrand("南京普天" + 1);
    hsbox.setCompanyId("1");
    hsbox.setCompanyName("V1");
    hsbox.setModelId(404131 % 3 + "");
    hsbox.setPathLength(null);
    hsbox.setPrecision(0.005d);
    hsbox.setPlateNo("粤404131");
    hsbox.setSerialNo("V50404131");
    hsbox.setRemark(null);
    hsbox.setWorkingPressure(null);
    BaseResponse response = builder.post(BaseResponse.class, hsbox);
    logger.info(response.getMessage());
    if (response.getData() != null)
      logger.info(
          response.getData() instanceof String
              ? response.getData() + ""
              : JSONObject.fromObject(response.getData()).toString());
    Assert.assertEquals(response.getCode(), "0000");

    Map<String, Object> fieldMap2 = new HashMap<String, Object>();
    fieldMap2.put("hcVehicleId", 404131 + "");
    com.hcwins.vehicle.fleet.entity.mongo.device.Hsbox dbHsbox =
        dao.getEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Hsbox.class, fieldMap2);
    Assert.assertEquals(hsbox.getVehicleId(), dbHsbox.getHcVehicleId());
    Assert.assertEquals(hsbox.getPlateNo(), dbHsbox.getPlateNo());
    Assert.assertEquals(hsbox.getPlateNo().substring(1), dbHsbox.getPlateNo().substring(1));

    // 0405052
    fieldMap = new HashMap<String, Object>();
    fieldMap.put("hcVehicleId", 405052 + "");
    dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Hsbox.class, fieldMap);
    builder = getBuilder(fullUrl);

    hsbox = new Hsbox();
    hsbox.setVehicleId(405052 + "");
    hsbox.setBrand("南京普天" + 1);
    hsbox.setCompanyId("1");
    hsbox.setCompanyName("V1");
    hsbox.setModelId(405052 % 3 + "");
    hsbox.setPathLength(null);
    hsbox.setPrecision(0.005d);
    hsbox.setPlateNo("粤405052");
    hsbox.setSerialNo("V50405052");
    hsbox.setRemark(null);
    hsbox.setWorkingPressure(null);
    response = builder.post(BaseResponse.class, hsbox);
    logger.info(response.getMessage());
    if (response.getData() != null)
      logger.info(
          response.getData() instanceof String
              ? response.getData() + ""
              : JSONObject.fromObject(response.getData()).toString());
    Assert.assertEquals(response.getCode(), "0000");

    fieldMap2 = new HashMap<String, Object>();
    fieldMap2.put("hcVehicleId", 405052 + "");
    dbHsbox =
        dao.getEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Hsbox.class, fieldMap2);
    Assert.assertEquals(hsbox.getVehicleId(), dbHsbox.getHcVehicleId());
    Assert.assertEquals(hsbox.getPlateNo(), dbHsbox.getPlateNo());
    Assert.assertEquals(hsbox.getPlateNo().substring(1), dbHsbox.getPlateNo().substring(1));
  }
コード例 #4
0
  @org.junit.Test
  public void addModel() {

    Map<String, Object> fieldMap0 = new HashMap<String, Object>();
    fieldMap0.put("hcModelId", "0");
    dao.deleteEntityByFiled(
        com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap0);
    String fullUrl0 = wsBaseUrl + "device/hsbox/addModel";
    WebResource.Builder builder0 = getBuilder(fullUrl0);
    HsboxModel model0 = new HsboxModel();
    model0.setModelName("V0");
    model0.setUpdateType("TCP");
    model0.setModelId("0");
    model0.setIsAllMachine(true);
    BaseResponse response0 = builder0.post(BaseResponse.class, model0);
    logger.info(response0.getMessage());
    Assert.assertEquals(response0.getCode(), "0000");
    String modelName0 =
        dao.getEntityByFiled(
                com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap0)
            .getModelName();
    Assert.assertEquals(modelName0, model0.getModelName());

    Map<String, Object> fieldMap1 = new HashMap<String, Object>();
    fieldMap1.put("hcModelId", "1");
    dao.deleteEntityByFiled(
        com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap1);
    String fullUrl = wsBaseUrl + "device/hsbox/addModel";
    WebResource.Builder builder = getBuilder(fullUrl);
    HsboxModel model = new HsboxModel();
    model.setModelName("V1");
    model.setUpdateType("HTTP");
    model.setModelId("1");
    model.setIsAllMachine(true);
    BaseResponse response = builder.post(BaseResponse.class, model);
    logger.info(response.getMessage());
    Assert.assertEquals(response.getCode(), "0000");
    String modelName =
        dao.getEntityByFiled(
                com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap1)
            .getModelName();
    Assert.assertEquals(modelName, model.getModelName());

    Map<String, Object> fieldMap2 = new HashMap<String, Object>();
    fieldMap2.put("hcModelId", "2");
    dao.deleteEntityByFiled(
        com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap2);
    String fullUrl2 = wsBaseUrl + "device/hsbox/addModel";
    WebResource.Builder builder2 = getBuilder(fullUrl2);
    HsboxModel model2 = new HsboxModel();
    model2.setModelName("V2");
    model2.setUpdateType("TCP");
    model2.setModelId("2");
    model2.setIsAllMachine(true);
    BaseResponse response2 = builder2.post(BaseResponse.class, model2);
    logger.info(response2.getMessage());
    Assert.assertEquals(response2.getCode(), "0000");
    String modelName2 =
        dao.getEntityByFiled(
                com.hcwins.vehicle.fleet.entity.mongo.device.HsboxModel.class, fieldMap2)
            .getModelName();
    Assert.assertEquals(modelName2, model2.getModelName());
  }