예제 #1
1
 @Test
 public void testPutRemoveGet() {
   Map<Integer, Integer> myMap = new MyMap<>();
   Map<Integer, Integer> control = new HashMap<>();
   for (int i = 0; i < N; i++) {
     int k = random.nextInt();
     int v = random.nextInt();
     myMap.put(k, v);
     control.put(k, v);
   }
   Set<Integer> keysToRemove = new HashSet<>();
   for (int k : control.keySet()) {
     if (random.nextBoolean()) {
       keysToRemove.add(k);
     }
   }
   for (int k : keysToRemove) {
     control.remove(k);
     myMap.remove(k);
   }
   assertEquals(myMap.size(), control.size());
   for (int k : control.keySet()) {
     assertEquals(myMap.get(k), control.get(k));
     int r = random.nextInt();
     assertEquals(myMap.get(r), control.get(r));
   }
 }
예제 #2
0
  @Test
  public void dataset() {
    Document doc =
        Jsoup.parse(
            "<div id=1 data-name=jsoup class=new data-package=jar>Hello</div><p id=2>Hello</p>");
    Element div = doc.select("div").first();
    Map<String, String> dataset = div.dataset();
    Attributes attributes = div.attributes();

    // size, get, set, add, remove
    assertEquals(2, dataset.size());
    assertEquals("jsoup", dataset.get("name"));
    assertEquals("jar", dataset.get("package"));

    dataset.put("name", "jsoup updated");
    dataset.put("language", "java");
    dataset.remove("package");

    assertEquals(2, dataset.size());
    assertEquals(4, attributes.size());
    assertEquals("jsoup updated", attributes.get("data-name"));
    assertEquals("jsoup updated", dataset.get("name"));
    assertEquals("java", attributes.get("data-language"));
    assertEquals("java", dataset.get("language"));

    attributes.put("data-food", "bacon");
    assertEquals(3, dataset.size());
    assertEquals("bacon", dataset.get("food"));

    attributes.put("data-", "empty");
    assertEquals(null, dataset.get("")); // data- is not a data attribute

    Element p = doc.select("p").first();
    assertEquals(0, p.dataset().size());
  }
예제 #3
0
  static {
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs1346.mrc";
    try {
      RawRecordReader rawRecRdr = new RawRecordReader(new FileInputStream(new File(bibFilePath)));
      while (rawRecRdr.hasNext()) {
        RawRecord rawRec = rawRecRdr.next();
        Record rec = rawRec.getAsRecord(true, false, "999", "MARC8");
        String id = rec.getControlNumber();
        // String id = RecordTestingUtils.getRecordIdFrom001(rec);
        ALL_UNMERGED_BIBS.put(id, rec);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    bibFilePath = testDataParentPath + File.separator + "mhldMerged1346.mrc";
    try {
      RawRecordReader rawRecRdr = new RawRecordReader(new FileInputStream(new File(bibFilePath)));
      while (rawRecRdr.hasNext()) {
        RawRecord rawRec = rawRecRdr.next();
        Record rec = rawRec.getAsRecord(true, false, "999", "MARC8");
        String id = rec.getControlNumber();
        // String id = RecordTestingUtils.getRecordIdFrom001(rec);
        ALL_MERGED_BIB_RESULTS.put(id, rec);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
예제 #4
0
  @Test
  public void getProperties() throws Exception {
    final ModuleURN input = new ModuleURN("test:prov:me:A");
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("first", BigDecimal.TEN);
    m.put("second", "next");
    m.put("third", 909);
    // Test a non-empty and an empty map.
    List<Map<String, Object>> maps = Arrays.asList(m, new HashMap<String, Object>());
    for (Map<String, Object> map : maps) {
      final Map<String, Object> output = map;
      testAPI(
          new WSTester<Map<String, Object>>() {
            @Override
            protected Map<String, Object> invokeApi(boolean isNullParams) throws Exception {
              return getClient().getProperties(isNullParams ? null : input);
            }

            @Override
            protected Map<String, Object> setReturnValue(boolean isNullParams) {
              getMockSAService()
                  .setPropertiesOut(isNullParams ? null : new MapWrapper<String, Object>(output));
              return isNullParams ? null : output;
            }

            @Override
            protected void verifyInputParams(boolean isNullParams) throws Exception {
              verifyEquals(isNullParams ? null : input, getMockSAService().getURN());
            }
          });
      resetServiceParameters();
    }
  }
 @Test
 public void testSize() {
   dict = new HashTable<>(31);
   assertEquals(0, dict.size());
   dict.put("duncan", "is a person.");
   assertEquals(1, dict.size());
   dict.put("one", "last time");
   assertEquals(2, dict.size());
   dict.remove("duncan");
   assertEquals(1, dict.size());
   dict.remove("duncan");
   assertEquals(1, dict.size());
 }
예제 #6
0
 public void orderTest() {
   Customer customer = customerDAO.getCustomerById(3);
   List<Commodity> commodityList = commoDAO.getCommoditiesByIdString("2;3;4");
   List<OrderCommodityRel> relationLsit = CommodityListTools.commoToRel(commodityList);
   Order order = new Order(customer, relationLsit, 100);
   Map<Integer, Integer> map = new HashMap<Integer, Integer>();
   map.put(2, 2);
   map.put(3, 4);
   map.put(4, 4);
   order.setBuyNum(map);
   Date date = new Date();
   order.setOrderTime(new Timestamp(date.getTime()));
   orderDAO.createOrder(order);
   System.out.println(order.getOrderId());
 }
예제 #7
0
 @Test
 public void testPutGet() {
   Map<Integer, Integer> myMap = new MyMap<>();
   Map<Integer, Integer> control = new HashMap<>();
   for (int i = 0; i < N; i++) {
     int k = random.nextInt();
     int v = random.nextInt();
     myMap.put(k, v);
     control.put(k, v);
   }
   for (int k : control.keySet()) {
     assertEquals(myMap.get(k), control.get(k));
     int r = random.nextInt();
     assertEquals(myMap.get(r), control.get(r));
   }
 }
 @Test
 public void putToTheMap() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   Map<String, String> clientMap = hClient.getMap("putToTheMap");
   assertEquals(0, clientMap.size());
   String result = clientMap.put("1", "CBDEF");
   assertNull(result);
   assertEquals("CBDEF", clientMap.get("1"));
   assertEquals("CBDEF", clientMap.get("1"));
   assertEquals("CBDEF", clientMap.get("1"));
   assertEquals(1, clientMap.size());
   result = clientMap.put("1", "B");
   assertEquals("CBDEF", result);
   assertEquals("B", clientMap.get("1"));
   assertEquals("B", clientMap.get("1"));
 }
예제 #9
0
  @Test
  public void testEPL() {
    // should say fieldsTypes, maybe with object/component prefix
    Map<String, Object> eventTypes = new HashMap<>();
    eventTypes.put(LITERAL_SYMBOL, String.class);
    eventTypes.put(LITERAL_PRICE, Integer.class);

    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(LITERAL_QUOTES, new RandomSentenceSpout());
    builder
        .setBolt(
            LITERAL_ESPER,
            (new EsperBolt())
                .addEventTypes(eventTypes)
                .addOutputTypes(
                    Collections.singletonMap(
                        LITERAL_RETURN_OBJ, Arrays.asList(LITERAL_AVG, LITERAL_PRICE)))
                .addStatements(
                    Collections.singleton(
                        "insert into Result "
                            + "select avg(price) as avg, price from "
                            + "quotes_default(symbol='A').win:length(2) "
                            + "having avg(price) > 60.0")))
        .shuffleGrouping(LITERAL_QUOTES);
    builder.setBolt("print", new PrinterBolt()).shuffleGrouping(LITERAL_ESPER, LITERAL_RETURN_OBJ);

    Config conf = new Config();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("test", conf, builder.createTopology());
    Utils.sleep(10000);
    cluster.shutdown();
    assertEquals(resultEPL.get(100), new Double(75.0));
    assertEquals(resultEPL.get(50), new Double(75.0));
  }
예제 #10
0
  @Test
  public void testCookies_whenCookiesArePresent() {

    Collection<Cookie> cookies = new ArrayList<>();
    cookies.add(new Cookie("cookie1", "cookie1value"));
    cookies.add(new Cookie("cookie2", "cookie2value"));

    Map<String, String> expected = new HashMap<>();
    for (Cookie cookie : cookies) {
      expected.put(cookie.getName(), cookie.getValue());
    }

    Cookie[] cookieArray = cookies.toArray(new Cookie[cookies.size()]);

    when(servletRequest.getCookies()).thenReturn(cookieArray);

    assertTrue(
        "The count of cookies returned should be the same as those in the request",
        request.cookies().size() == 2);

    assertEquals(
        "A Map of Cookies should have been returned because they exist",
        expected,
        request.cookies());
  }
예제 #11
0
  @Test
  @org.junit.Ignore
  public void large_node_size() {
    for (int i : new int[] {10, 200, 6000}) {

      int max = i * 100;
      File f = TT.tempDbFile();
      DB db = DBMaker.fileDB(f).transactionDisable().make();
      Map m =
          db.treeMapCreate("map")
              .nodeSize(i)
              .keySerializer(BTreeKeySerializer.INTEGER)
              .valueSerializer(Serializer.INTEGER)
              .make();

      for (int j = 0; j < max; j++) {
        m.put(j, j);
      }

      db.close();
      db = DBMaker.fileDB(f).deleteFilesAfterClose().transactionDisable().make();
      m = db.treeMap("map");

      for (Integer j = 0; j < max; j++) {
        assertEquals(j, m.get(j));
      }
      db.close();
    }
  }
예제 #12
0
 /** Test of renderChildren method, of class Activity. */
 @Test
 public void testCreateChildren() throws Exception {
   System.out.println("renderChildren");
   // Setup
   ChildPane childPane = new ChildPane();
   childPane.setChild("Child");
   VBox vbox = VBoxBuilder.create().children(childPane).build();
   Parent parent = new Parent();
   parent.setScene(vbox);
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   RenderParameter renderParam = new RenderParameter();
   String id = renderParam.putParam("checkForLabel", "CheckForLabel");
   childPane.setId(id);
   parent.createChildren(fieldParams, renderParam, ValidationResult.getEmptyResult());
   // Assertoin
   Child child = (Child) parent.getChildActivities(Child.class).get(0);
   assertNotNull(child);
   assertNotNull(child.getScene());
   assertEquals(childPane, child.getScene());
   assertEquals(parent, child.getParent());
   VBox cvbox = (VBox) child.getScene().getChildren().get(0);
   assertTrue(cvbox.getChildren().get(0) instanceof Button);
   assertTrue(cvbox.getChildren().get(1) instanceof Label);
   assertEquals(data.checkForButton, ((Button) cvbox.getChildren().get(0)).getText());
   assertEquals("CheckForLabel", ((Label) cvbox.getChildren().get(1)).getText());
 }
예제 #13
0
 /* http://stackoverflow.com/questions/13592236/parse-the-uri-string-into-name-value-collection-in-java */
 public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {
   Map<String, String> queryPairs = new LinkedHashMap<String, String>();
   String query = url.getQuery();
   String[] pairs = query.split("&");
   for (String pair : pairs) {
     int idx = pair.indexOf("=");
     String key = URLDecoder.decode(pair.substring(0, idx), "UTF-8");
     if (queryPairs.get(key) == null) {
       queryPairs.put(key, URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
     } else {
       queryPairs.put(
           key, queryPairs.get(key) + ", " + URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
     }
   }
   return queryPairs;
 }
예제 #14
0
 /** Test of initialize method, of class Activity. */
 @Test
 public void testInitialize_Activity_Map() throws Exception {
   System.out.println("initialize");
   // Setup
   ParentActivity parent = new ParentActivity();
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   final String field2 = "field2value";
   final List<String> field3 = new ArrayList<String>();
   Map<String, Object> takeoverParams =
       new HashMap<String, Object>() {
         {
           put("field2", field2);
           put("field3", field3);
         }
       };
   ChildActivity child = new ChildActivity();
   child.initialize(parent, fieldParams, takeoverParams);
   // Assertion
   assertEquals(parent, child.getParent());
   assertEquals(data.getField0(), child.field0);
   assertEquals(data.getField1(), child.field1);
   assertEquals(field2, child.field2);
   assertEquals(field3, child.field3);
   assertEquals("TESTING", child.getTest());
 }
예제 #15
0
  private User setupAppUser(UUID appId, String username, String email, boolean activated)
      throws Exception {
    Mailbox.clearAll();

    EntityManager em = setup.getEmf().getEntityManager(appId);

    Map<String, Object> userProps = new LinkedHashMap<String, Object>();
    userProps.put("username", username);
    userProps.put("email", email);
    userProps.put("activated", activated);

    User user = em.create(User.ENTITY_TYPE, User.class, userProps);
    setup.getEntityIndex().refresh(app.getId());

    return user;
  }
예제 #16
0
  @Test
  public void usingForm() {
    final // sneaky final
    // #create
    Form<User> userForm = Form.form(User.class);
    // #create

    // #bind
    Map<String, String> anyData = new HashMap();
    anyData.put("email", "*****@*****.**");
    anyData.put("password", "secret");

    User user = userForm.bind(anyData).get();
    // #bind

    assertThat(user.email, equalTo("*****@*****.**"));
    assertThat(user.password, equalTo("secret"));
  }
예제 #17
0
  @Test
  public void testXsltWithParameters() {
    IResource xml = resourceLocator.getFirst("/xml/custom-parameters-required.xml");
    IResource xslt = resourceLocator.getFirst("/xsl/custom-xslt.xsl");

    Map<String, String> xsltParameters = Maps.newHashMap();
    xsltParameters.put("id-field", "number");
    xsltParameters.put("title-field", "heading");
    xsltParameters.put("snippet-field", "snippet");
    xsltParameters.put("url-field", "url");

    processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"), xml);
    processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"), xslt);
    processingAttributes.put(
        AttributeUtils.getKey(XmlDocumentSource.class, "xsltParameters"), xsltParameters);
    final int documentCount = runQuery();
    assertTransformedDocumentsEqual(documentCount);
  }
  private void doControlTask() throws IOException, ClassNotFoundException {
    BlockingTaskSummaryResponseHandler handler = new BlockingTaskSummaryResponseHandler();
    client.getTasksAssignedAsPotentialOwner("control", "en-UK", handler);
    List<TaskSummary> sums = handler.getResults();
    assertNotNull(sums);
    assertEquals(1, sums.size());

    BlockingTaskOperationResponseHandler startTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.start(sums.get(0).getId(), "control", startTaskOperationHandler);

    BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler();
    client.getTask(sums.get(0).getId(), getTaskHandler);
    Task controlTask = getTaskHandler.getTask();

    BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler();
    client.getContent(controlTask.getTaskData().getDocumentContentId(), getContentHandler);
    Content content = getContentHandler.getContent();

    assertNotNull(content);

    ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject();
    Emergency retrivedEmergency = (Emergency) deserializedContent.get("emergency");
    assertNotNull(retrivedEmergency);
    ActivePatients retrivedActivePatients =
        (ActivePatients) deserializedContent.get("activePatients");
    assertNotNull(retrivedActivePatients);
    assertEquals(1, retrivedActivePatients.size());
    SuggestedProcedures retrivedSuggestedProcedures =
        (SuggestedProcedures) deserializedContent.get("suggestedProcedures");
    assertNotNull(retrivedSuggestedProcedures);
    assertEquals(
        "[DefaultHeartAttackProcedure: ]",
        retrivedSuggestedProcedures.getSuggestedProceduresString());

    Map<String, Object> info = new HashMap<String, Object>();
    SelectedProcedures selectedProcedures = new SelectedProcedures(retrivedEmergency.getId());

    selectedProcedures.addSelectedProcedureName("DefaultHeartAttackProcedure");
    info.put("selectedProcedures", selectedProcedures);

    ContentData result = new ContentData();
    result.setAccessType(AccessType.Inline);
    result.setType("java.util.Map");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bos);
    out.writeObject(info);
    out.close();
    result.setContent(bos.toByteArray());

    BlockingTaskOperationResponseHandler completeTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.complete(sums.get(0).getId(), "control", result, completeTaskOperationHandler);
  }
예제 #19
0
  @Test
  public void queryParamShouldBeParsedAsHashMap() {
    Map<String, String[]> params = new HashMap<>();
    params.put("user[name]", new String[] {"Federico"});

    when(servletRequest.getParameterMap()).thenReturn(params);

    String name = request.queryMap("user").value("name");
    assertEquals("Invalid name in query string", "Federico", name);
  }
 @Test
 public void getPuttedValueFromTheMap() {
   HazelcastClient hClient = getHazelcastClient();
   Map<String, String> clientMap = hClient.getMap("getPuttedValueFromTheMap");
   int size = clientMap.size();
   clientMap.put("1", "Z");
   String value = clientMap.get("1");
   assertEquals("Z", value);
   assertEquals(size + 1, clientMap.size());
 }
 @Test
 public void removeFromMap() {
   HazelcastClient hClient = getHazelcastClient();
   Map map = hClient.getMap("removeFromMap");
   assertNull(map.put("a", "b"));
   assertEquals("b", map.get("a"));
   assertEquals("b", map.remove("a"));
   assertNull(map.remove("a"));
   assertNull(map.get("a"));
 }
  @Test
  @SuppressWarnings("serial")
  public void createRetrieveAnAccountProfileAndDeleteRelatedAccount() throws Exception {
    SaveResult accountResult =
        module.create(ZObjectType.Account, Collections.singletonList(testAccount())).get(0);
    assertTrue(accountResult.isSuccess());

    final String accountId = accountResult.getId();
    try {
      SaveResult contactResult =
          module
              .create(
                  ZObjectType.Contact,
                  Collections.<Map<String, Object>>singletonList(
                      new HashMap<String, Object>() {
                        {
                          put("Country", "US");
                          put("FirstName", "John");
                          put("LastName", "Doe");
                          put("AccountId", accountId);
                        }
                      }))
              .get(0);

      assertTrue(contactResult.isSuccess());

      Map<String, Object> accountMap = testAccount();
      accountMap.put("Id", accountId);
      accountMap.put("BillToId", contactResult.getId());

      SaveResult accountUpdateResult =
          module.update(ZObjectType.Account, Collections.singletonList(accountMap)).get(0);

      assertTrue(accountUpdateResult.isSuccess());

      Map<String, Object> accountProfile = module.accountProfile(accountId);

      assertEquals("Doe", ((Map<String, Object>) accountProfile.get("billTo")).get("lastName"));
    } finally {
      module.delete(ZObjectType.Account, Arrays.asList(accountId)).get(0);
    }
  }
예제 #23
0
  @org.junit.Test
  public void testGenerateValuesFreeAlternativesWithNegativeIngredients() throws Exception {
    mappingCollector.setValueBefore("bucket", 768);
    mappingCollector.setValueBefore("waterBucket", 768);
    mappingCollector.setValueBefore("waterBottle", 0);
    Map<String, Integer> m = new HashMap<>();
    m.put("waterBucket", 1);
    m.put("bucket", -1);
    mappingCollector.addConversion(1, "waterGroup", m);
    mappingCollector.addConversion(1, "waterGroup", Arrays.asList("waterBottle"));
    mappingCollector.setValueBefore("a", 3);
    mappingCollector.addConversion(1, "result", Arrays.asList("a", "waterGroup"));

    Map<String, Integer> values = valueGenerator.generateValues();
    assertEquals(3, getValue(values, "a"));
    assertEquals(768, getValue(values, "bucket"));
    assertEquals(768, getValue(values, "waterBucket"));
    assertEquals(0, getValue(values, "waterGroup"));
    assertEquals(3, getValue(values, "result"));
  }
  @Test
  public void testMapEquals() {
    Map s = new HashMap();
    s.put("five", 5);
    s.put("ten", 10);

    Map r = new InstrumentedMap(s);
    Map q = new InstrumentedMap(r);

    assertTrue(r.equals(q));
  }
  private void doOperatorTask() throws ClassNotFoundException, IOException {
    BlockingTaskSummaryResponseHandler handler = new BlockingTaskSummaryResponseHandler();
    client.getTasksAssignedAsPotentialOwner("operator", "en-UK", handler);
    List<TaskSummary> sums = handler.getResults();
    assertNotNull(sums);
    assertEquals(1, sums.size());

    BlockingTaskOperationResponseHandler startTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.start(sums.get(0).getId(), "operator", startTaskOperationHandler);

    BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler();
    client.getTask(sums.get(0).getId(), getTaskHandler);
    Task operatorTask = getTaskHandler.getTask();

    BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler();
    client.getContent(operatorTask.getTaskData().getDocumentContentId(), getContentHandler);
    Content content = getContentHandler.getContent();

    assertNotNull(content);

    ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject();
    Call restoredCall = (Call) deserializedContent.get("call");
    persistenceService.storeCall(restoredCall);

    Emergency emergency = new Emergency();

    emergency.setCall(restoredCall);

    emergency.setLocation(new Location(1, 2));
    emergency.setType(Emergency.EmergencyType.HEART_ATTACK);
    emergency.setNroOfPeople(1);
    persistenceService.storeEmergency(emergency);

    trackingService.attachEmergency(restoredCall.getId(), emergency.getId());

    Map<String, Object> info = new HashMap<String, Object>();
    info.put("emergency", emergency);

    ContentData result = new ContentData();
    result.setAccessType(AccessType.Inline);
    result.setType("java.util.Map");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bos);
    out.writeObject(info);
    out.close();
    result.setContent(bos.toByteArray());

    BlockingTaskOperationResponseHandler completeTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.complete(sums.get(0).getId(), "operator", result, completeTaskOperationHandler);
  }
예제 #26
0
 // [Issue#232]
 public void testBigDecimalAsPlainStringTreeConversion() throws Exception {
   ObjectMapper mapper = new ObjectMapper();
   mapper.enable(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN);
   Map<String, Object> map = new HashMap<String, Object>();
   String PI_STR = "3.00000000";
   map.put("pi", new BigDecimal(PI_STR));
   JsonNode tree = mapper.valueToTree(map);
   assertNotNull(tree);
   assertEquals(1, tree.size());
   assertTrue(tree.has("pi"));
 }
예제 #27
0
  @Test
  public void testPrimitiveAccess() {
    Map<String, Double> vpm = new HashMap<String, Double>();

    dp.setVehiclesPerMeter(vpm);

    Double val = 1.23;
    vpm.put("3", val);

    assertEquals((Double) 1.23, dp.getVehiclesPerMeter().get("3"));
  }
예제 #28
0
 Base1() throws GoraException, NoSuchAlgorithmException {
   final ByteBuffer b0 = ByteBuffer.wrap("0".getBytes());
   b0.mark();
   e0 =
       new com.kareebo.contacts.thrift.EncryptionKey(
           b0, com.kareebo.contacts.thrift.EncryptionAlgorithm.RSA2048);
   final User user0 = userDatastore.get(clientId.getUser());
   final Map<CharSequence, Client> clients0 = user0.getClients();
   clients0.values().iterator().next().getKeys().setEncryption(TypeConverter.convert(e0));
   final ByteBuffer b1 = ByteBuffer.wrap("1".getBytes());
   b1.mark();
   e1 =
       new com.kareebo.contacts.thrift.EncryptionKey(
           b1, com.kareebo.contacts.thrift.EncryptionAlgorithm.RSA2048);
   final Client client01 = createClient(clientId01, verificationKey);
   client01.getKeys().setEncryption(TypeConverter.convert(e1));
   clients0.put(TypeConverter.convert(clientId01.getClient()), client01);
   user0.setClients(clients0);
   final Client client10 = createClient(clientId10, verificationKey);
   final Client client11 = createClient(clientId11, verificationKey);
   final User user1 = new User();
   user1.setBlind(b0);
   final Map<CharSequence, Client> clients1 = new HashMap<>(2);
   clients1.put(TypeConverter.convert(clientId10.getClient()), client10);
   clients1.put(TypeConverter.convert(clientId11.getClient()), client11);
   user1.setClients(clients1);
   user1.setIdentities(new ArrayList<>());
   user1.setSentRequests(new ArrayList<>());
   user1.setId(clientId10.getUser());
   userDatastore.put(clientId.getUser(), user0);
   userDatastore.put(clientId10.getUser(), user1);
   final HashIdentity hashIdentity = new HashIdentity();
   hashIdentity.setHash(b0);
   final HashIdentityValue hashIdentityValue = new HashIdentityValue();
   hashIdentityValue.setConfirmers(new ArrayList<>());
   hashIdentityValue.setId(clientId10.getUser());
   hashIdentity.setHashIdentity(hashIdentityValue);
   u.setAlgorithm(HashAlgorithm.SHA256);
   u.setBuffer(b0);
   identityDataStore.put(b0, hashIdentity);
 }
예제 #29
0
 @Test
 public void in_memory_test() {
   StorageDirect engine = new StorageDirect(Volume.memoryFactory(false));
   Map<Long, Integer> recids = new HashMap<Long, Integer>();
   for (int i = 0; i < 1000; i++) {
     long recid = engine.recordPut(i, Serializer.BASIC_SERIALIZER);
     recids.put(recid, i);
   }
   for (Long recid : recids.keySet()) {
     assertEquals(recids.get(recid), engine.recordGet(recid, Serializer.BASIC_SERIALIZER));
   }
 }
예제 #30
0
  @org.junit.Test
  public void testGenerateValuesWaterBucketRecipe() throws Exception {
    mappingCollector.setValueBefore("somethingElse", 9);
    mappingCollector.setValueBefore("container", 23);
    mappingCollector.setValueBefore("fluid", Integer.MIN_VALUE);
    mappingCollector.addConversion(1, "filledContainer", Arrays.asList("container", "fluid"));

    // Recipe that only consumes fluid:
    Map<String, Integer> map = new HashMap<>();
    map.put("container", -1);
    map.put("filledContainer", 1);
    map.put("somethingElse", 2);
    mappingCollector.addConversion(1, "fluidCraft", map);

    Map<String, Integer> values = valueGenerator.generateValues();
    assertEquals(9, getValue(values, "somethingElse"));
    assertEquals(23, getValue(values, "container"));
    assertEquals(0, getValue(values, "fluid"));
    assertEquals(23, getValue(values, "filledContainer"));
    assertEquals(2 * 9, getValue(values, "fluidCraft"));
  }