java.util.HashMap Java Examples

The following examples show how to use java.util.HashMap. 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: InnerLoggerFactory.java    From rocketmq-read with Apache License 2.0 7 votes vote down vote up
private static void objectArrayAppend(StringBuilder sbuf, Object[] a, Map<Object[], Object> seenMap) {
    if (seenMap == null) {
        seenMap = new HashMap<Object[], Object>();
    }
    sbuf.append('[');
    if (!seenMap.containsKey(a)) {
        seenMap.put(a, null);
        int len = a.length;

        for (int i = 0; i < len; ++i) {
            deeplyAppendParameter(sbuf, a[i], seenMap);
            if (i != len - 1) {
                sbuf.append(", ");
            }
        }

        seenMap.remove(a);
    } else {
        sbuf.append("...");
    }

    sbuf.append(']');
}
 
Example #2
Source File: MessageContextFirstHandler.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(SOAPMessageContext context) {
    boolean isOutbound = (boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (isOutbound) {
        @SuppressWarnings("unchecked")
        Map<String, List<String>> headerMap = (Map<String, List<String>>)context
            .get(MessageContext.HTTP_REQUEST_HEADERS);
        if (headerMap == null) {
            headerMap = new HashMap<>();
        }
        // Add custom header.
        headerMap.put("MY_HEADER", Arrays.asList("FIRST_VALUE"));
        context.put(MessageContext.HTTP_REQUEST_HEADERS, headerMap);
    }
    return true;
}
 
Example #3
Source File: PayInPaymentDetailsBankWire.java    From mangopay2-java-sdk with MIT License 6 votes vote down vote up
/**
 * Gets map which property is an object and what type of object.
 *
 * @return Collection of field name-field type pairs.
 */
@Override
public Map<String, Type> getSubObjects() {

    HashMap<String, Type> result = new HashMap<>();

    result.put("DeclaredDebitedFunds", Money.class);
    result.put("DeclaredFees", Money.class);
    result.put("BankAccount", BankAccount.class);

    return result;
}
 
Example #4
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Named("remote") @Singleton @Provides BundleDataSource providesRemoteBundleDataSource(
    @Named("mature-pool-v7")
        BodyInterceptor<cm.aptoide.pt.dataprovider.ws.v7.BaseBody> bodyInterceptorPoolV7,
    @Named("default") OkHttpClient okHttpClient, Converter.Factory converter,
    BundlesResponseMapper mapper, TokenInvalidator tokenInvalidator,
    @Named("default") SharedPreferences sharedPreferences, AptoideAccountManager accountManager,
    PackageRepository packageRepository, Database database, IdsRepository idsRepository,
    QManager qManager, Resources resources, WindowManager windowManager,
    ConnectivityManager connectivityManager,
    AdsApplicationVersionCodeProvider adsApplicationVersionCodeProvider,
    OemidProvider oemidProvider, AppBundlesVisibilityManager appBundlesVisibilityManager,
    StoreCredentialsProvider storeCredentialsProvider) {
  return new RemoteBundleDataSource(5, new HashMap<>(), bodyInterceptorPoolV7, okHttpClient,
      converter, mapper, tokenInvalidator, sharedPreferences, new WSWidgetsUtils(),
      storeCredentialsProvider, idsRepository,
      AdNetworkUtils.isGooglePlayServicesAvailable(application.getApplicationContext()),
      oemidProvider.getOemid(), accountManager,
      qManager.getFilters(ManagerPreferences.getHWSpecsFilter(sharedPreferences)), resources,
      windowManager, connectivityManager, adsApplicationVersionCodeProvider, packageRepository,
      10, 10, appBundlesVisibilityManager);
}
 
Example #5
Source File: CountryListLoader.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ArrayList<Map<String, String>> loadInBackground() {
  Set<String> regions                    = PhoneNumberUtil.getInstance().getSupportedRegions();
  ArrayList<Map<String, String>> results = new ArrayList<>(regions.size());

  for (String region : regions) {
    Map<String, String> data = new HashMap<>(2);
    data.put("country_name", PhoneNumberFormatter.getRegionDisplayName(region));
    data.put("country_code", "+" +PhoneNumberUtil.getInstance().getCountryCodeForRegion(region));
    results.add(data);
  }

  Collections.sort(results, new RegionComparator());

  return results;
}
 
Example #6
Source File: BestConf.java    From bestconf with Apache License 2.0 5 votes vote down vote up
public static Map<Attribute, Double> instanceToMap(Instance ins){
	HashMap<Attribute, Double> retval = new HashMap<Attribute, Double>();
	Enumeration<Attribute> enu = ins.enumerateAttributes();
	while(enu.hasMoreElements()){
		Attribute temp = enu.nextElement();
		retval.put(temp, ins.value(temp));
	}
	return retval;
}
 
Example #7
Source File: DistributedLogTool.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
private Map<BookieSocketAddress, Integer> getBookieStats(LogSegmentMetadata segment) throws Exception {
    Map<BookieSocketAddress, Integer> stats = new HashMap<BookieSocketAddress, Integer>();
    LedgerHandle lh = bkc.client().get().openLedgerNoRecovery(segment.getLogSegmentId(),
            BookKeeper.DigestType.CRC32, getConf().getBKDigestPW().getBytes(UTF_8));
    long eidFirst = 0;
    for (SortedMap.Entry<Long, ArrayList<BookieSocketAddress>>
            entry : LedgerReader.bookiesForLedger(lh).entrySet()) {
        long eidLast = entry.getKey().longValue();
        long count = eidLast - eidFirst + 1;
        for (BookieSocketAddress bookie : entry.getValue()) {
            merge(stats, bookie, (int) count);
        }
        eidFirst = eidLast;
    }
    return stats;
}
 
Example #8
Source File: DbWithRelocationTest.java    From zserio with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Before
public void setUp() throws IOException, SQLException
{
    FileUtil.deleteFileIfExists(europeDbFile);
    europeDb = new EuropeDb(EUROPE_DB_FILE_NAME);
    europeDb.createSchema();

    FileUtil.deleteFileIfExists(americaDbFile);
    final Map<String, String> tableToDbFileNameRelocationMap = new HashMap<String, String>();
    tableToDbFileNameRelocationMap.put(RELOCATED_SLOVAKIA_TABLE_NAME, EUROPE_DB_FILE_NAME);
    tableToDbFileNameRelocationMap.put(RELOCATED_CZECHIA_TABLE_NAME, EUROPE_DB_FILE_NAME);
    americaDb = new AmericaDb(AMERICA_DB_FILE_NAME, tableToDbFileNameRelocationMap);
    americaDb.createSchema();
}
 
Example #9
Source File: PolicyVersionDetail.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * Internal implementation, normal users should not use it.
 */
public void toMap(HashMap<String, String> map, String prefix) {
    this.setParamSimple(map, prefix + "VersionId", this.VersionId);
    this.setParamSimple(map, prefix + "CreateDate", this.CreateDate);
    this.setParamSimple(map, prefix + "IsDefaultVersion", this.IsDefaultVersion);
    this.setParamSimple(map, prefix + "Document", this.Document);

}
 
Example #10
Source File: TaskProcessor.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object setupRequest(String message) {
	Map<String, String> properties = new HashMap<>();
	if (StringUtils.hasText(this.processorProperties.getDataSourceUrl())) {
		properties
			.put("spring_datasource_url", this.processorProperties
				.getDataSourceUrl());
	}
	if (StringUtils
		.hasText(this.processorProperties.getDataSourceDriverClassName())) {
		properties.put("spring_datasource_driverClassName", this.processorProperties
			.getDataSourceDriverClassName());
	}
	if (StringUtils.hasText(this.processorProperties.getDataSourceUserName())) {
		properties.put("spring_datasource_username", this.processorProperties
			.getDataSourceUserName());
	}
	if (StringUtils.hasText(this.processorProperties.getDataSourcePassword())) {
		properties.put("spring_datasource_password", this.processorProperties
			.getDataSourcePassword());
	}
	properties.put("payload", message);

	TaskLaunchRequest request = new TaskLaunchRequest(
		this.processorProperties.getUri(), null, properties, null,
		this.processorProperties.getApplicationName());

	return new GenericMessage<>(request);
}
 
Example #11
Source File: ChannelFactory.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Lookup a product name by label.
 *
 * @param label Product name label to search for.
 * @return Product name if found, null otherwise.
 */
public static ProductName lookupProductNameByLabel(String label) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("label", label);
    return (ProductName)singleton.lookupObjectByNamedQuery(
            "ProductName.findByLabel", params);
}
 
Example #12
Source File: Utils.java    From SocialSDKAndroid with Apache License 2.0 5 votes vote down vote up
public static Map<String, String> jsonToMap(JSONObject val) {
    HashMap map = new HashMap();

    Iterator iterator = val.keys();

    while(iterator.hasNext()) {
        String var4 = (String)iterator.next();
        map.put(var4, val.opt(var4) + "");
    }

    return map;
}
 
Example #13
Source File: ExprManagerUtilTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
@Test
   public void testValidateNodes2( ) throws DataException
{

	ExprManager em = new ExprManager( null , cx);
	Map m = new HashMap( );
	m.put( "COL0",
			new ScriptExpression( "row[\"COL1\"]+row[\"COL2\"]+row[\"COL3\"]" ) );
	m.put( "COL2", new ScriptExpression( "dataSetRow[\"COL2\"]" ) );
	m.put( "COL1",
			new ScriptExpression( "row[\"COL0\"]+row[\"COL3\"]+dataSetRow[\"COL3\"]" ) );
	m.put( "COL3", new ScriptExpression( "row[\"COL2\"]+row[\"COL4\"]" ) );
	m.put( "COL4", new ScriptExpression( "row[\"COL2\"]" ) );

	em.addBindingExpr( null, getBindingMap(m), 0 );
	
	try
	{
		ExprManagerUtil.validateColumnBinding( em, null, cx );
		fail( "Should not arrive here" );
	}
	catch ( DataException e )
	{
	}
}
 
Example #14
Source File: BaseHibernateManager.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void saveOrUpdateLetterGradePercentMapping(final Map<String, Double> gradeMap, final Gradebook gradebook) {
	if(gradeMap == null) {
        throw new IllegalArgumentException("gradeMap is null in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
    }

	final LetterGradePercentMapping lgpm = getLetterGradePercentMappingForGradebook(gradebook);

	if(lgpm == null) {
		final Set<String> keySet = gradeMap.keySet();

		if(keySet.size() != GradebookService.validLetterGrade.length) { //we only consider letter grade with -/+ now.
            throw new IllegalArgumentException("gradeMap doesn't have right size in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
        }
		if(!validateLetterGradeMapping(gradeMap)) {
            throw new IllegalArgumentException("gradeMap contains invalid letter in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
        }

		final HibernateCallback<Void> hcb = session -> {
            final LetterGradePercentMapping lgpm1 = new LetterGradePercentMapping();
            final Map<String, Double> saveMap = new HashMap<>(gradeMap);
            lgpm1.setGradeMap(saveMap);
            lgpm1.setGradebookId(gradebook.getId());
            lgpm1.setMappingType(2);
            session.save(lgpm1);
            return null;
        };
		getHibernateTemplate().execute(hcb);
	}
	else
	{
		udpateLetterGradePercentMapping(gradeMap, gradebook);
	}
}
 
Example #15
Source File: ServiceValuesAccess.java    From mdw with Apache License 2.0 5 votes vote down vote up
protected Map<String,String> getParameters(Map<String,String> headers) {
    Map<String,String> params = new HashMap<String,String>();
    String query = headers.get(Listener.METAINFO_REQUEST_QUERY_STRING);
    if (query == null)
        query = headers.get("request-query-string");
    if (query != null && !query.isEmpty()) {
        for (String pair : query.split("&")) {
            int idx = pair.indexOf("=");
            try {
                params.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"),
                        URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
            }
            catch (UnsupportedEncodingException ex) {
                // as if UTF-8 is going to be unsupported
            }
        }
    }
    return params;
}
 
Example #16
Source File: KnownSaneOptions.java    From swingsane with Apache License 2.0 5 votes vote down vote up
public static boolean isUsingDefaultBlackThreshold(Scanner scanner) {
  HashMap<String, FixedOption> fixedOptions = scanner.getFixedOptions();
  FixedOption fixedOption = fixedOptions.get(SANE_NAME_THRESHOLD);
  if (fixedOption == null) {
    return false;
  }
  return fixedOption.getOptionsOrderValuePair().isActive();
}
 
Example #17
Source File: ObsService.java    From huaweicloud-sdk-java-obs with Apache License 2.0 5 votes vote down vote up
protected boolean doesObjectExistImpl(GetObjectMetadataRequest request) throws ServiceException {
    Map<String, String> headers = new HashMap<String, String>();
    this.transSseCHeaders(request.getSseCHeader(), headers, this.getIHeaders());
    this.transRequestPaymentHeaders(request, headers, this.getIHeaders());

    Map<String, String> params = new HashMap<String, String>();
    if (request.getVersionId() != null) {
        params.put(ObsRequestParams.VERSION_ID, request.getVersionId());
    }
    boolean doesObjectExist = false;
    try {
        Response response = performRestHead(request.getBucketName(), request.getObjectKey(), params, headers);
        if (200 == response.code()) {
            doesObjectExist = true;
        }
    } catch (ServiceException ex) {
        if (404 == ex.getResponseCode()) {
            doesObjectExist = false;
        } else {
            throw ex;
        }
    }
    return doesObjectExist;
}
 
Example #18
Source File: MetadataVisitor.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
private Map<String, String> propertiesToMap(Properties properties) {
    Map<String, String> propertyMap = new HashMap<>();
    if(properties != null) {
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            propertyMap.put(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    return propertyMap;
}
 
Example #19
Source File: MessageHandler.java    From RISE-V2G with MIT License 5 votes vote down vote up
public synchronized V2GMessage getV2GMessage(
		byte[] sessionID, 
		HashMap<String, byte[]> xmlSignatureRefElements,
		ECPrivateKey signaturePrivateKey,
		JAXBElement<? extends BodyBaseType> v2gMessageInstance) {
	return getV2GMessage(sessionID, null, xmlSignatureRefElements, signaturePrivateKey, v2gMessageInstance);
}
 
Example #20
Source File: MailTemplateTest.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Test
public void requestPasswordReset() throws IOException {
    Map<String, Object> ctx = new HashMap<>();

    String username = "test" + UUID.randomUUID().toString();
    UserTO user = new UserTO();
    user.setUsername(username);
    ctx.put("user", user);

    String token = "token " + UUID.randomUUID().toString();
    List<String> input = new ArrayList<>();
    input.add(token);
    ctx.put("input", input);

    String textBody = evaluate(REQUEST_PASSWORD_RESET_TEMPLATE, ctx);

    assertNotNull(textBody);
    assertTrue(textBody.contains("a password reset was requested for " + username + "."));
    assertFalse(textBody.contains(
            "http://localhost:9080/syncope-enduser/app/#!/confirmpasswordreset?token="
            + token));
    assertTrue(textBody.contains(
            "http://localhost:9080/syncope-enduser/app/#!/confirmpasswordreset?token="
            + token.replaceAll(" ", "%20")));
}
 
Example #21
Source File: DistributionalRandomOversampling.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
private static HashMap<Integer,Double> cacheFeatureTSRscore(IIndex index, short poscat) {
	InformationGain ig=new InformationGain();
	HashMap<Integer,Double> cached=new HashMap<>();
	IIntIterator feats=index.getFeatureDB().getFeatures();
	while(feats.hasNext()){
		int featID = feats.next();
		double tsr=ig.compute(poscat, featID, index);
		cached.put(featID, tsr);
	}	
	return cached;
}
 
Example #22
Source File: ExtendedContentDataTypeHelper.java    From datawave with Apache License 2.0 5 votes vote down vote up
protected Map<String,String> getValues(Configuration conf, String prefix) {
    Map<String,String> values = new HashMap<>();
    for (Map.Entry<String,String> entry : conf) {
        String key = entry.getKey();
        if (key.startsWith(prefix)) {
            // if the property is longer than the prefix, then ensure the
            // next character is a '.'
            if (key.length() == prefix.length() || key.charAt(prefix.length()) == '.') {
                values.put(key, entry.getValue());
            }
        }
    }
    return values;
}
 
Example #23
Source File: UsersTest.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateTarget() {
    HugeGraph graph = graph();
    UserManager userManager = graph.userManager();

    HugeTarget target = makeTarget("graph1", "127.0.0.1:8080");
    target.creator("admin");
    Id id = userManager.createTarget(target);

    target = userManager.getTarget(id);
    Assert.assertEquals("graph1", target.name());
    Assert.assertEquals("127.0.0.1:8080", target.url());
    Assert.assertEquals(target.create(), target.update());

    HashMap<String, Object> expected = new HashMap<>();
    expected.putAll(ImmutableMap.of("target_name", "graph1",
                                    "target_graph", "graph1",
                                    "target_url", "127.0.0.1:8080",
                                    "target_creator", "admin"));
    expected.putAll(ImmutableMap.of("target_create", target.create(),
                                    "target_update", target.update(),
                                    "id", target.id()));

    Assert.assertEquals(expected, target.asMap());
}
 
Example #24
Source File: TestClusterManagementWebapp.java    From helix with Apache License 2.0 5 votes vote down vote up
void verifyAddCluster() throws IOException, InterruptedException {
  String httpUrlBase = "http://localhost:" + ADMIN_PORT + "/clusters";
  Map<String, String> paraMap = new HashMap<String, String>();

  paraMap.put(JsonParameters.CLUSTER_NAME, clusterName);
  paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.addCluster);

  Reference resourceRef = new Reference(httpUrlBase);

  Request request = new Request(Method.POST, resourceRef);

  request.setEntity(
      JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
      MediaType.APPLICATION_ALL);
  Response response = _gClient.handle(request);

  Representation result = response.getEntity();
  StringWriter sw = new StringWriter();
  result.write(sw);

  // System.out.println(sw.toString());

  ObjectMapper mapper = new ObjectMapper();
  ZNRecord zn = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
  AssertJUnit.assertTrue(zn.getListField("clusters").contains(clusterName));

}
 
Example #25
Source File: UPB.java    From mobemu with MIT License 5 votes vote down vote up
/**
 * Gets only the valid UPB 2012 trace users (i.e. those who actively
 * participated in the trace and had at least one interest). This function can
 * be modified depending on what is required.
 *
 * @return a map that correlates between the valid user's real ID from the trace
 *         and the newly-assigned one (since the IDs should be consecutive)
 */
private static Map<Integer, Integer> Upb2012GetValidUsers() {
	Map<Integer, Integer> users = new HashMap<>(); // real id / new id

	users.put(0, 0);
	users.put(12, 1);
	users.put(22, 2);
	users.put(14, 3);
	users.put(5, 4);
	users.put(32, 5);
	users.put(7, 6);
	users.put(30, 7);
	users.put(34, 8);
	users.put(31, 9);
	users.put(55, 10);
	users.put(52, 11);
	users.put(33, 12);
	users.put(43, 13);
	users.put(4, 14);
	users.put(15, 15);
	users.put(26, 16);
	users.put(20, 17);
	users.put(29, 18);
	users.put(40, 19);
	users.put(6, 20);
	users.put(45, 21);
	users.put(48, 22);
	users.put(61, 23);

	return users;
}
 
Example #26
Source File: TLDEventDataFilterTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void keep_anyFieldTest() throws ParseException {
    Map<String,Integer> fieldLimits = new HashMap<>(1);
    fieldLimits.put(Constants.ANY_FIELD, 1);
    
    Set<String> blacklist = new HashSet<>();
    blacklist.add("field3");
    
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("field2 == 'bar'");
    
    replayAll();
    
    // expected key structure
    Key key = new Key("row", "dataType" + Constants.NULL + "123.345.456", "field1" + Constants.NULL_BYTE_STRING + "value");
    filter = new TLDEventDataFilter(query, mockAttributeFactory, null, blacklist, 1, -1, fieldLimits, "LIMIT_FIELD", Collections.EMPTY_SET);
    
    assertTrue(filter.keep(key));
    // increments counts = 1
    assertTrue(filter.apply(new AbstractMap.SimpleEntry<>(key, null)));
    assertNull(filter.getSeekRange(key, key.followingKey(PartialKey.ROW), false));
    // does not increment counts so will still return true
    assertTrue(filter.keep(key));
    // increments counts = 2 so rejects based on field filter
    assertFalse(filter.apply(new AbstractMap.SimpleEntry<>(key, null)));
    Range seekRange = filter.getSeekRange(key, key.followingKey(PartialKey.ROW), false);
    assertNotNull(seekRange);
    assertEquals(seekRange.getStartKey().getRow(), key.getRow());
    assertEquals(seekRange.getStartKey().getColumnFamily(), key.getColumnFamily());
    assertEquals(seekRange.getStartKey().getColumnQualifier().toString(), "field1" + "\u0001");
    assertEquals(true, seekRange.isStartKeyInclusive());
    
    // now fails
    assertFalse(filter.keep(key));
    
    verifyAll();
}
 
Example #27
Source File: ChangeActivityStateBuilderImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ChangeActivityStateBuilder processVariable(String processVariableName, Object processVariableValue) {
    if (this.processVariables == null) {
        this.processVariables = new HashMap<>();
    }

    this.processVariables.put(processVariableName, processVariableValue);
    return this;
}
 
Example #28
Source File: BFS.java    From Erdos with MIT License 5 votes vote down vote up
public BFS(IGraph graph_input, IVertex sourceIVertex)
{
    super(graph_input, "Breadth First Search");

    _sourceIVertex = sourceIVertex;
    _D            = new HashMap<>();
    _COLOR        = new HashMap<>();
    _PIE          = new LinkedHashMap<>();
    _Q            = new LinkedList<>();
}
 
Example #29
Source File: SOAPMsgConfigTestCase.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Test
public void changeParamTest() {
    /* Configuration. */
    HashMap<String, String> map = new HashMap<String, String>();
    map.put(KEY_PREFIX + KEY_NAME, KEY_VALUE);
    soapConfig.setParams(map);

    /* Checks that configuration has been processed correctly. */
    map = soapConfig.getParams();
    String value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE));

    /* Positive case. */
    soapConfig.changeParam(KEY_NAME, KEY_VALUE2);
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has been changed.

    /* Negative cases. */
    soapConfig.changeParam(KEY_NAME, null); // Null value.
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has NOT been changed.

    soapConfig.changeParam(null, KEY_VALUE); // Null key.
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has NOT been changed.
}
 
Example #30
Source File: DalConfigure.java    From dal with Apache License 2.0 5 votes vote down vote up
public void validate() throws Exception {
    Set<String> sqlServerSet = new HashSet<>();
    Map<String, Set<String>> connStrMap = new HashMap<>();
    for (DatabaseSet dbSet : databaseSets.values()) {
        IIdGeneratorConfig idGenConfig = dbSet.getIdGenConfig();
        if (null == idGenConfig) {
            continue;
        }
        String dbSetName = dbSet.getName();
        if (dbSet.getDatabaseCategory() == DatabaseCategory.SqlServer) {
            sqlServerSet.add(dbSetName);
            continue;
        }
        String sequenceDbName = idGenConfig.getSequenceDbName();
        Map<String, DataBase> dbs = dbSet.getDatabases();
        if (dbs != null) {
            for (DataBase db : dbs.values()) {
                String connStr = db.getConnectionString();
                Set<String> dbSetsForConnStr = connStrMap.get(connStr);
                if (dbSetsForConnStr != null) {
                    dbSetsForConnStr.add(sequenceDbName);
                } else {
                    dbSetsForConnStr = new HashSet<>();
                    dbSetsForConnStr.add(sequenceDbName);
                    connStrMap.put(connStr, dbSetsForConnStr);
                }
            }
        }
    }
    internalCheck(sqlServerSet, connStrMap);
}