Search in sources :

Example 31 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project pmph by BCSquad.

the class OrgUserController method importExcel.

@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "机构用户管理界面导入Excel文件")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public ResponseBean importExcel(@RequestParam(name = "file") MultipartFile file, HttpServletRequest request) {
    Map<String, Object> map = new HashedMap();
    String sessionId = CookiesUtil.getSessionId(request);
    if (StringUtil.isEmpty(sessionId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.SESSION, CheckedExceptionResult.NULL_PARAM, "用户登陆超时,请重新登陆再试");
    }
    HttpSession session = SessionContext.getSession(sessionId);
    String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
    try {
        List<OrgVO> list = orgUserService.importExcel(file);
        map.put("uuid", uuid);
        map.put("list", list);
        session.setAttribute(uuid, list);
    } catch (CheckedServiceException e) {
        return new ResponseBean(e);
    } catch (IOException e) {
        return new ResponseBean(e);
    }
    return new ResponseBean(map);
}
Also used : OrgVO(com.bc.pmpheep.back.vo.OrgVO) HttpSession(javax.servlet.http.HttpSession) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) IOException(java.io.IOException) HashedMap(org.apache.commons.collections.map.HashedMap) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project cosmic by MissionCriticalCloud.

the class HostResponseTest method testSetDetailsWithoutRootCredentials.

@Test
public void testSetDetailsWithoutRootCredentials() {
    final HostResponse hostResponse = new HostResponse();
    final Map details = new HashMap<>();
    details.put(VALID_KEY, VALID_VALUE);
    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);
}
Also used : HashMap(java.util.HashMap) HashedMap(org.apache.commons.collections.map.HashedMap) Map(java.util.Map) HashMap(java.util.HashMap) HashedMap(org.apache.commons.collections.map.HashedMap) Test(org.junit.Test)

Example 33 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project graylog2-server by Graylog2.

the class InputFacadeTest method resolveForInstallationLookupTable.

@Test
@MongoDBFixtures("InputFacadeTest.json")
public void resolveForInstallationLookupTable() throws NotFoundException {
    when(lookupuptableBuilder.lookupTable("whois")).thenReturn(lookupuptableBuilder);
    when(lookupuptableBuilder.lookupTable("tor-exit-node-list")).thenReturn(lookupuptableBuilder);
    when(lookupuptableBuilder.build()).thenReturn(lookupTable);
    when(lookupTableService.newBuilder()).thenReturn(lookupuptableBuilder);
    when(lookupTableService.hasTable("whois")).thenReturn(true);
    when(lookupTableService.hasTable("tor-exit-node-list")).thenReturn(true);
    final Input input = inputService.find("5ae2eb0a3d27464477f0fd8b");
    final Map<String, Object> lookupTableConfig = new HashedMap(1);
    lookupTableConfig.put("lookup_table_name", "tor-exit-node-list");
    final ConverterEntity converterEntity = ConverterEntity.create(ValueReference.of(Converter.Type.LOOKUP_TABLE.name()), ReferenceMapUtils.toReferenceMap(lookupTableConfig));
    final List<ConverterEntity> converterEntities = new ArrayList<>(1);
    converterEntities.add(converterEntity);
    final InputWithExtractors inputWithExtractors = InputWithExtractors.create(input, inputService.getExtractors(input));
    final LookupTableExtractor extractor = (LookupTableExtractor) inputWithExtractors.extractors().iterator().next();
    final ExtractorEntity extractorEntity = ExtractorEntity.create(ValueReference.of(extractor.getTitle()), ValueReference.of(extractor.getType()), ValueReference.of(extractor.getCursorStrategy()), ValueReference.of(extractor.getTargetField()), ValueReference.of(extractor.getSourceField()), ReferenceMapUtils.toReferenceMap(extractor.getExtractorConfig()), converterEntities, ValueReference.of(extractor.getConditionType()), ValueReference.of(extractor.getConditionValue()), ValueReference.of(extractor.getOrder()));
    List<ExtractorEntity> extractors = new ArrayList<>();
    extractors.add(extractorEntity);
    InputEntity inputEntity = InputEntity.create(ValueReference.of(input.getTitle()), ReferenceMapUtils.toReferenceMap(input.getConfiguration()), Collections.emptyMap(), ValueReference.of(input.getType()), ValueReference.of(input.isGlobal()), extractors);
    final Entity entity = EntityV1.builder().id(ModelId.of(input.getId())).type(ModelTypes.INPUT_V1).data(objectMapper.convertValue(inputEntity, JsonNode.class)).build();
    final LookupTableEntity whoIsEntity = LookupTableEntity.create(ValueReference.of("whois"), ValueReference.of("title"), ValueReference.of("description"), ValueReference.of("cache_name"), ValueReference.of("dataadapter_name"), ValueReference.of("default_single_value"), ValueReference.of("BOOLEAN"), ValueReference.of("default_multi_value"), ValueReference.of("BOOLEAN"));
    final LookupTableEntity torNodeEntity = LookupTableEntity.create(ValueReference.of("tor-exit-node-list"), ValueReference.of("title"), ValueReference.of("description"), ValueReference.of("cache_name"), ValueReference.of("dataadapter_name"), ValueReference.of("default_single_value"), ValueReference.of("BOOLEAN"), ValueReference.of("default_multi_value"), ValueReference.of("BOOLEAN"));
    final Entity expectedWhoIsEntity = EntityV1.builder().id(ModelId.of("dead-beef")).data(objectMapper.convertValue(whoIsEntity, JsonNode.class)).type(ModelTypes.LOOKUP_TABLE_V1).build();
    final Entity expectedTorEntity = EntityV1.builder().id(ModelId.of("dead-feed")).data(objectMapper.convertValue(torNodeEntity, JsonNode.class)).type(ModelTypes.LOOKUP_TABLE_V1).build();
    final EntityDescriptor whoisDescriptor = expectedWhoIsEntity.toEntityDescriptor();
    final EntityDescriptor torDescriptor = expectedTorEntity.toEntityDescriptor();
    final Map<EntityDescriptor, Entity> entityDescriptorEntityMap = new HashMap<>(2);
    entityDescriptorEntityMap.put(whoisDescriptor, expectedWhoIsEntity);
    entityDescriptorEntityMap.put(torDescriptor, expectedTorEntity);
    Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), entityDescriptorEntityMap);
    assertThat(graph.nodes()).contains(expectedWhoIsEntity);
    assertThat(graph.nodes()).contains(expectedTorEntity);
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) ConverterEntity(org.graylog2.contentpacks.model.entities.ConverterEntity) InputEntity(org.graylog2.contentpacks.model.entities.InputEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) ExtractorEntity(org.graylog2.contentpacks.model.entities.ExtractorEntity) LookupTableEntity(org.graylog2.contentpacks.model.entities.LookupTableEntity) GrokPatternEntity(org.graylog2.contentpacks.model.entities.GrokPatternEntity) HashMap(java.util.HashMap) LookupTableExtractor(org.graylog2.inputs.extractors.LookupTableExtractor) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) RawUDPInput(org.graylog2.inputs.raw.udp.RawUDPInput) Input(org.graylog2.inputs.Input) FakeHttpMessageInput(org.graylog2.inputs.random.FakeHttpMessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) LookupTableEntity(org.graylog2.contentpacks.model.entities.LookupTableEntity) ConverterEntity(org.graylog2.contentpacks.model.entities.ConverterEntity) ExtractorEntity(org.graylog2.contentpacks.model.entities.ExtractorEntity) InputEntity(org.graylog2.contentpacks.model.entities.InputEntity) HashedMap(org.apache.commons.collections.map.HashedMap) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 34 with HashedMap

use of org.apache.commons.collections.map.HashedMap in project cloudstack by apache.

the class HostResponseTest method testSetDetailsWithoutRootCredentials.

@Test
public void testSetDetailsWithoutRootCredentials() {
    final HostResponse hostResponse = new HostResponse();
    final Map details = new HashMap<>();
    details.put(VALID_KEY, VALID_VALUE);
    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);
}
Also used : HashMap(java.util.HashMap) HashedMap(org.apache.commons.collections.map.HashedMap) Map(java.util.Map) HashMap(java.util.HashMap) HashedMap(org.apache.commons.collections.map.HashedMap) Test(org.junit.Test)

Aggregations

HashedMap (org.apache.commons.collections.map.HashedMap)34 Test (org.junit.Test)14 Map (java.util.Map)13 HashMap (java.util.HashMap)10 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 File (java.io.File)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 EmailPool (com.bonree.brfs.email.EmailPool)2 ManagerContralFactory (com.bonree.brfs.schedulers.ManagerContralFactory)2 Date (java.util.Date)2 List (java.util.List)2 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)2 SearchResponse (org.elasticsearch.action.search.SearchResponse)2 Terms (org.elasticsearch.search.aggregations.bucket.terms.Terms)2 OrgVO (com.bc.pmpheep.back.vo.OrgVO)1 ProductType (com.bc.pmpheep.back.vo.ProductType)1 Service (com.bonree.brfs.common.service.Service)1