public Map<String, Object> buildMessage() {
   Map<String, Object> map = new HashMap<>();
   map.put("publisher", "norbert");
   map.put("time", NOW);
   map.put("readings", SAMPLE_READINGS);
   return map;
 }
Ejemplo n.º 2
0
 @Test
 public void setMetadata() throws IOException {
   expectStatusCode(202);
   Map<String, Object> metadata = new TreeMap<String, Object>();
   metadata.put("Year", "1989");
   metadata.put("Company", "42 BV");
   object.setMetadata(metadata);
   verifyHeaderValue("1989", X_OBJECT_META_PREFIX + "Year");
   verifyHeaderValue("42 BV", X_OBJECT_META_PREFIX + "Company");
 }
Ejemplo n.º 3
0
  @Test
  public void shouldNotThrowExceptionIfXmlnsNotRecognized() {
    Map<String, String> motherFormValuesWithoutXmlns =
        motherFormValues(
            "94d5374f-290e-409f-bc57-86c2e4bcc43f", "89fda0284e008d2e0c980fb13fa0e5bb");
    motherFormValuesWithoutXmlns.put("xmlns", "randomurl");

    try {
      careService.processAndSaveForms(
          motherFormValuesWithoutXmlns, new ArrayList<Map<String, String>>());
    } catch (Exception e) {
      fail("The exception should not have been thrown: " + e.getMessage());
    }
  }
  private static Credentials getCredentials(Cluster cluster) {
    Map<String, String> credentials = cluster.getCredentials();

    Credentials creds = null;
    for (Map.Entry<String, String> entry : credentials.entrySet()) {
      String userName = entry.getKey();
      String password = entry.getValue();
      String tenantDomain = MultitenantUtils.getTenantDomain(userName);

      creds = new Credentials(userName, password, tenantDomain);
    }

    return creds;
  }
Ejemplo n.º 5
0
 @SuppressWarnings("EqualsBetweenInconvertibleTypes")
 @Test
 public void compareContainers() {
   Container container = account.getContainer("alpha");
   StoredObject object1 = container.getObject("img1.png");
   StoredObject object2 = container.getObject("img2.png");
   assertFalse(object1.equals("alpha"));
   assertFalse(object1.equals(object2));
   Map<StoredObject, String> containers = new TreeMap<StoredObject, String>();
   containers.put(object1, object1.getName());
   containers.put(object2, object2.getName());
   assertEquals(object1.getName(), containers.get(object1));
   assertEquals(object2.getName(), containers.get(object2));
   assertEquals(object1.getName().hashCode(), object1.hashCode());
 }
  @AfterClass
  public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue(
        "Application context of type "
            + appCtx.getClass()
            + " is not a subclass of "
            + ConfigurableApplicationContext.class,
        appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext =
        (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue(
        "Bean Factory of type "
            + beanFactory.getClass()
            + " is not of type "
            + BeanDefinitionRegistry.class,
        beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader =
        new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-testcleanup.xml"));

    // cleanup command factory
    final Map<String, CommandFactory> commandFactoryList =
        applicationContext.getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg =
        appCtx.getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    //		if (definitonFactory != null)
    //		{
    // TODO this test seems to let processes run after method completion - therefore we cannot
    // remove definitions !!!
    //			definitonFactory.remove("testPlaceorder");
    //			definitonFactory.remove("testConsignmentFulfilmentSubprocess");
    //		}
    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;
    processService = null;
  }
Ejemplo n.º 7
0
 private Map<String, String> motherFormValues(String caseId, String flwId) {
   Map<String, String> motherForm = new HashMap<>();
   motherForm.put("xmlns", "http://bihar.commcarehq.org/pregnancy/new");
   motherForm.put("dateModified", "2012-07-21T12:02:59.923+05:30");
   motherForm.put(
       "fullName",
       "&#2327;&#2366;&#2351;&#2340;&#2381;&#2352;&#2368; &#2342;&#2375;&#2357;&#2368;");
   motherForm.put(
       "husbandName",
       "&#2342;&#2367;&#2344;&#2375;&#2358; &#2350;&#2369;&#2326;&#2367;&#2351;&#2366;");
   motherForm.put("hhNumber", "165");
   motherForm.put("familyNumber", "5");
   motherForm.put("dobKnown", "no");
   motherForm.put("caste", "other");
   motherForm.put("ageCalc", null);
   motherForm.put("instanceId", "e34707f8-80c8-4198-bf99-c11c90ba5c98");
   motherForm.put("motherCase", caseId);
   motherForm.put("flw", flwId);
   motherForm.put("timeStart", "2012-07-21T11:59:31.076+05:30");
   motherForm.put("timeEnd", "2012-07-21T12:02:59.923+05:30");
   return motherForm;
 }
  @Test
  public void insertEventsFromMultipleStreams() {
    try {
      // save stream defn 1
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);

      // save stream defn 3
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition3);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList = new ArrayList<Event>();
    // retrieve stream id 1
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent1, streamDefinition1.getStreamId()));

    // retrieve stream id 3
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent3, streamDefinition3.getStreamId()));

    Map<String, Event> insertedEvents = new HashMap<String, Event>();
    int eventCounter = 0;
    for (Event event : eventList) {
      try {
        String rowKey = insertEvent(cluster, event, eventCounter++);
        // inserts row key only if event is valid, i.e. only proper events will add a row key
        insertedEvents.put(rowKey, event);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    assertEquals(4, insertedEvents.size());

    Map<String, Event> retrievedEvents = new HashMap<String, Event>();

    for (Map.Entry<String, Event> eventProps : insertedEvents.entrySet()) {
      try {
        retrievedEvents.put(
            eventProps.getKey(),
            getEvent(cluster, eventProps.getValue().getStreamId(), eventProps.getKey()));
      } catch (EventProcessingException e) {
        e.printStackTrace();
        fail();
      }
    }

    for (Map.Entry<String, Event> rowKeyAndEvent : retrievedEvents.entrySet()) {
      Event retrievedEvent = rowKeyAndEvent.getValue();
      Event originialEvent = insertedEvents.get(rowKeyAndEvent.getKey());
      System.out.println(
          "Retrieved Event : " + retrievedEvent + "\n Original Event : " + originialEvent + "\n\n");
      if (streamDefinition1.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition1));
      } else if (streamDefinition2.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition3));
      }
    }
  }