org.apache.commons.collections.map.HashedMap Java Examples

The following examples show how to use org.apache.commons.collections.map.HashedMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationEntityServiceJDBCImplTest.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelApplicationEntity() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    siteEntityService.create(siteEntity);
    ApplicationDesc applicationDesc = applicationProviderService.getApplicationDescByType("TEST_APP");


    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    applicationEntityService.create(applicationEntity);
    Collection<ApplicationEntity> results = applicationEntityService.findAll();
    Assert.assertEquals(1, results.size());
    applicationEntityService.delete(applicationEntity);
    results = applicationEntityService.findAll();
    Assert.assertEquals(0, results.size());
}
 
Example #2
Source File: TestApplicationHealthCheckServiceImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
public Collection<ApplicationEntity> generateCollections() {
    Collection<ApplicationEntity> entities = new ArrayList<>();
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("TEST_APPLICATION");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    applicationEntity.setAppId("appId");
    entities.add(applicationEntity);
    return entities;
}
 
Example #3
Source File: UpLoadController.java    From hdw-dubbo with Apache License 2.0 6 votes vote down vote up
/**
 * 多文件上传到FastDFS
 *
 * @param multipartFiles
 * @return
 */
public List<Map<String, String>> uploadsToFastDFS(MultipartFile[] multipartFiles) {
    List<Map<String, String>> list = new ArrayList<>();
    if (multipartFiles != null && multipartFiles.length > 0) {
        for (MultipartFile file : multipartFiles) {
            try {
                String fileName = file.getOriginalFilename();
                StorePath storePath = fastFileStorageClient.uploadFile(IOUtils.toByteArray(file.getInputStream()), FilenameUtils.getExtension(file.getOriginalFilename()));
                System.out.println("上传文件路径:" + storePath.getFullPath());
                log.info("文件分组:" + storePath.getGroup() + "上传文件路径:" + storePath.getFullPath());
                String path = fdfsFileUploadServer + "/" + storePath.getFullPath();
                Map<String, String> params = new HashedMap();
                params.put("fileName", fileName);
                params.put("filePath", path);
                list.add(params);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return list;
}
 
Example #4
Source File: HostResponseTest.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetDetailsWithRootCredentials() {

    final HostResponse hostResponse = new HostResponse();
    final Map details = new HashMap<>();

    details.put(VALID_KEY, VALID_VALUE);
    details.put("username", "test");
    details.put("password", "password");

    final Map expectedDetails = new HashedMap();
    expectedDetails.put(VALID_KEY, VALID_VALUE);

    hostResponse.setDetails(details);
    final Map actualDetails = hostResponse.getDetails();

    assertTrue(details != actualDetails);
    assertEquals(expectedDetails, actualDetails);

}
 
Example #5
Source File: NoBootTest.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Test
public void test2222() {
    Map<InjectionFieldPo, String> map = new HashedMap();

    InjectionFieldPo a = new InjectionFieldPo();
    a.setApi("aa");
    a.setMethod("bb");
    a.setKey("vv");

    InjectionFieldPo b = new InjectionFieldPo();
    b.setApi("aa");
    b.setMethod("bb");
    b.setKey("aaaa");

    map.put(a, "1");
    map.put(b, "2");

    System.out.println(map);
}
 
Example #6
Source File: UpLoadController.java    From hdw-dubbo with Apache License 2.0 6 votes vote down vote up
/**
 * 上传文件到FastDFS
 *
 * @param localFilePath
 * @return
 * @throws RuntimeException
 */
public Map<String, String> uploadToFastDFS(String localFilePath) {
    Map<String, String> params = new HashedMap();
    String path = "";
    try {
        byte[] bytes = getBytes(localFilePath);
        String fileName = "";
        if ((localFilePath != null) && (localFilePath.length() > 0)) {
            int dot = localFilePath.lastIndexOf(File.separator);
            if ((dot > -1) && (dot < (localFilePath.length() - 1))) {
                fileName = localFilePath.substring(dot + 1, localFilePath.length());
            }
        }
        StorePath storePath = fastFileStorageClient.uploadFile(bytes, FilenameUtils.getExtension(fileName));
        System.out.println("上传文件路径:" + storePath.getFullPath());
        log.info("文件分组:" + storePath.getGroup() + "上传文件路径:" + storePath.getFullPath());
        path = fdfsFileUploadServer + "/" + storePath.getFullPath();
        params.put("fileName", fileName);
        params.put("filePath", path);
    } catch (Exception e) {
        e.printStackTrace();
        log.error(e.getMessage());
    }
    return params;
}
 
Example #7
Source File: GramProcessor.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Deprecated
public Map<String, NGrams> calculateByPackage(List<CtType<?>> all) throws JSAPException {

	Map<String, NGrams> result = new HashedMap();
	CodeParserLauncher ingp = new CodeParserLauncher<>(ingredientProcessor);
	int allElements = 0;

	for (CtType<?> ctType : all) {
		NGrams ns = new NGrams();
		CtPackage parent = (CtPackage) ctType.getParent(CtPackage.class);
		if (!result.containsKey(parent.getQualifiedName())) {
			allElements += getNGramsFromCodeElements(parent, ns, ingp);
			result.put(parent.getQualifiedName(), ns);
		}
	}
	logger.debug("allElements " + allElements);
	return result;
}
 
Example #8
Source File: FlinkerJobUtil.java    From DataLink with Apache License 2.0 6 votes vote down vote up
/**
 * 动态获取一个datax admin机器的ip,选择方式是遍历所有的datax admin机器,然后找到一台可用内存最大的机器
 * @return
 */
public static String dynamicChoosenDataxMacheine() {
    List<String> addresses = getDataxMachineAddress();
    Map<String,FlinkerMachineInfo> map = new HashedMap();
    String iteratorAddress = "";
    long lastIteratorMaxMemory = Long.MAX_VALUE;
    for(int i=0;i<addresses.size();i++) {
        FlinkerMachineInfo info = getDataxMachineInfo(addresses.get(i));
        long currentFreeMemory = info.getFreeMemory();
        if(i==0) {
            iteratorAddress = addresses.get(i);
            lastIteratorMaxMemory = currentFreeMemory;
        } else {
            if(lastIteratorMaxMemory < currentFreeMemory) {
                iteratorAddress = addresses.get(i);
                lastIteratorMaxMemory = currentFreeMemory;
            }
        }
    }

    if(StringUtils.isBlank(iteratorAddress)) {
        logger.error("can not get dynamic datax machine info ");
    }
    return iteratorAddress;
}
 
Example #9
Source File: TemporalEvaluatorsTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
public TemporalEvaluatorsTest() {
  super();

  factory = new StreamFactory();

  factory.withFunctionName(TemporalEvaluatorYear.FUNCTION_NAME,  TemporalEvaluatorYear.class);
  factory.withFunctionName(TemporalEvaluatorMonth.FUNCTION_NAME, TemporalEvaluatorMonth.class);
  factory.withFunctionName(TemporalEvaluatorDay.FUNCTION_NAME,   TemporalEvaluatorDay.class);
  factory.withFunctionName(TemporalEvaluatorDayOfYear.FUNCTION_NAME,   TemporalEvaluatorDayOfYear.class);
  factory.withFunctionName(TemporalEvaluatorHour.FUNCTION_NAME,   TemporalEvaluatorHour.class);
  factory.withFunctionName(TemporalEvaluatorMinute.FUNCTION_NAME,   TemporalEvaluatorMinute.class);
  factory.withFunctionName(TemporalEvaluatorSecond.FUNCTION_NAME,   TemporalEvaluatorSecond.class);
  factory.withFunctionName(TemporalEvaluatorEpoch.FUNCTION_NAME,   TemporalEvaluatorEpoch.class);
  factory.withFunctionName(TemporalEvaluatorWeek.FUNCTION_NAME,   TemporalEvaluatorWeek.class);
  factory.withFunctionName(TemporalEvaluatorQuarter.FUNCTION_NAME,   TemporalEvaluatorQuarter.class);
  factory.withFunctionName(TemporalEvaluatorDayOfQuarter.FUNCTION_NAME,   TemporalEvaluatorDayOfQuarter.class);

  values = new HashedMap();
}
 
Example #10
Source File: ConsumeIndexQueryHandler.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public Command handle(Transport transport, Command command) throws TransportException {
    ConsumeIndexQueryRequest request = (ConsumeIndexQueryRequest)command.getPayload();
    if (request == null) return null;

    Map<String, List<Integer>> indexTopicPartitions = request.getTopicPartitions();
    Map<String, Map<Integer, IndexMetadataAndError>> topicPartitionIndex = new HashedMap();
    String app = request.getApp();
    for (String topic : indexTopicPartitions.keySet()) {
        List<Integer> partitions = indexTopicPartitions.get(topic);
        Map<Integer, IndexMetadataAndError> partitionIndexes = new HashedMap();
        for (int partition : partitions) {
            long index = getConsumerIndex(topic, (short)partition, app);
            IndexMetadataAndError indexMetadataAndError = new IndexMetadataAndError(index, "", (short) JoyQueueCode.SUCCESS.getCode());
            partitionIndexes.put(partition, indexMetadataAndError);
        }
        topicPartitionIndex.put(topic, partitionIndexes);
    }
    ConsumeIndexQueryResponse response = new ConsumeIndexQueryResponse(topicPartitionIndex);
    JoyQueueHeader header = new JoyQueueHeader(Direction.RESPONSE, QosLevel.ONE_WAY, CommandType.CONSUME_INDEX_QUERY_RESPONSE);
    return new Command(header, response);
}
 
Example #11
Source File: IndexStoreRequestDecoder.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public Object decode(final JoyQueueHeader header, final ByteBuf buffer) throws Exception {
    Map<String, Map<Integer, IndexAndMetadata>> indexMetadata = new HashedMap();
    String app = Serializer.readString(buffer, Serializer.SHORT_SIZE);
    int topics = buffer.readInt();
    for (int i = 0; i < topics; i++) {
        String topic = Serializer.readString(buffer, Serializer.SHORT_SIZE);
        Map<Integer, IndexAndMetadata> partitionMetadata = new HashedMap();
        int partitions = buffer.readInt();
        for (int j = 0; j < partitions; j++) {
            int partition = buffer.readInt();
            long index = buffer.readLong();
            String metadata = Serializer.readString(buffer, Serializer.SHORT_SIZE);
            long indexCacheRetainTime = buffer.readLong();
            long indexCommitTime = buffer.readLong();
            IndexAndMetadata indexAndMetadata = new IndexAndMetadata(index, metadata);
            partitionMetadata.put(partition, indexAndMetadata);
        }
        indexMetadata.put(topic, partitionMetadata);
    }
    return new ConsumeIndexStoreRequest(app, indexMetadata);
}
 
Example #12
Source File: IndexQueryRequestDecoder.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public Object decode(JoyQueueHeader header, ByteBuf buffer) throws Exception {
    Map<String, List<Integer>> indexTopicPartitions = new HashedMap();
    String groupId = Serializer.readString(buffer, Serializer.SHORT_SIZE);
    int topics = buffer.readInt();
    for (int i = 0; i < topics; i++) {
        String topic = Serializer.readString(buffer, Serializer.SHORT_SIZE);
        List<Integer> partitions = new ArrayList<>();
        int partitionNum = buffer.readInt();
        for (int j = 0; j < partitionNum; j++) {
            partitions.add(buffer.readInt());
        }
        indexTopicPartitions.put(topic, partitions);
    }
    return new ConsumeIndexQueryRequest(groupId, indexTopicPartitions);
}
 
Example #13
Source File: UpLoadController.java    From hdw-dubbo with Apache License 2.0 6 votes vote down vote up
/**
 * 上传文件到FastDFS
 *
 * @param file
 * @return
 */
public Map<String, String> uploadToFastDFS(File file) {
    Map<String, String> params = new HashedMap();
    String path = "";
    try {
        String fileName = file.getName();
        StorePath storePath =
                fastFileStorageClient.uploadFile(IOUtils.toByteArray(new
                        FileInputStream(file)), FilenameUtils.getExtension(file.getName()));
        System.out.println("上传文件路径:" + storePath.getFullPath());
        log.info("文件分组:" + storePath.getGroup() + "上传文件路径:" + storePath.getFullPath());
        path = fdfsFileUploadServer + "/" + storePath.getFullPath();
        params.put("fileName", fileName);
        params.put("filePath", path);
    } catch (Exception e) {
        e.printStackTrace();
        log.error(e.getMessage());
    }
    return params;
}
 
Example #14
Source File: NoBootTest.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@Test
public void test2222() {
    Map<InjectionFieldPo, String> map = new HashedMap();

    InjectionFieldPo a = new InjectionFieldPo();
    a.setApi("aa");
    a.setMethod("bb");
    a.setKey("vv");

    InjectionFieldPo b = new InjectionFieldPo();
    b.setApi("aa");
    b.setMethod("bb");
    b.setKey("aaaa");

    map.put(a, "1");
    map.put(b, "2");

    System.out.println(map);
}
 
Example #15
Source File: DataSourceService.java    From DBus with Apache License 2.0 6 votes vote down vote up
/**
 * resource页的搜索
 *
 * @param dsName 若为空,则返回所有DataSource信息
 * @return
 */
public PageInfo<Map<String, Object>> search(int pageNum, int pageSize, String dsName,
                                            String sortBy, String order, String dsType) {
    Map<String, Object> param = new HashedMap();
    param.put("dsName", dsName == null ? dsName : dsName.trim());
    param.put("sortBy", sortBy == null ? sortBy : sortBy.trim());
    param.put("dsType", dsType == null ? dsType : dsType.trim());
    param.put("order", order);

    PageHelper.startPage(pageNum, pageSize);
    List<Map<String, Object>> dataSources = mapper.search(param);
    try {
        // 获取各数据线Topology运行情况
        stormTopoHelper.populateToposToDs(dataSources);
    } catch (Exception e) {
        logger.warn("Get Storm Rest API failed. Can't access Topology running status!", e);
    }
    return new PageInfo<>(dataSources);
}
 
Example #16
Source File: JShellQueryFunction.java    From HolandaCatalinaFw with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    Map<String,Object> params = new HashedMap();
    params.put("param1", 10);


    JShell jShell = JShell.create();
    jShell.eval("import java.util.Date;");
    jShell.eval("import java.util.Map;");
    jShell.eval("import java.util.HashMap;");
    jShell.eval("int i = 0;");
    jShell.eval("i = i + 10;");
    jShell.eval("Map<String,Object> map1 = new HashMap<>();");
    jShell.eval("map1.put(\"field\", new Date());");
    jShell.variables().map(x -> x.name()).forEach(System.out::println);
    jShell.variables().map(x -> jShell.varValue(x)).forEach(System.out::println);
}
 
Example #17
Source File: ApplicationEntityServiceJDBCImplTest.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testInsertApplicationEntityFail() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    siteEntityService.create(siteEntity);
    ApplicationDesc applicationDesc = applicationProviderService.getApplicationDescByType("TEST_APP");

    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    applicationEntityService.create(applicationEntity);
    applicationEntityService.create(applicationEntity);
}
 
Example #18
Source File: ProjectTableService.java    From DBus with Apache License 2.0 6 votes vote down vote up
public PageInfo<Map<String, Object>> queryResource(String dsName,
                                                   String schemaName,
                                                   String tableName,
                                                   Integer pageNum,
                                                   Integer pageSize,
                                                   Integer projectId,
                                                   Integer topoId) {
    Map<String, Object> param = new HashedMap();
    param.put("dsName", dsName == null ? dsName : dsName.trim());
    param.put("schemaName", schemaName == null ? schemaName : schemaName.trim());
    param.put("tableName", tableName == null ? tableName : tableName.trim());
    param.put("projectId", projectId);
    param.put("topoId", topoId);

    PageHelper.startPage(pageNum, pageSize);
    //查询到project下所有resource信息
    List<Map<String, Object>> resources = resourceMapper.searchTableResource(param);
    return new PageInfo(resources);
}
 
Example #19
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    ApplicationEntity entity2 = entity;
    configure.put("c", "d");
    entity2.setContext(configure);
    ApplicationEntity resultEntity = applicationEntityService.update(entity2);
    org.junit.Assert.assertEquals(2, resultEntity.getContext().size());
    Collection collection = applicationEntityService.findAll();
    Assert.assertEquals(1, collection.size());
}
 
Example #20
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testDelete() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    ApplicationEntity resultEntity = applicationEntityService.delete(entity);
    Assert.assertEquals(resultEntity, entity);
}
 
Example #21
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetByUUIDOrAppIdNullUUID() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    String appId = entity.getAppId();
    ApplicationEntity resultEntity = applicationEntityService.getByUUIDOrAppId(null, appId);
    Assert.assertNotNull(resultEntity);
}
 
Example #22
Source File: ProjectTableService.java    From DBus with Apache License 2.0 6 votes vote down vote up
public Map<Integer, Set<String>> getExistedTopicsByProjectId(Long projectId) {
    Map<Integer, Set<String>> topicsGroupedBySink = new HashedMap();
    List<Map<String, Object>> resultMap = projectTopoTableMapper.getExistedTopicsByProjectId(projectId);
    for (Map<String, Object> topicDataMap : resultMap) {
        Integer sinkId = (Integer) topicDataMap.get("sink_id");
        String outPutTopic = (String) topicDataMap.get("output_topic");
        if (topicsGroupedBySink.containsKey(sinkId)) {
            topicsGroupedBySink.get(sinkId).add(outPutTopic);
        } else {
            Set<String> topicsOfSink = new HashSet<>();
            topicsOfSink.add(outPutTopic);
            topicsGroupedBySink.put(sinkId, topicsOfSink);
        }
    }
    return topicsGroupedBySink;
}
 
Example #23
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetByUUIDOrAppIdWhenNullAppId() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    String uuid = entity.getUuid();
    ApplicationEntity resultEntity = applicationEntityService.getByUUIDOrAppId(uuid, null);
    Assert.assertNotNull(resultEntity);
}
 
Example #24
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetBySiteIdAndAppType() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    Assert.assertNotNull(entity);
    String siteId = entity.getSite().getSiteId();
    String appType = entity.getDescriptor().getType();
    ApplicationEntity resultEntity = applicationEntityService.getBySiteIdAndAppType(siteId, appType);
    Assert.assertNotNull(resultEntity);
}
 
Example #25
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindBySiteId() throws EntityNotFoundException {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    Assert.assertNotNull(entity);
    String siteId = entity.getSite().getSiteId();
    Collection resultEntities = applicationEntityService.findBySiteId(siteId);
    Assert.assertEquals(1, resultEntities.size());
}
 
Example #26
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindByUUID() throws EntityNotFoundException {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    String uuid = entity.getUuid();
    ApplicationEntity resultEntity = applicationEntityService.getByUUID(uuid);
    Assert.assertNotNull(resultEntity);
}
 
Example #27
Source File: TestApplicationEntityServiceMemoryImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreate() {
    SiteEntity siteEntity = new SiteEntity();
    siteEntity.setSiteId("testsiteid");
    siteEntity.setSiteName("testsitename");
    siteEntity.setDescription("testdesc");
    ApplicationDesc applicationDesc = new ApplicationDesc();
    applicationDesc.setType("type1");
    ApplicationEntity applicationEntity = new ApplicationEntity();
    applicationEntity.setSite(siteEntity);
    applicationEntity.setDescriptor(applicationDesc);
    applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
    applicationEntity.setJarPath(applicationDesc.getJarPath());
    Map<String, Object> configure = new HashedMap();
    configure.put("a", "b");
    applicationEntity.setConfiguration(configure);
    applicationEntity.setContext(configure);
    ApplicationEntity entity = applicationEntityService.create(applicationEntity);
    System.out.println(entity.getUuid());
    Assert.assertNotNull(entity);
}
 
Example #28
Source File: CollaborationTagStore.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private void validateTag(CollaborationTag collaborationTag) {
  // tags must be unique and MAX_TAG_LENGTH characters max length
  final Map<String, Boolean> valueMap = new HashedMap();

  for (String tag : collaborationTag.getTagsList()) {
    if (tag.length() > MAX_TAG_LENGTH) {
      throw UserException.validationError()
        .message("Tags must be at most %s characters in length, but found [%s] which is [%s] long.", MAX_TAG_LENGTH, tag, tag.length())
        .build(logger);
    }

    if (valueMap.containsKey(tag)) {
      throw UserException.validationError()
        .message("Tags must be unique but found multiple instances of [%s].", tag)
        .build(logger);
    }

    valueMap.put(tag, true);
  }
}
 
Example #29
Source File: SelectController.java    From cjs_ssms with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 数据表grid查询 It's not good enough
 * @param pageIndex
 * @param pageSize
 * @param paramsMap 给criteria添加参数使用
 * @return
 */
private Map<String, Object> getGrids(int pageIndex, int pageSize, HashMap<String, String> paramsMap) {
  PageRowBounds rowBounds = new PageRowBounds(pageIndex+1, pageSize);
  SqlSession sqlSession = MybatisHelper.getSqlSession();
  Mapper mapper = (Mapper) sqlSession.getMapper(UUserMapper.class);
  Example example = new Example(UUser.class);
  Example.Criteria criteria = example.createCriteria();
  /*criteria增加条件...*/
  List<UUser> users = (List<UUser>) mapper.selectByExampleAndRowBounds(example, rowBounds);

  /*4.构造适合miniui_grid展示的map*/
  Map<String, Object> map_grid = new HashedMap();
  map_grid.put("total", users.size());
  map_grid.put("data", users);

  return map_grid;
}
 
Example #30
Source File: UserFrontController.java    From cjs_ssms with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 注册
 * JavaBean: User这种的bean会自动返回给前端
 *
 * @param user
 * @param model
 * @param response
 */
@RequestMapping("/register")
public void register(UUser user, Model model, HttpServletResponse response) {
  Map<String, Object> remap = new HashedMap();
  try {
    boolean b = userFService.registerUser(user);
    if (b) {
      log.info("注册普通用户" + user.getUsername() + "成功。");
      remap.put("msg", "恭喜您," + user.getUsername() + "注册成功。");
      HttpRespUtil.respJson(StatusEnum.SUCCESS, remap, response);
    } else {
      remap.put("msg", "用户名已存在。");
      HttpRespUtil.respJson(StatusEnum.SUCCESS, remap, response);
    }

  } catch (Exception e) {
    log.debug("注册普通用户" + user.getUsername() + "异常");
    remap.put("msg","注册普通用户异常");
    HttpRespUtil.respJson(StatusEnum.FAIL, remap, response);
    e.printStackTrace();
  }
}