public void testCountInSubQuery() {
    EntityManager em = createEntityManager();
    boolean testPass = false;
    ReportQuery mainQuery = new ReportQuery(Customer.class, new ExpressionBuilder());
    ReportQuery subQuery = new ReportQuery(Order.class, new ExpressionBuilder());
    subQuery.setSelectionCriteria(
        subQuery
            .getExpressionBuilder()
            .get("customer")
            .get("customerId")
            .equal(mainQuery.getExpressionBuilder().get("customerId")));
    subQuery.addCount("orderId");
    mainQuery.setSelectionCriteria(
        mainQuery.getExpressionBuilder().subQuery(subQuery).greaterThan(0));
    mainQuery.addAttribute("customerId");
    mainQuery.returnWithoutReportQueryResult();
    List expectedResult = (List) getServerSession().executeQuery(mainQuery);
    String ejbqlString =
        "SELECT c.customerId FROM Customer c WHERE (SELECT COUNT(o) FROM c.orders o) > 0";
    List result = em.createQuery(ejbqlString).getResultList();
    if (result.containsAll(expectedResult) && expectedResult.containsAll(result)) testPass = true;

    Assert.assertEquals("Count subquery test failed: data validation error", result.size(), 2);
    Assert.assertTrue("Count subquery test failed", testPass);
  }
  @Test
  public void testFolder() {
    List<String> cmisObjsNames = new ArrayList<String>();
    List<String> cmisObjsIds = new ArrayList<String>();

    try {
      CollectionIterable<CmisObject> cmisObjs =
          (CollectionIterable<CmisObject>)
              getConnector()
                  .folder(
                      null, folderObjectId.getId(), NavigationOptions.CHILDREN, 100, null, null);
      AbstractIterator<CmisObject> ai = cmisObjs.iterator();

      while (ai.hasNext()) {
        CmisObject cmisObj = ai.next();
        cmisObjsNames.add(cmisObj.getName());
        cmisObjsIds.add(cmisObj.getId());
      }

      assertTrue(cmisObjsNames.containsAll(subFoldersNames));
      assertTrue(cmisObjsIds.containsAll(subFoldersIds));
      assertEquals(cmisObjsNames.size(), subFoldersNames.size());

    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
  public void testExistsExpression() {
    EntityManager em = createEntityManager();
    boolean testPass = false;
    ExpressionBuilder employeeBuilder = new ExpressionBuilder(Employee.class);
    ExpressionBuilder managerBuilder = new ExpressionBuilder(Employee.class);
    ReportQuery mainQuery = new ReportQuery();
    ReportQuery subQuery = new ReportQuery();

    subQuery.setReferenceClass(Employee.class);
    Expression managerExpression =
        employeeBuilder.get("manager").get("id").equal(managerBuilder.get("id"));
    subQuery.addAttribute(
        "one", new ConstantExpression(new Integer(1), subQuery.getExpressionBuilder()));
    subQuery.setSelectionCriteria(managerExpression);
    Expression employeeExpression = employeeBuilder.exists(subQuery);

    mainQuery.setReferenceClass(Employee.class);
    mainQuery.setSelectionCriteria(employeeExpression);
    mainQuery.addAttribute("id");
    mainQuery.returnWithoutReportQueryResult();
    List expectedResult = (List) getServerSession().executeQuery(mainQuery);

    String ejbqlString =
        "SELECT DISTINCT emp.id FROM Employee emp WHERE EXISTS ( SELECT managedEmp.id FROM Employee managedEmp WHERE managedEmp = emp.manager)";
    List result = em.createQuery(ejbqlString).getResultList();

    if (result.containsAll(expectedResult) && expectedResult.containsAll(result)) testPass = true;
    // 8 employees with managers
    Assert.assertEquals("Exists Expression test failed: data validation error", result.size(), 8);
    Assert.assertTrue("Exists Expression test failed", testPass);
  }
Exemplo n.º 4
1
 public void checkIsCovering(List<String> oneAttrCombo) {
   // Get partition for this combination of non decision attributes
   Set<List<Integer>> singlePartition = computePartition(oneAttrCombo);
   // Check to see if it's a possible covering
   if (isCoveringCanidate(singlePartition, decisionPartition)) {
     System.out.println("Found one that could be a covering!");
     // For now, just put all covering canidates into our structure
     boolean foundLarger = false;
     boolean isLarger = false;
     List<String> temp = new ArrayList<String>();
     for (List<String> one : allCoverings) {
       if (one.containsAll(oneAttrCombo)) {
         foundLarger = true;
         temp = one;
       }
       if (oneAttrCombo.containsAll(one)) {
         isLarger = true;
       }
     }
     if (foundLarger) {
       allCoverings.remove(temp);
       allCoverings.add(oneAttrCombo);
     } else if (isLarger) {
       // Do nothing
     } else {
       allCoverings.add(oneAttrCombo);
     }
   }
 }
Exemplo n.º 5
0
  @Test
  public void testToListWithHashtable() {
    final Hashtable<String, Integer> expected = new Hashtable<String, Integer>();
    expected.put("one", Integer.valueOf(1));
    expected.put("two", Integer.valueOf(2));
    expected.put("three", Integer.valueOf(3));
    // validate elements.
    final List<Integer> actualEltList = EnumerationUtils.toList(expected.elements());
    assertEquals(expected.size(), actualEltList.size());
    assertTrue(actualEltList.contains(Integer.valueOf(1)));
    assertTrue(actualEltList.contains(Integer.valueOf(2)));
    assertTrue(actualEltList.contains(Integer.valueOf(3)));
    final List<Integer> expectedEltList = new ArrayList<Integer>();
    expectedEltList.add(Integer.valueOf(1));
    expectedEltList.add(Integer.valueOf(2));
    expectedEltList.add(Integer.valueOf(3));
    assertTrue(actualEltList.containsAll(expectedEltList));

    // validate keys.
    final List<String> actualKeyList = EnumerationUtils.toList(expected.keys());
    assertEquals(expected.size(), actualEltList.size());
    assertTrue(actualKeyList.contains("one"));
    assertTrue(actualKeyList.contains("two"));
    assertTrue(actualKeyList.contains("three"));
    final List<String> expectedKeyList = new ArrayList<String>();
    expectedKeyList.add("one");
    expectedKeyList.add("two");
    expectedKeyList.add("three");
    assertTrue(actualKeyList.containsAll(expectedKeyList));
  }
Exemplo n.º 6
0
  public static void pushAppToCF(
      boolean mig_service, AppModel model, CloudFoundryClient cfClient, String app_dir)
      throws IOException {

    // Should first start the applications with depended on capability
    List<String> depended_on_apps = model.getAppNamesWithDependedOnCapability();
    startDependedOnApplications(depended_on_apps, mig_service, model, cfClient, app_dir);

    // Then start the applications with depends on requirement
    List<String> depends_on_apps = model.getAppNamesWithDependsOnRequirement();
    startDependsOnApplications(depends_on_apps, mig_service, model, cfClient, app_dir);

    // Finally start the standalone applications
    // remove all the depended_on and depends_on applications from the original list
    List<WebAppNode> webapps = model.getWebApps();
    List<String> web_app_names = new ArrayList<String>();
    for (WebAppNode webapp : webapps) {
      web_app_names.add(webapp.getName());
    }

    if (web_app_names.containsAll(depended_on_apps)) {
      web_app_names.removeAll(depended_on_apps);
    }
    if (web_app_names.containsAll(depends_on_apps)) {
      web_app_names.removeAll(depends_on_apps);
    }
    // start the remained standalone applications
    if (web_app_names != null && web_app_names.size() > 0) {
      startApplications(web_app_names, mig_service, model, cfClient, app_dir);
    }
  }
Exemplo n.º 7
0
  /** This is a unit test for the following enum : {@link com.smartdevicelink.trace.enums.Mod} */
  public void testModEnum() {

    // TestValues
    String testApp = "app";
    String testRpc = "rpc";
    String testMar = "mar";
    String testTran = "tran";
    String testProto = "proto";
    String testProxy = "proxy";
    String testInvalid = "invalid";

    try {
      // Comparison Values
      Mod expectedAppEnum = Mod.app;
      Mod expectedRpcEnum = Mod.rpc;
      Mod expectedMarEnum = Mod.mar;
      Mod expectedTranEnum = Mod.tran;
      Mod expectedProtoEnum = Mod.proto;
      Mod expectedProxyEnum = Mod.proxy;
      List<Mod> expectedEnumList = new ArrayList<Mod>();
      expectedEnumList.add(Mod.app);
      expectedEnumList.add(Mod.rpc);
      expectedEnumList.add(Mod.mar);
      expectedEnumList.add(Mod.tran);
      expectedEnumList.add(Mod.proto);
      expectedEnumList.add(Mod.proxy);

      Mod actualNullEnum = Mod.valueForString(null);
      Mod actualAppEnum = Mod.valueForString(testApp);
      Mod actualRpcEnum = Mod.valueForString(testRpc);
      Mod actualMarEnum = Mod.valueForString(testMar);
      Mod actualTranEnum = Mod.valueForString(testTran);
      Mod actualProtoEnum = Mod.valueForString(testProto);
      Mod actualProxyEnum = Mod.valueForString(testProxy);
      Mod actualInvalidEnum = Mod.valueForString(testInvalid);
      List<Mod> actualEnumList = Arrays.asList(Mod.values());

      // Valid Tests
      assertEquals(Test.MATCH, expectedAppEnum, actualAppEnum);
      assertEquals(Test.MATCH, expectedRpcEnum, actualRpcEnum);
      assertEquals(Test.MATCH, expectedMarEnum, actualMarEnum);
      assertEquals(Test.MATCH, expectedTranEnum, actualTranEnum);
      assertEquals(Test.MATCH, expectedProtoEnum, actualProtoEnum);
      assertEquals(Test.MATCH, expectedProxyEnum, actualProxyEnum);
      assertTrue(
          Test.ARRAY,
          expectedEnumList.containsAll(actualEnumList)
              && actualEnumList.containsAll(expectedEnumList));

      // Invalid/Null Tests
      assertNull(Test.NULL, actualInvalidEnum);
      assertNull(Test.NULL, actualNullEnum);

    } catch (NullPointerException e) {
      fail("Could not retrieve value for null string, should return null.");
    } catch (IllegalArgumentException e) {
      fail("Could not retrieve value for invalid string, should return null.");
    }
  }
Exemplo n.º 8
0
Arquivo: Ex6.java Projeto: yehaote/mi
 public static void main(String[] args) {
   Random rand = new Random(47);
   // 生成新的String序列
   List<String> ls = new ArrayList<String>();
   print("0: " + ls);
   Collections.addAll(ls, "oh", "what", "a", "beautiful", "Manila", "Monday", "morning");
   print("1: " + ls);
   // 增加新元素
   String h = new String("hi");
   ls.add(h); // Automatically resizes
   print("2: " + ls);
   print("3: " + ls.contains(h));
   ls.remove(h); // Remove by object
   String n = ls.get(2);
   print("4: " + n + " " + ls.indexOf(n));
   String m = new String("cy");
   print("5: " + ls.indexOf(m));
   print("6: " + ls.remove(m));
   // Must be the exact object
   print("7: " + ls.remove(n));
   print("8: " + ls);
   ls.add(3, new String("wonderful"));
   print("9: " + ls);
   List<String> sub = ls.subList(1, 4);
   print("sublist: " + sub);
   print("10: " + ls.containsAll(sub));
   Collections.sort(sub); // In-place sort
   print("sorted subList: " + sub);
   // Order is not important in containsAll();
   print("11: " + ls.containsAll(sub));
   Collections.shuffle(sub, rand);
   print("12: " + ls.containsAll(sub));
   List<String> copy = new ArrayList<String>(ls);
   sub = Arrays.asList(ls.get(1), ls.get(4)); // 跟书上结果好像不一样
   print("sub: " + sub);
   copy.retainAll(sub);
   print("13: " + copy);
   copy = new ArrayList<String>(ls); // Get a fresh copy
   copy.remove(2);
   print("14: " + copy);
   copy.removeAll(sub); // Only remove exact objects
   print("15: " + copy);
   copy.set(1, new String("hello")); // Replace an elements
   print("16: " + copy);
   copy.addAll(2, sub); // Insert a list in the middle
   print("17: " + copy);
   print("18: " + ls.isEmpty());
   ls.clear();
   print("19: " + ls);
   print("20: " + ls.isEmpty());
   List<String> ts = new ArrayList<String>();
   Collections.addAll(ts, "one", "two", "three", "four");
   ls.addAll(ts);
   print("21: " + ls);
   Object[] o = ls.toArray();
   print("22: " + o[3]);
   String[] pa = ls.toArray(new String[0]);
   print("23: " + pa[3]);
 }
Exemplo n.º 9
0
 @SuppressWarnings("unchecked")
 public boolean containsAll(final Collection<?> objs) {
   if (objs instanceof JaxbListWrapper) {
     return m_objects.containsAll(((JaxbListWrapper<? extends T>) objs).getObjects());
   } else {
     return m_objects.containsAll(objs);
   }
 }
Exemplo n.º 10
0
  @Test
  /**
   * Ensures that the findUniqueReportClass() method returns a set of report classes without
   * returning duplicates.
   *
   * @throws Exception
   */
  public void testFindSubClassesByReportClass() throws Exception {
    String reportClass = "classA";

    CtlDocClass class1 = new CtlDocClass();
    EntityDataGenerator.generateTestDataForModelClass(class1);
    class1.setReportClass(reportClass);
    class1.setSubClass("subA");
    class1.setId(160);

    CtlDocClass class2 = new CtlDocClass();
    EntityDataGenerator.generateTestDataForModelClass(class2);
    class2.setReportClass(reportClass);
    class2.setSubClass("subB");
    class2.setId(161);

    CtlDocClass class3 = new CtlDocClass();
    EntityDataGenerator.generateTestDataForModelClass(class3);
    class3.setReportClass("classB");
    class3.setSubClass("subC");
    class3.setId(162);

    CtlDocClass class4 = new CtlDocClass();
    EntityDataGenerator.generateTestDataForModelClass(class4);
    class4.setReportClass("classC");
    class4.setSubClass("subD");
    class4.setId(163);

    dao.persist(class1);
    dao.persist(class2);
    dao.persist(class3);
    dao.persist(class4);

    List<String> result = dao.findSubClassesByReportClass(reportClass);
    List<String> expectedResult = new ArrayList<String>(Arrays.asList("subA", "subB"));

    assertEquals(result.size(), expectedResult.size());
    assertTrue(result.containsAll(expectedResult));
    // ensure that all persisted items are in the table
    // ensure ordered by reportclass lexicographically
    String str1;
    String str2;
    for (int i = 0; i < result.size() - 1; i++) {
      str1 = result.get(i);
      str2 = result.get(i + 1);
      if (str1.compareTo(str2) > -1) {
        fail("Results not ordred by sub class.");
      }
    }
    assertTrue(true);
    assertTrue(result.containsAll(expectedResult));
  }
Exemplo n.º 11
0
  private boolean haveSameGenotypes(Genotype g1, Genotype g2) {
    if ((g1.isCalled() && g2.isFiltered())
        || (g2.isCalled() && g1.isFiltered())
        || (g1.isFiltered() && g2.isFiltered() && EXCLUDE_FILTERED)) return false;

    List<Allele> a1s = g1.getAlleles();
    List<Allele> a2s = g2.getAlleles();
    return (a1s.containsAll(a2s) && a2s.containsAll(a1s));
  }
 /** containsAll returns true for collection with subset of elements */
 public void testContainsAll() {
   List full = populatedArray(3);
   Vector v = new Vector();
   v.add(one);
   v.add(two);
   assertTrue(full.containsAll(v));
   v.add(six);
   assertFalse(full.containsAll(v));
 }
  private void compareComments(
      de.uni_koblenz.jgralab.schema.NamedElementClass element, NamedElementClass gElement) {

    List<String> comments = element.getComments();
    List<String> gComments = retrieveComments(gElement);

    comments.containsAll(gComments);
    gComments.containsAll(comments);
  }
 @Override
 public synchronized boolean containsAll(Collection c) {
   if (c instanceof PyList) {
     return list.containsAll(((PyList) c).list);
   } else if (c instanceof PyTuple) {
     return list.containsAll(((PyTuple) c).getList());
   } else {
     return list.containsAll(new PyList(c));
   }
 }
Exemplo n.º 15
0
 @Override
 public boolean equals(Object obj) {
   if (obj instanceof OverloadedFunction) {
     OverloadedFunction other = (OverloadedFunction) obj;
     return primaryCandidates.containsAll(other.primaryCandidates)
         && other.primaryCandidates.containsAll(primaryCandidates)
         && defaultCandidates.containsAll(other.defaultCandidates)
         && other.defaultCandidates.containsAll(defaultCandidates);
   }
   return false;
 }
  /**
   * Compares two EnumDomain objects with each other.
   *
   * @param domain EnumDomain from the Schema, which should be compared.
   * @param gDomain EnumDomain from the SchemaGraph, which should be compared.
   */
  private final void compareDomain(
      de.uni_koblenz.jgralab.schema.EnumDomain domain, EnumDomain gDomain) {

    List<String> enumConstants = domain.getConsts();
    List<String> gEnumConstants = gDomain.get_enumConstants();

    assertTrue(
        "The size of enum constants are not equal.", enumConstants.size() == gEnumConstants.size());

    assertTrue("Not all Constants are included.", gEnumConstants.containsAll(enumConstants));
    assertTrue("Not all Constants are included.", enumConstants.containsAll(gEnumConstants));
  }
Exemplo n.º 17
0
  // Done inefficiently so as to exercise toArray
  static List clone(List s) {
    List a = Arrays.asList(s.toArray());
    if (s.hashCode() != a.hashCode()) fail("Incorrect hashCode computation.");

    List clone = newList();
    clone.addAll(a);
    if (!s.equals(clone)) fail("List not equal to copy.");
    if (!s.containsAll(clone)) fail("List does not contain copy.");
    if (!clone.containsAll(s)) fail("Copy does not contain list.");

    return clone;
  }
Exemplo n.º 18
0
 @Test
 public void listAddAllInOne() {
   List<String> firstList = newLinkedList("a", "b", "c");
   List<String> secondList = newLinkedList("d", "e", "f");
   List<String> combined = flatArrayList(firstList, secondList);
   List<String> linkedCombined = flatLinkedList(firstList, secondList);
   assertEquals(firstList.size() + secondList.size(), combined.size());
   assertTrue(combined.containsAll(firstList));
   assertTrue(combined.containsAll(secondList));
   assertEquals(combined.subList(0, 3), firstList);
   assertEquals(combined.subList(3, 6), secondList);
   assertEquals(combined, linkedCombined);
 }
Exemplo n.º 19
0
  static void equate(Generator gen, Expression expr, QFrame left, QFrame right) {
    Expression lexpr = left.getExpression();
    Expression rexpr = right.getExpression();

    List lvals = left.getValues();
    List rvals = right.getValues();

    List lnull = gen.getNull(lexpr);
    List rnull = gen.getNull(rexpr);

    if (lvals.size() != rvals.size()) {
      if (lvals.size() == 1 && lnull.containsAll(lvals)) {
        lvals = repeat(lvals.get(0), rvals.size());
      } else if (rvals.size() == 1 && rnull.containsAll(rvals)) {
        rvals = repeat(rvals.get(0), lvals.size());
      } else {
        throw new IllegalStateException(
            "cardinality mismatch\nlvals: "
                + lvals
                + "\nrvals: "
                + rvals
                + "\nleft: "
                + lexpr
                + "\nright: "
                + rexpr);
      }
    }

    List lnonnull = gen.getNonNull(lexpr);
    List rnonnull = gen.getNonNull(rexpr);

    for (int i = 0; i < lvals.size(); i++) {
      QValue lval = (QValue) lvals.get(i);
      QValue rval = (QValue) rvals.get(i);
      gen.addEquality(expr, lval, rval);
      if (lnull.contains(lval)) {
        gen.addNull(expr, rval);
      }
      if (lnonnull.contains(lval)) {
        gen.addNonNull(expr, rval);
      }
      if (rnull.contains(rval)) {
        gen.addNull(expr, lval);
      }
      if (rnonnull.contains(rval)) {
        gen.addNonNull(expr, lval);
      }
    }

    gen.addSufficient(expr);
  }
  private void verifyProcessEntityEdges() {
    Vertex processVertex = getEntityVertex(PROCESS_ENTITY_NAME, RelationshipType.PROCESS_ENTITY);

    // verify edge to cluster vertex
    verifyVertexForEdge(
        processVertex,
        Direction.OUT,
        RelationshipLabel.FEED_CLUSTER_EDGE.getName(),
        CLUSTER_ENTITY_NAME,
        RelationshipType.CLUSTER_ENTITY.getName());
    // verify edge to user vertex
    verifyVertexForEdge(
        processVertex,
        Direction.OUT,
        RelationshipLabel.USER.getName(),
        FALCON_USER,
        RelationshipType.USER.getName());
    // verify edge to tags vertex
    verifyVertexForEdge(
        processVertex, Direction.OUT, "classified-as", "Critical", RelationshipType.TAGS.getName());

    // verify edges to inputs
    List<String> actual = new ArrayList<String>();
    for (Edge edge :
        processVertex.getEdges(Direction.IN, RelationshipLabel.FEED_PROCESS_EDGE.getName())) {
      Vertex outVertex = edge.getVertex(Direction.OUT);
      Assert.assertEquals(
          RelationshipType.FEED_ENTITY.getName(),
          outVertex.getProperty(RelationshipProperty.TYPE.getName()));
      actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName()));
    }

    Assert.assertTrue(
        actual.containsAll(Arrays.asList("impression-feed", "clicks-feed")),
        "Actual does not contain expected: " + actual);

    actual.clear();
    // verify edges to outputs
    for (Edge edge :
        processVertex.getEdges(Direction.OUT, RelationshipLabel.PROCESS_FEED_EDGE.getName())) {
      Vertex outVertex = edge.getVertex(Direction.IN);
      Assert.assertEquals(
          RelationshipType.FEED_ENTITY.getName(),
          outVertex.getProperty(RelationshipProperty.TYPE.getName()));
      actual.add(outVertex.<String>getProperty(RelationshipProperty.NAME.getName()));
    }
    Assert.assertTrue(
        actual.containsAll(Arrays.asList("imp-click-join1", "imp-click-join2")),
        "Actual does not contain expected: " + actual);
  }
  public boolean areProcessClustersSame(
      List<org.apache.falcon.entity.v0.process.Cluster> oldClusters,
      List<org.apache.falcon.entity.v0.process.Cluster> newClusters) {
    if (oldClusters.size() != newClusters.size()) {
      return false;
    }

    List<String> oldClusterNames = getProcessClusterNames(oldClusters);
    List<String> newClusterNames = getProcessClusterNames(newClusters);

    return oldClusterNames.size() == newClusterNames.size()
        && oldClusterNames.containsAll(newClusterNames)
        && newClusterNames.containsAll(oldClusterNames);
  }
Exemplo n.º 22
0
  @Test
  public void testPluginsList() {
    Collection<Plugin> pluginList = Plugins.list();

    List<String> expectedPluginIds =
        Arrays.asList(new String[] {"local", "unreliable_local", "dummy"});
    List<String> actualPluginIds = new ArrayList<String>();

    for (Plugin plugin : pluginList) {
      actualPluginIds.add(plugin.getId());
    }

    assertTrue(expectedPluginIds.containsAll(actualPluginIds));
    assertTrue(actualPluginIds.containsAll(expectedPluginIds));
  }
Exemplo n.º 23
0
  public static void compareTwoArrayList() {

    Pessoa bobo = new Pessoa("Bob", LocalDate.of(1985, 9, 1));
    Pessoa andre1 = new Pessoa("André", LocalDate.of(1978, 1, 2));
    Pessoa andre2 = new Pessoa("André", LocalDate.of(1978, 1, 1));

    List<Pessoa> pessoas = new ArrayList<>();
    pessoas.add(bobo);
    pessoas.add(andre1);
    pessoas.add(andre2);

    List<Pessoa> pessoas2 = new ArrayList<>();
    pessoas2.add(new Pessoa("Alonso", LocalDate.of(1989, 9, 1)));
    pessoas2.add(new Pessoa("Jamerson", LocalDate.of(1981, 1, 2)));
    pessoas2.add(new Pessoa("Lindomar", LocalDate.of(1973, 1, 1)));

    List<Pessoa> pessoas3 = new ArrayList<>();
    pessoas3.add(bobo);
    pessoas3.add(andre1);
    pessoas3.add(andre2);

    List<Pessoa> pessoas4 = new ArrayList<>();
    pessoas4.add(new Pessoa("Alonso", LocalDate.of(1989, 9, 1)));
    pessoas4.add(new Pessoa("Jamerson", LocalDate.of(1981, 1, 2)));
    pessoas4.add(new Pessoa("Lindomar", LocalDate.of(1973, 1, 1)));

    List<Pessoa> pessoas5 = new ArrayList<>();
    pessoas5.add(new Pessoa("Lindomar", LocalDate.of(1973, 1, 1)));
    pessoas5.add(new Pessoa("Alonso", LocalDate.of(1989, 9, 1)));
    pessoas5.add(new Pessoa("Jamerson", LocalDate.of(1981, 1, 2)));

    // 01
    boolean iguais = pessoas.equals(pessoas2);
    System.out.println(iguais);

    // 02
    iguais = pessoas.equals(pessoas3);
    System.out.println(iguais);

    // 03
    iguais = pessoas2.equals(pessoas4);
    System.out.println(iguais);

    // 04
    iguais = pessoas4.containsAll(pessoas5);
    boolean iguais2 = pessoas5.containsAll(pessoas4);
    System.out.println(iguais && iguais2);
  }
  @Test
  public void testLineageForNoDateInFeedPath() throws Exception {
    setupForNoDateInFeedPath();

    WorkflowExecutionContext context =
        WorkflowExecutionContext.create(
            getTestMessageArgs(
                EntityOperations.GENERATE,
                GENERATE_WORKFLOW_NAME,
                null,
                OUTPUT_INSTANCE_PATHS_NO_DATE,
                INPUT_INSTANCE_PATHS_NO_DATE,
                null),
            WorkflowExecutionContext.Type.POST_PROCESSING);
    service.onSuccess(context);

    debug(service.getGraph());
    GraphUtils.dump(service.getGraph());

    // Verify if instance name has nominal time
    List<String> feedNamesOwnedByUser =
        getFeedsOwnedByAUser(RelationshipType.FEED_INSTANCE.getName());
    List<String> expected =
        Arrays.asList(
            "impression-feed/2014-01-01T01:00Z",
            "clicks-feed/2014-01-01T01:00Z",
            "imp-click-join1/2014-01-01T01:00Z",
            "imp-click-join2/2014-01-01T01:00Z");
    Assert.assertTrue(feedNamesOwnedByUser.containsAll(expected));

    // +5 = 1 process, 2 inputs, 2 outputs
    Assert.assertEquals(getVerticesCount(service.getGraph()), 22);
    // +34 = +26 for feed instances + 8 for process instance
    Assert.assertEquals(getEdgesCount(service.getGraph()), 65);
  }
Exemplo n.º 25
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   RangeAxisContainer other = (RangeAxisContainer) obj;
   if (cells == null) {
     if (other.cells != null) {
       return false;
     }
   } else if (!cells.containsAll(other.cells)) {
     return false;
   }
   if (name == null) {
     if (other.name != null) {
       return false;
     }
   } else if (!name.equals(other.name)) {
     return false;
   }
   return true;
 }
Exemplo n.º 26
0
  private String clusterSizes(List<List<Node>> partition, List<List<Node>> trueClusters) {
    String s = "";

    FOR:
    for (int i = 0; i < partition.size(); i++) {
      List<Node> cluster = partition.get(i);
      s += cluster.size();

      for (List<Node> trueCluster : trueClusters) {
        if (trueCluster.containsAll(cluster)) {
          //                    Collections.sort(trueCluster);
          //                    Collections.sort(cluster);
          //                    System.out.println(trueCluster + " " + cluster);
          s += "p";

          if (i < partition.size() - 1) {
            s += ",";
          }

          continue FOR;
        }
      }

      if (i < partition.size() - 1) {
        s += ",";
      }
    }

    return s;
  }
Exemplo n.º 27
0
  @Test
  public void testMultipleConcurrentEPs3() {
    final KieSession ksession = getKieSessionWith3Segments();

    List<String> results = new ArrayList<String>();
    ksession.setGlobal("results", results);

    EPManipulator3[] epManipulators = new EPManipulator3[9];
    for (int i = 0; i < 9; i++) {
      epManipulators[i] = new EPManipulator3(ksession, i + 1);
    }

    for (int deleteIndex = 0; deleteIndex < 11; deleteIndex++) {
      boolean success = true;
      CompletionService<Boolean> ecs = new ExecutorCompletionService<Boolean>(executor);
      for (int i = 0; i < 9; i++) {
        ecs.submit(epManipulators[i].setDeleteIndex(deleteIndex % 10));
      }

      for (int i = 1; i < 10; i++) {
        try {
          success = ecs.take().get() && success;
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }

      assertTrue(success);

      new Thread() {
        public void run() {
          ksession.fireUntilHalt();
        }
      }.start();

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }

      ksession.halt();

      if (deleteIndex % 10 == 0) {
        assertEquals(3, results.size());
        assertTrue(results.containsAll(asList("R1", "R2", "R3")));
      } else {
        if (!results.isEmpty()) {
          fail(
              "Results should be empty with deleteIndex = "
                  + deleteIndex
                  + "; got "
                  + results.size()
                  + " items");
        }
      }

      results.clear();
    }
  }
  private void verifyLineageGraph(
      String feedType,
      List<String> expectedFeeds,
      List<String> secureFeeds,
      List<String> ownedAndSecureFeeds) {
    // feeds owned by a user
    List<String> feedNamesOwnedByUser = getFeedsOwnedByAUser(feedType);
    Assert.assertTrue(feedNamesOwnedByUser.containsAll(expectedFeeds));

    Graph graph = service.getGraph();

    Iterator<Vertex> vertices =
        graph.getVertices("name", "impression-feed/2014-01-01T00:00Z").iterator();
    Assert.assertTrue(vertices.hasNext());
    Vertex feedInstanceVertex = vertices.next();
    Assert.assertEquals(
        feedInstanceVertex.getProperty(RelationshipProperty.TYPE.getName()),
        RelationshipType.FEED_INSTANCE.getName());

    Object vertexId = feedInstanceVertex.getId();
    Vertex vertexById = graph.getVertex(vertexId);
    Assert.assertEquals(vertexById, feedInstanceVertex);

    // feeds classified as secure
    verifyFeedsClassifiedAsSecure(feedType, secureFeeds);

    // feeds owned by a user and classified as secure
    verifyFeedsOwnedByUserAndClassification(feedType, "Financial", ownedAndSecureFeeds);
  }
  /**
   * Checks Content Assist content on specified position within editor with editorTitle and checks
   * if expectedProposalList is equal to current Proposal List
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedProposalList
   * @param mustEquals
   */
  public static SWTBotEditor checkContentAssistContent(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      List<String> expectedProposalList,
      boolean mustEquals) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    ContentAssistBot contentAssist = editor.contentAssist();
    List<String> currentProposalList = contentAssist.getProposalList();
    assertTrue(
        "Code Assist menu has incorrect menu items.\n"
            + "Expected Proposal Menu Labels vs. Current Proposal Menu Labels :\n"
            + FormatUtils.getListsDiffFormatted(expectedProposalList, currentProposalList),
        mustEquals
            ? expectedProposalList.equals(currentProposalList)
            : currentProposalList.containsAll(expectedProposalList));

    return editor;
  }
Exemplo n.º 30
0
  public void testExtendPrivileges() throws NotExecutableException, RepositoryException {
    checkCanModifyAc(path);
    // search 2 non-aggregated privileges
    List<Privilege> twoPrivs = new ArrayList<Privilege>(2);
    for (int i = 0; i < privs.length && twoPrivs.size() < 2; i++) {
      if (!privs[i].isAggregate()) {
        twoPrivs.add(privs[i]);
      }
    }
    if (twoPrivs.size() < 2) {
      throw new NotExecutableException(
          "At least 2 supported, non-aggregate privileges required at " + path);
    }

    AccessControlList acl = getList(acMgr, path);
    Privilege privilege = twoPrivs.get(0);
    // add first privilege:
    acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege});

    // add a second privilege (but not specifying the privilege added before)
    // -> the first privilege must not be removed.
    Privilege privilege2 = twoPrivs.get(1);
    acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege2});

    List<Privilege> currentPrivileges = currentPrivileges(acl, testPrincipal);
    assertTrue(
        "'AccessControlList.addAccessControlEntry' must not remove privileges added before",
        currentPrivileges.containsAll(twoPrivs));
  }