/**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by "
             + "currency code.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata2() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     if (MonetaryConversions.isConversionAvailable("XXX", providerName)) {
       CurrencyConversion conv = MonetaryConversions.getConversion("XXX", providerName);
       ConversionContext ctx = conv.getContext();
       AssertJUnit.assertNotNull(
           "ExchangeProvider must return a valid ProviderContext, but returned null: "
               + providerName,
           ctx);
       AssertJUnit.assertEquals(
           "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
           providerName,
           ctx.getProviderName());
       AssertJUnit.assertNotNull(
           "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
               + providerName,
           ctx.getRateType());
     }
   }
 }
 /**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all ExchangeRateProvider instances returns valid ProviderContext.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ExchangeRateProvider prov = MonetaryConversions.getExchangeRateProvider(providerName);
     AssertJUnit.assertNotNull("Provider mot accessible: " + providerName, prov);
     ProviderContext ctx = prov.getContext();
     AssertJUnit.assertNotNull(
         "ExchangeProvider must return a valid ProviderContext, but returned null: "
             + providerName,
         ctx);
     AssertJUnit.assertEquals(
         "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
         providerName,
         ctx.getProviderName());
     AssertJUnit.assertNotNull(
         "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
             + providerName,
         ctx.getRateTypes());
     AssertJUnit.assertFalse(
         "ExchangeProvider's ProviderContext declares empty RateTypes to be returned: "
             + providerName,
         ctx.getRateTypes().isEmpty());
   }
 }
  public void testSyncTxReplMap() throws Exception {
    Integer age;
    TransactionManager tm = TestingUtil.getTransactionManager(cache1);
    tm.begin();
    Transaction tx = tm.getTransaction();
    LocalListener lis = new LocalListener();

    cache1.put("age", 38);
    lis.put("name", "Ben");

    assert cache1.get("age").equals(38);
    tm.suspend();
    assertNull(
        "age on cache2 must be null as the TX has not yet been committed", cache2.get("age"));
    assertNull("age on cache1 must be null as the TX has been resumed", cache1.get("age"));
    tm.resume(tx);
    assertNotNull("age on cache1 must be not be null", cache1.get("age"));
    tm.commit();
    assertNotNull("age on cache1 must be not be null", cache1.get("age"));

    System.out.println("  ********************** ");
    // value on cache2 must be 38
    age = (Integer) cache2.get("age");
    assertNotNull("\"age\" obtained from cache2 must be non-null ", age);
    assertTrue("\"age\" must be 38", age == 38);
  }
Ejemplo n.º 4
0
  @Override
  protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd)
      throws ObjectNotFoundException, SchemaException {
    OperationResult result =
        new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken");
    Task task = taskManager.getTask(syncTaskOid, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);

    PrismProperty<String> syncTokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN);
    assertNotNull("No sync token in " + task, syncTokenProperty);
    String syncToken = syncTokenProperty.getRealValue();
    assertNotNull("No sync token in " + task, syncToken);
    IntegrationTestTools.display("Sync token", syncToken);

    GeneralizedTime syncTokenGt;
    try {
      syncTokenGt = new GeneralizedTime(syncToken);
    } catch (ParseException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    TestUtil.assertBetween(
        "Wrong time in sync token: " + syncToken,
        roundTsDown(tsStart),
        roundTsUp(tsEnd),
        syncTokenGt.getCalendar().getTimeInMillis());
  }
 /**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by "
             + "ConversionQuery/CurrencyUnit.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata3WithContext() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ConversionQuery query =
         ConversionQueryBuilder.of()
             .setTermCurrency(Monetary.getCurrency("XXX"))
             .setProviderName(providerName)
             .build();
     if (MonetaryConversions.isConversionAvailable(query)) {
       CurrencyConversion conv = MonetaryConversions.getConversion(query);
       ConversionContext ctx = conv.getContext();
       AssertJUnit.assertNotNull(
           "ExchangeProvider must return a valid ProviderContext, but returned null: "
               + providerName,
           ctx);
       AssertJUnit.assertEquals(
           "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
           providerName,
           ctx.getProviderName());
       AssertJUnit.assertNotNull(
           "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
               + providerName,
           ctx.getRateType());
     }
   }
 }
Ejemplo n.º 6
0
 @Override
 public void expectSingleCustomEvent(ClientEvent.Type type, CustomEvent expected) {
   CustomEvent event = pollEvent(type);
   assertNotNull(event.key);
   assertNotNull(event.timestamp); // check only custom field, value can be null
   assertAnyEquals(expected, event);
 }
  /**
   * WARNING: don't do stupid things such like below, we do this because we can guarantee the shard
   * id will NOT change. if you want to use cobar client corretly, make sure you are partitioning
   * you databases with shard id that will not be changed once it's created!!!
   */
  public void testUpdateOnCobarSqlMapClientTemplate() {
    String[] names = {"Aaron", "Amily", "Aragon", "Darren", "Darwin"};
    batchInsertMultipleFollowersAsFixture(names);

    String nameSuffix = "Wang";
    for (String name : names) {
      Follower follower =
          (Follower)
              getSqlMapClientTemplate()
                  .queryForObject("com.alibaba.cobar.client.entities.Follower.finaByName", name);
      assertNotNull(follower);
      follower.setName(follower.getName() + nameSuffix);
      getSqlMapClientTemplate()
          .update("com.alibaba.cobar.client.entities.Follower.update", follower);

      Long id = follower.getId();

      follower = null;
      follower =
          (Follower)
              getSqlMapClientTemplate()
                  .queryForObject("com.alibaba.cobar.client.entities.Follower.finaByName", name);
      assertNull(follower);

      follower =
          (Follower)
              getSqlMapClientTemplate()
                  .queryForObject("com.alibaba.cobar.client.entities.Follower.load", id);
      assertNotNull(follower);
      assertEquals(name + nameSuffix, follower.getName());
    }
  }
Ejemplo n.º 8
0
  /** Test payInvoice(invoice) API call. */
  @Test
  public void testPayInvoice() {
    // setup
    UserWS user = buildUser(PRANCING_PONY_ACCOUNT_TYPE);
    user.setId(api.createUser(user));

    ItemTypeWS itemType = buildItemType();
    itemType.setId(api.createItemCategory(itemType));

    ItemDTOEx item = buildItem(itemType.getId(), api.getCallerCompanyId());
    item.setId(api.createItem(item));

    // testing
    System.out.println("Getting an invoice paid, and validating the payment.");
    OrderWS order = buildOrder(user.getId(), Arrays.asList(item.getId()), new BigDecimal("3.45"));
    Integer invoiceId =
        api.createOrderAndInvoice(
            order, OrderChangeBL.buildFromOrder(order, ORDER_CHANGE_STATUS_APPLY));
    Integer orderId = api.getInvoiceWS(invoiceId).getOrders()[0];
    PaymentAuthorizationDTOEx auth = api.payInvoice(invoiceId);
    assertNotNull("auth can not be null", auth);
    PaymentWS payment = api.getLatestPayment(user.getId());
    assertNotNull("payment can not be null", payment);
    assertNotNull("auth in payment can not be null", payment.getAuthorizationId());

    // cleanup
    api.deletePayment(auth.getPaymentId());
    api.deleteInvoice(invoiceId);
    api.deleteOrder(orderId);
    api.deleteItem(item.getId());
    api.deleteItemCategory(itemType.getId());
    api.deleteUser(user.getId());
  }
  @BeforeMethod
  public void setUp() throws Exception {
    cleanupDB();
    m_mockStoreManager = EasyMock.createMock(IActiveMailboxStoreManager.class);
    ICustomerManager customerMgrMock = new CustomerManagerMock();
    IIslandManager islandMgrMock = createNiceMock(IIslandManager.class);
    int islandId =
        0; // needs to match value for feed/search passed into TestUtils.createCustomer() call to
    // customer manager
    boolean provisioned = true; // needs to be provisioned-enabled
    Island island =
        new Island(islandId, "fooIsland", null, provisioned, false, "fooPlatform", "fooSchema");
    expect(islandMgrMock.getIsland(islandId)).andReturn(island).anyTimes();
    expect(islandMgrMock.isValidIsland(islandId)).andReturn(true).anyTimes();
    replay(islandMgrMock);
    ManagementContainerInjector.getInjector()
        .withService(islandMgrMock, getClass().getName())
        .withService(customerMgrMock, getClass().getName());

    m_customer =
        TestUtils.createActiveMailboxTestCustomer(
            Capabilities.ActiveMailboxSupport.AM_CUSTOMER_ENCRYPTION);
    assertNotNull("Customer should have been created", m_customer);

    TestUtils.cleanupTestUsers(m_customer.getCustID());

    m_user = TestUtils.createUser(m_customer, "user-1", "1", "password");
    assertNotNull("User should have been created", m_user);
  }
Ejemplo n.º 10
0
  @Test
  public void test015SearchLdapConnector() throws Exception {
    final String TEST_NAME = "test015SearchLdapConnector";
    displayTestTitle(TEST_NAME);

    QueryType query = new QueryType();
    query.setFilter(
        ModelClientUtil.parseSearchFilterType(
            "<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >"
                + "<path>c:connectorType</path>"
                + "<value>"
                + CONNECTOR_LDAP_TYPE
                + "</value>"
                + "</equal>"));

    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();

    // WHEN
    modelPort.searchObjects(
        ModelClientUtil.getTypeQName(ConnectorType.class),
        query,
        null,
        objectListHolder,
        resultHolder);

    // THEN
    assertSuccess(resultHolder);
    ObjectListType objectList = objectListHolder.value;
    assertEquals("Unexpected number of LDAP connectors", 1, objectList.getObject().size());
    ConnectorType ldapConnector = (ConnectorType) objectList.getObject().get(0);
    assertNotNull("Null LDAP connector", ldapConnector);
    connectorLdapOid = ldapConnector.getOid();
    assertNotNull("Null LDAP connector OID", connectorLdapOid);
  }
 // -------------------------------------------------------------------------
 @Test
 public void test_basics() throws Exception {
   assertNotNull(_secMaster);
   assertEquals(true, _secMaster.getUniqueIdScheme().equals("DbSec"));
   assertNotNull(_secMaster.getDbConnector());
   assertNotNull(_secMaster.getClock());
 }
Ejemplo n.º 12
0
  /**
   * Simple call to connector test() method.
   *
   * @throws Exception
   */
  @Test
  public void test310TestConnectionNegative() throws Exception {
    final String TEST_NAME = "test310TestConnectionNegative";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN

    OperationResult result = new OperationResult(TEST_NAME);

    ConnectorInstance badConnector =
        factory.createConnectorInstance(
            connectorType,
            ResourceTypeUtil.getResourceNamespace(badResourceType),
            "test connector");
    badConnector.configure(
        badResourceType.getConnectorConfiguration().asPrismContainerValue(), result);

    // WHEN

    badConnector.test(result);

    // THEN
    result.computeStatus("test failed");
    display("Test result (FAILURE EXPECTED)", result);
    AssertJUnit.assertNotNull(result);
    OperationResult connectorConnectionResult = result.getSubresults().get(1);
    AssertJUnit.assertNotNull(connectorConnectionResult);
    System.out.println(
        "Test \"connector connection\" result: "
            + connectorConnectionResult
            + " (FAILURE EXPECTED)");
    AssertJUnit.assertTrue(
        "Unexpected success of bad connector test", !connectorConnectionResult.isSuccess());
    AssertJUnit.assertTrue(!result.isSuccess());
  }
  @Test
  public void resolveInlineModelTest() throws Exception {
    Swagger swagger = new Swagger();

    swagger.addDefinition(
        "User",
        new ModelImpl()
            .name("user")
            .description("a common user")
            .property("name", new StringProperty())
            .property(
                "address",
                new ObjectProperty()
                    .title("title")
                    ._default("default")
                    .access("access")
                    .readOnly(false)
                    .required(true)
                    .description("description")
                    .name("name")
                    .property("street", new StringProperty())
                    .property("city", new StringProperty())));

    new InlineModelResolver().flatten(swagger);

    ModelImpl user = (ModelImpl) swagger.getDefinitions().get("User");

    assertNotNull(user);
    assertTrue(user.getProperties().get("address") instanceof RefProperty);

    ModelImpl address = (ModelImpl) swagger.getDefinitions().get("User_address");
    assertNotNull(address);
    assertNotNull(address.getProperties().get("city"));
    assertNotNull(address.getProperties().get("street"));
  }
Ejemplo n.º 14
0
  public void testRepeatableReadWithNull() throws Exception {
    LockTestData tl = lockTestData;
    Cache<String, String> cache = tl.cache;
    TransactionManager tm = tl.tm;

    assertNull(cache.get("k"));

    tm.begin();
    assertNull(cache.get("k"));
    Transaction reader = tm.suspend();

    tm.begin();
    cache.put("k", "v");
    assertNotNull(cache.get("k"));
    assertEquals("v", cache.get("k"));
    tm.commit();

    assertNotNull(cache.get("k"));
    assertEquals("v", cache.get("k"));

    tm.resume(reader);
    Object o = cache.get("k");
    assertNull("found value " + o, o);
    tm.commit();

    assertNotNull(cache.get("k"));
    assertEquals("v", cache.get("k"));
    assertNoLocks();
  }
Ejemplo n.º 15
0
  @Test
  public void testSingleViewMultipleClients() {
    ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    env.init();
    ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();

    ViewClient client1 = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    assertNotNull(client1.getUniqueId());

    client1.attachToViewProcess(
        env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));
    ViewProcessImpl client1Process = env.getViewProcess(vp, client1.getUniqueId());
    assertTrue(client1Process.getState() == ViewProcessState.RUNNING);

    ViewClient client2 = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    assertNotNull(client2.getUniqueId());
    assertFalse(client1.getUniqueId().equals(client2.getUniqueId()));

    client2.attachToViewProcess(
        env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));
    ViewProcessImpl client2Process = env.getViewProcess(vp, client2.getUniqueId());
    assertEquals(client1Process, client2Process);
    assertTrue(client2Process.getState() == ViewProcessState.RUNNING);

    client1.detachFromViewProcess();
    assertTrue(client2Process.getState() == ViewProcessState.RUNNING);

    client2.detachFromViewProcess();
    assertTrue(client2Process.getState() == ViewProcessState.TERMINATED);

    client1.shutdown();
    client2.shutdown();
  }
Ejemplo n.º 16
0
  private void assertTestRelationship(Relationship relationship) {
    assertEquals("relationship", relationship.getId());
    assertNotNull(relationship.getSources());
    assertEquals(1, relationship.getSources().size());
    assertEquals(
        URI.create("urn:sourceDescription1"), relationship.getSources().get(0).getDescriptionRef());

    assertEquals(RelationshipType.Couple, relationship.getKnownType());

    assertEquals(URI.create("urn:person1"), relationship.getPerson1().getResource());
    assertEquals(URI.create("urn:person2"), relationship.getPerson2().getResource());

    assertNotNull(relationship.getFacts());
    assertEquals(2, relationship.getFacts().size());
    assertEquals("fact", relationship.getFacts().get(0).getId());
    assertEquals("event", relationship.getFacts().get(1).getId());

    assertNotNull(relationship.getIdentifiers());
    assertEquals(1, relationship.getIdentifiers().size());
    assertEquals(URI.create("urn:identifierType"), relationship.getIdentifiers().get(0).getType());
    assertEquals(
        URI.create("urn:identifierValue"), relationship.getIdentifiers().get(0).getValue());

    assertEquals("explanation", relationship.getAttribution().getChangeMessage());
  }
Ejemplo n.º 17
0
  /**
   * Assert application activation
   *
   * @param applicationName
   * @param tenantId
   */
  private void assertClusterWithScalingup(String applicationName, int tenantId) {
    Application application =
        ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
    assertNotNull(
        String.format("Application is not found: [application-id] %s", applicationName),
        application);
    boolean clusterScaleup = false;
    String clusterId = null;
    long startTime = System.currentTimeMillis();
    while (!clusterScaleup) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignore) {
      }
      Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
      for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
        String serviceUuid = clusterDataHolder.getServiceUuid();
        clusterId = clusterDataHolder.getClusterId();
        Service service = TopologyManager.getTopology().getService(serviceUuid);
        assertNotNull(
            String.format(
                "Service is not found: [application-id] %s [service] %s",
                applicationName, serviceUuid),
            service);

        Cluster cluster = service.getCluster(clusterId);
        assertNotNull(
            String.format(
                "Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
                applicationName, serviceUuid, clusterId),
            cluster);
        for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
          int activeInstances = 0;
          for (Member member : cluster.getMembers()) {
            if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
              if (member.getStatus().equals(MemberStatus.Active)) {
                activeInstances++;
              }
            }
          }
          clusterScaleup = activeInstances >= clusterDataHolder.getMinInstances();
          if (clusterScaleup) {
            activeInstancesAfterScaleup = activeInstances;
            break;
          }
        }
        application =
            ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
        if ((System.currentTimeMillis() - startTime) > CLUSTER_SCALE_UP_TIMEOUT) {
          break;
        }
      }
    }
    assertEquals(
        true,
        clusterScaleup,
        String.format("Cluster did not get scaled up: [cluster-id] %s", clusterId));
  }
Ejemplo n.º 18
0
 private void checkSecurityMessage(final FudgeMsgEnvelope fme) {
   assertNotNull(fme);
   final FudgeMsg msg = fme.getMessage();
   assertNotNull(msg);
   FudgeMsgFormatter.outputToSystemOut(msg);
   final FudgeMsg security =
       msg.getFieldValue(FudgeMsg.class, msg.getByName(SECURITYSOURCE_SECURITY));
   assertNotNull(security);
 }
Ejemplo n.º 19
0
 private void checkSecuritiesMessage(final FudgeMsgEnvelope fme) {
   assertNotNull(fme);
   final FudgeMsg msg = fme.getMessage();
   assertNotNull(msg);
   FudgeMsgFormatter.outputToSystemOut(msg);
   final Collection<FudgeField> securities = msg.getAllByName(SECURITYSOURCE_SECURITY);
   assertNotNull(securities);
   assertEquals(2, securities.size());
 }
 @Test
 public void checkDeadLockDetection() throws AttributeNotFoundException {
   Map result = (Map) converter.extractObject(new SelfRefBean1(), new Stack<String>(), true);
   assertNotNull("Bean 2 is set", result.get("bean2"));
   assertNotNull("Bean2:Bean1 is set", ((Map) result.get("bean2")).get("bean1"));
   assertEquals(
       "Reference breackage", ((Map) result.get("bean2")).get("bean1").getClass(), String.class);
   assertTrue("Bean 3 should be resolved", result.get("bean3") instanceof Map);
 }
 // -------------------------------------------------------------------------
 @Test
 public void aaplEquityByBbgTicker() throws Exception {
   ExternalId bloombergIdentifier =
       getBloombergIdentifier(EXPECTED_AAPL_EQUITY_SEC, ExternalSchemes.BLOOMBERG_TICKER);
   assertNotNull(bloombergIdentifier);
   Security sec = _securityProvider.getSecurity(bloombergIdentifier.toBundle());
   assertNotNull(sec);
   assertEquitySecurity(EXPECTED_AAPL_EQUITY_SEC, sec);
 }
Ejemplo n.º 22
0
 @BeforeTest
 @Override
 protected void before() throws Exception {
   log.info("before");
   super.before();
   server = byName(ORACLE_SERVER);
   assertNotNull(server);
   details = byName("Oracle Advanced Statistics");
   assertNotNull(details);
 }
 @Test(dependsOnMethods = {"testMetadataLevel"})
 public void testPlaneInfoZCT() {
   List<IObjectContainer> containers = store.getIObjectContainers(PlaneInfo.class);
   for (IObjectContainer container : containers) {
     PlaneInfo planeInfo = (PlaneInfo) container.sourceObject;
     assertNotNull("theZ is null", planeInfo.getTheZ());
     assertNotNull("theC is null", planeInfo.getTheC());
     assertNotNull("theT is null", planeInfo.getTheT());
   }
 }
Ejemplo n.º 24
0
  @Test
  public void testGetStudent() throws InvalidParametersException, EntityDoesNotExistException {
    int currentNumberOfStudent = studentsDb.getAllStudents().size();
    StudentAttributes s = createNewStudent();
    s.googleId = "validGoogleId";
    s.googleId = "validTeam";
    studentsDb.updateStudent(s.course, s.email, s.name, s.team, s.email, s.googleId, s.comments);

    ______TS("typical success case: existent");
    StudentAttributes retrieved = studentsDb.getStudentForEmail(s.course, s.email);
    assertNotNull(retrieved);
    assertNotNull(studentsDb.getStudentForRegistrationKey(retrieved.key));
    assertNotNull(studentsDb.getStudentForRegistrationKey(StringHelper.encrypt(retrieved.key)));
    assertNull(studentsDb.getStudentForRegistrationKey("notExistingKey"));
    ______TS("non existant student case");
    retrieved = studentsDb.getStudentForEmail("any-course-id", "*****@*****.**");
    assertNull(retrieved);

    StudentAttributes s2 = createNewStudent("*****@*****.**");
    s2.googleId = "validGoogleId2";
    studentsDb.updateStudent(
        s2.course, s2.email, s2.name, s2.team, s2.email, s2.googleId, s2.comments);
    studentsDb.deleteStudentsForGoogleId(s2.googleId);
    assertNull(studentsDb.getStudentForGoogleId(s2.course, s2.googleId));

    s2 = createNewStudent("*****@*****.**");
    assertEquals(
        true, studentsDb.getUnregisteredStudentsForCourse(s2.course).get(0).isEnrollInfoSameAs(s2));

    s2.googleId = null;
    studentsDb.updateStudent(
        s2.course, s2.email, s2.name, s2.team, s2.email, s2.googleId, s2.comments);
    assertEquals(
        true, studentsDb.getUnregisteredStudentsForCourse(s2.course).get(0).isEnrollInfoSameAs(s2));

    assertTrue(s.isEnrollInfoSameAs(studentsDb.getStudentsForGoogleId(s.googleId).get(0)));
    assertEquals(true, studentsDb.getStudentsForCourse(s.course).get(0).isEnrollInfoSameAs(s));
    assertEquals(
        true, studentsDb.getStudentsForTeam(s.team, s.course).get(0).isEnrollInfoSameAs(s));
    assertEquals(2 + currentNumberOfStudent, studentsDb.getAllStudents().size());

    ______TS("null params case");
    try {
      studentsDb.getStudentForEmail(null, "*****@*****.**");
      Assert.fail();
    } catch (AssertionError a) {
      assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, a.getMessage());
    }
    try {
      studentsDb.getStudentForEmail("any-course-id", null);
      Assert.fail();
    } catch (AssertionError a) {
      assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, a.getMessage());
    }
  }
Ejemplo n.º 25
0
  @Test
  public void testColumnCounts() {
    for (int i = 0; i < reader.getTableCount(); i++) {
      String[] names = reader.getColumnNames(i);
      Class[] types = reader.getColumnTypes(i);

      assertNotNull(names);
      assertNotNull(types);
      assertEquals(names.length, types.length);
    }
  }
Ejemplo n.º 26
0
  /**
   * Test fetching and translating resource schema.
   *
   * @throws Exception
   */
  @Test
  public void test400FetchResourceSchema() throws Exception {
    final String TEST_NAME = "test400FetchResourceSchema";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN

    // WHEN

    // The schema was fetched during test init. Now just check if it was OK.

    // THEN

    AssertJUnit.assertNotNull(resourceSchema);

    System.out.println(resourceSchema.debugDump());

    Document xsdSchema = resourceSchema.serializeToXsd();

    System.out.println(
        "-------------------------------------------------------------------------------------");
    System.out.println(DOMUtil.printDom(xsdSchema));
    System.out.println(
        "-------------------------------------------------------------------------------------");

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME));
    AssertJUnit.assertNotNull(accountDefinition);

    AssertJUnit.assertFalse(
        "No identifiers for account object class ", accountDefinition.getIdentifiers().isEmpty());

    PrismPropertyDefinition uidDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME));
    AssertJUnit.assertNotNull(uidDefinition);

    for (Definition def : resourceSchema.getDefinitions()) {
      if (def instanceof ResourceAttributeContainerDefinition) {
        ResourceAttributeContainerDefinition rdef = (ResourceAttributeContainerDefinition) def;
        assertNotEmpty("No type name in object class", rdef.getTypeName());
        assertNotEmpty(
            "No native object class for " + rdef.getTypeName(), rdef.getNativeObjectClass());

        // This is maybe not that important, but just for a sake of
        // completeness
        assertNotEmpty("No name for " + rdef.getTypeName(), rdef.getName());
      }
    }
  }
 /**
  * Verifies if the indexing interceptor is aware of a specific list of types.
  *
  * @param cache the cache containing the indexes
  * @param types vararg listing the types the indexing engine should know
  */
 private void assertIndexingKnows(Cache<Object, Object> cache, Class<?>... types) {
   ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
   SearchIntegrator searchIntegrator = cr.getComponent(SearchIntegrator.class);
   assertNotNull(searchIntegrator);
   Map<Class<?>, EntityIndexBinding> indexBindingForEntity =
       searchIntegrator.unwrap(ExtendedSearchIntegrator.class).getIndexBindings();
   assertNotNull(indexBindingForEntity);
   Set<Class<?>> keySet = indexBindingForEntity.keySet();
   assertEquals(types.length, keySet.size());
   assertTrue(keySet.containsAll(Arrays.asList(types)));
 }
 /** Access the conversion using the default conversion chain. */
 @Test(description = "4.3.1 Access and test conversion using the default provider chain.")
 @SpecAssertion(id = "431-A5", section = "4.3.1")
 public void testDefaultConversion() {
   ConversionQuery query =
       ConversionQueryBuilder.of().setTermCurrency(Monetary.getCurrency("USD")).build();
   CurrencyConversion conv = MonetaryConversions.getConversion(query);
   AssertJUnit.assertNotNull("No default CurrencyConversion returned for USD.", conv);
   query = ConversionQueryBuilder.of().setTermCurrency(Monetary.getCurrency("EUR")).build();
   conv = MonetaryConversions.getConversion(query);
   AssertJUnit.assertNotNull("No default CurrencyConversion returned for EUR.", conv);
 }
Ejemplo n.º 29
0
 @Test
 public void testGetAllBondsOfIssuerType() {
   final FudgeMsgEnvelope fme =
       getSecuritySourceResource().getBondsWithIssuerName("US TREASURY N/B");
   assertNotNull(fme);
   final FudgeMsg msg = fme.getMessage();
   assertNotNull(msg);
   FudgeMsgFormatter.outputToSystemOut(msg);
   final Collection<FudgeField> securities = msg.getAllByName(SECURITYSOURCE_SECURITY);
   assertNotNull(securities);
   assertEquals(1, securities.size());
 }
 @SuppressWarnings("rawtypes")
 public static void assertJSONObjectEquals(
     final JSONObject expectedJson, final JSONObject actualJson) throws Exception {
   assertNotNull(expectedJson);
   assertNotNull(actualJson);
   String expectedSorted =
       JSONValue.toJSONString(
           (Map) new JSONParser().parse(expectedJson.toString(), s_sortedJSONObjectFactory));
   String actualSorted =
       JSONValue.toJSONString(
           (Map) new JSONParser().parse(actualJson.toString(), s_sortedJSONObjectFactory));
   assertEquals(expectedSorted, actualSorted);
 }