Пример #1
0
    @Override
    public VersionObject deserialize(
        JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
      VersionObject obj = new VersionObject();
      obj.artifacts = new LinkedList<Artifact>();

      JsonObject groupLevel = json.getAsJsonObject().getAsJsonObject("artefacts");

      // itterate over the groups
      for (Entry<String, JsonElement> groupE : groupLevel.entrySet()) {
        String group = groupE.getKey();

        // itterate over the artefacts in the groups
        for (Entry<String, JsonElement> artifactE :
            groupE.getValue().getAsJsonObject().entrySet()) {
          Artifact artifact = context.deserialize(artifactE.getValue(), Artifact.class);
          artifact.group = group;

          if ("latest".equals(artifactE.getKey())) {
            obj.latest = artifact;
          } else {
            obj.artifacts.add(artifact);
          }
        }
      }

      return obj;
    }
Пример #2
0
  private void updateWatchedRoots() {
    Set<String> pathsToRemove = new HashSet<String>(myWatchedOutputs.keySet());
    Set<String> toAdd = new HashSet<String>();
    for (Artifact artifact : getArtifacts()) {
      final String path = artifact.getOutputPath();
      if (path != null && path.length() > 0) {
        pathsToRemove.remove(path);
        if (!myWatchedOutputs.containsKey(path)) {
          toAdd.add(path);
        }
      }
    }

    List<LocalFileSystem.WatchRequest> requestsToRemove =
        new ArrayList<LocalFileSystem.WatchRequest>();
    for (String path : pathsToRemove) {
      final LocalFileSystem.WatchRequest request = myWatchedOutputs.remove(path);
      ContainerUtil.addIfNotNull(request, requestsToRemove);
    }

    Set<LocalFileSystem.WatchRequest> newRequests =
        LocalFileSystem.getInstance().replaceWatchedRoots(requestsToRemove, toAdd, null);
    for (LocalFileSystem.WatchRequest request : newRequests) {
      myWatchedOutputs.put(request.getRootPath(), request);
    }
  }
    private ACLMessage handleProfilerRequest(ACLMessage request) {
      AID profiler = request.getSender();
      ArrayList<Integer> requestedIDs;
      try {
        requestedIDs = (ArrayList<Integer>) request.getContentObject();
        // System.out.println(getName() + ": Received request from Profiler. He requested " +
        // requestedIDs.size() + " IDs.");
      } catch (UnreadableException e) {
        System.err.println(
            myAgent.getAID().getName()
                + ": Couldn't get IDs to look up. Will respond with an empty list...");
        requestedIDs = new ArrayList<>();
      }
      String conversationID = request.getConversationId();
      ArrayList<Artifact> relatedArtifacts = new ArrayList<>();

      for (Integer id : requestedIDs)
        for (Artifact a : artifacts) if (a.getId() == id) relatedArtifacts.add(a);

      ACLMessage response = new ACLMessage(ACLMessage.INFORM);
      response.addReceiver(profiler);
      response.setConversationId(conversationID);
      response.setOntology("tour-info");
      try {
        response.setContentObject(relatedArtifacts);
      } catch (IOException e) {
        System.err.println(
            myAgent.getAID().getName()
                + ": Couldn't serialize the Artifact list... Will cause problems with other agents.");
      }
      return response;
      // System.out.println(myAgent.getAID().getName() + ":Response message sent to Profiler with "
      // + relatedArtifacts.size() + " artifacts.");
    }
  @Test
  public void testPOJOSearchWithoutSearchHandle() {
    PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class);
    PojoPage<Artifact> p;
    this.loadSimplePojos(products);
    QueryManager queryMgr = client.newQueryManager();
    StringQueryDefinition qd = queryMgr.newStringDefinition();
    qd.setCriteria("Widgets");

    products.setPageLength(11);
    p = products.search(qd, 1);
    assertEquals("total no of pages", 5, p.getTotalPages());
    System.out.println(p.getTotalPages());
    long pageNo = 1, count = 0;
    do {
      count = 0;

      p = products.search(qd, pageNo);

      while (p.iterator().hasNext()) {
        Artifact a = p.iterator().next();
        validateArtifact(a);
        assertTrue("Artifact Id is odd", a.getId() % 2 != 0);
        assertTrue(
            "Company name contains widgets", a.getManufacturer().getName().contains("Widgets"));
        count++;
        //				System.out.println(a.getId()+" "+a.getManufacturer().getName() +"  "+count);
      }
      assertEquals("Page size", count, p.size());
      pageNo = pageNo + p.getPageSize();
    } while (!p.isLastPage() && pageNo < p.getTotalSize());
    assertEquals("page number after the loop", 5, p.getPageNumber());
    assertEquals("total no of pages", 5, p.getTotalPages());
  }
  protected List<Artifact> parseArtifacts(int parentNestingLevel, String... lines) {
    List<Artifact> foundArtifacts = new ArrayList<>();

    // find all lines for "this" artifact
    for (int i = 1; i < lines.length; i++) {
      String line = lines[i];

      if (line.equals("No dependencies")) {
        return foundArtifacts;
      }

      int lineNestingLevel = parseNestingLevel(line);

      // dependencies of the current artifact
      if (lineNestingLevel == (parentNestingLevel + 1)) {
        String[] newLines = getArtifactLines(new Pointer(i), lines);
        Artifact artifact = new Artifact(line, masterArtifactList);

        foundArtifacts.add(artifact);
        addArtifact(artifact);
        artifact.parseArtifacts(lineNestingLevel, newLines);
        i += newLines.length - 1;
      } else // lineNestingLevel < currentNestingLevel
      {
        // currentArtifact = currentArtifact.getParent();
        // addChildArtifact(this, line);
        return foundArtifacts; // pop off the stack
      }
    }

    return foundArtifacts;
  }
  @Test(expected = ClassCastException.class)
  public void testPOJOqbeSearchWithSearchHandle() {
    PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class);
    PojoPage<Artifact> p;
    this.loadSimplePojos(products);

    QueryManager queryMgr = client.newQueryManager();
    String queryAsString =
        "{\"$query\":{"
            + "\"$and\":[{\"inventory\":{\"$gt\":1010}},{\"inventory\":{\"$le\":1110}}]"
            + ",\"$filtered\": true}}";
    System.out.println(queryAsString);
    PojoQueryDefinition qd =
        (PojoQueryDefinition)
            queryMgr.newRawQueryByExampleDefinition(
                new StringHandle(queryAsString).withFormat(Format.JSON));
    qd.setCollections("even");
    SearchHandle results = new SearchHandle();
    products.setPageLength(10);
    p = products.search(qd, 1, results);
    assertEquals("total no of pages", 5, p.getTotalPages());
    System.out.println(p.getTotalPages());
    //		System.out.println(results.getMetrics().getQueryResolutionTime());
    long pageNo = 1, count = 0;
    do {
      count = 0;
      p = products.search(qd, pageNo, results);

      while (p.iterator().hasNext()) {
        Artifact a = p.iterator().next();
        validateArtifact(a);
        assertTrue(
            "Enventory lies between 1010 to 1110",
            a.getInventory() > 1010 && a.getInventory() <= 1110);
        assertTrue("Artifact Id is even", a.getId() % 2 == 0);
        assertTrue("Company name contains Acme", a.getManufacturer().getName().contains("Acme"));
        count++;
        //				System.out.println(a.getId()+" "+a.getManufacturer().getName() +"  "+count);
      }
      assertEquals("Page size", count, p.size());
      pageNo = pageNo + p.getPageSize();
      MatchDocumentSummary[] mds = results.getMatchResults();
      assertEquals("Size of the results summary", 10, mds.length);
      for (MatchDocumentSummary md : mds) {
        assertTrue("every uri should contain the class name", md.getUri().contains("Artifact"));
      }
      String[] facetNames = results.getFacetNames();
      for (String fname : facetNames) {
        System.out.println(fname);
      }
      //			assertEquals("Total results from search handle ",50,results.getTotalResults());
      //			assertTrue("Search Handle metric results ",results.getMetrics().getTotalTime()>0);
    } while (!p.isLastPage() && pageNo < p.getTotalSize());
    assertEquals("Page start check", 41, p.getStart());
    assertEquals("page number after the loop", 5, p.getPageNumber());
    assertEquals("total no of pages", 5, p.getTotalPages());
  }
  @Test(expected = ClassCastException.class)
  public void testPOJOCombinedSearchWithJacksonHandle() {
    PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class);
    PojoPage<Artifact> p;
    this.loadSimplePojos(products);
    QueryManager queryMgr = client.newQueryManager();
    String queryAsString =
        "{\"search\":{\"query\":{\"and-query\":["
            + "{\"word-constraint-query\":{\"constraint-name\":\"pojo-name-field\", \"text\":\"Acme\"}},"
            + "{\"word-constraint-query\":{\"constraint-name\":\"pojo-name-field\", \"text\":\"special\"}}]},"
            + "\"options\":{\"constraint\":{\"name\":\"pojo-name-field\", \"word\":{\"json-property\":\"name\"}}}"
            + "}}";

    PojoQueryDefinition qd =
        (PojoQueryDefinition)
            queryMgr.newRawCombinedQueryDefinition(
                new StringHandle(queryAsString).withFormat(Format.JSON));
    JacksonHandle results = new JacksonHandle();
    p = products.search(qd, 1, results);
    products.setPageLength(11);
    assertEquals("total no of pages", 1, p.getTotalPages());
    //		System.out.println(p.getTotalPages()+results.get().toString());
    long pageNo = 1, count = 0;
    do {
      count = 0;
      p = products.search(qd, pageNo, results);

      while (p.iterator().hasNext()) {
        Artifact a = p.iterator().next();
        validateArtifact(a);
        count++;
        assertTrue(
            "Manufacture name starts with acme", a.getManufacturer().getName().contains("Acme"));
        assertTrue("Artifact name contains", a.getName().contains("special"));
      }
      assertEquals("Page size", count, p.size());
      pageNo = pageNo + p.getPageSize();

      assertEquals(
          "Page start from search handls vs page methods",
          results.get().get("start").asLong(),
          p.getStart());
      assertEquals(
          "Format in the search handle",
          "json",
          results.get().withArray("results").get(1).path("format").asText());
      assertTrue(
          "Uri in search handle contains Artifact",
          results.get().withArray("results").get(1).path("uri").asText().contains("Artifact"));
      //			System.out.println(results.get().toString());
    } while (!p.isLastPage() && pageNo < p.getTotalSize());
    assertFalse("search handle has metrics", results.get().has("metrics"));
    assertEquals("Total from search handle", 11, results.get().get("total").asInt());
    assertEquals("page number after the loop", 1, p.getPageNumber());
    assertEquals("total no of pages", 1, p.getTotalPages());
  }
Пример #8
0
 public Downloader(Project p, Artifact artifact, File dest, Options options) {
   project = p;
   this.artifact = artifact;
   destination = dest;
   if (options.isSeparateClassifierTypes() && !artifact.getClassifier().isEmpty()) {
     destination = new File(destination, artifact.getClassifier());
     destination.mkdirs();
   }
   this.options = options;
 }
 private void endNotifyMonitor(
     CacheMonitorRouter monitor, boolean existed, Artifact artifact, File destination) {
   if (monitor != null) {
     if (existed) {
       monitor.updatedLocalCache(artifact.toURL(), destination);
     } else {
       monitor.addedToLocalCache(artifact.toURL(), destination);
     }
   }
 }
  public static String validateArtifact(Artifact artifact) {
    if (artifact == null
        || artifact.getArtifactCategory() == null
        || artifact.getArtifactIdentifier() == null
        || artifact.getArtifactName() == null) {
      return RepositoryServiceClientConstants.FAILURE;
    }

    return RepositoryServiceClientConstants.SUCCESS;
  }
Пример #11
0
 public Artifact getArtifact(String id) {
   Artifact foundArtifact = null;
   for (Artifact artifact : artifactList) {
     if (id.equals(artifact.getId())) {
       foundArtifact = artifact;
       break;
     }
   }
   return foundArtifact;
 }
Пример #12
0
 @Override
 public ArtifactManagerState getState() {
   final ArtifactManagerState state = new ArtifactManagerState();
   for (Artifact artifact : getAllArtifactsIncludingInvalid()) {
     final ArtifactState artifactState;
     if (artifact instanceof InvalidArtifact) {
       artifactState = ((InvalidArtifact) artifact).getState();
     } else {
       artifactState = new ArtifactState();
       artifactState.setBuildOnMake(artifact.isBuildOnMake());
       artifactState.setName(artifact.getName());
       artifactState.setOutputPath(artifact.getOutputPath());
       artifactState.setRootElement(serializePackagingElement(artifact.getRootElement()));
       artifactState.setArtifactType(artifact.getArtifactType().getId());
       for (ArtifactPropertiesProvider provider : artifact.getPropertiesProviders()) {
         final ArtifactPropertiesState propertiesState =
             serializeProperties(provider, artifact.getProperties(provider));
         if (propertiesState != null) {
           artifactState.getPropertiesList().add(propertiesState);
         }
       }
       Collections.sort(
           artifactState.getPropertiesList(),
           new Comparator<ArtifactPropertiesState>() {
             @Override
             public int compare(
                 @NotNull ArtifactPropertiesState o1, @NotNull ArtifactPropertiesState o2) {
               return o1.getId().compareTo(o2.getId());
             }
           });
     }
     state.getArtifacts().add(artifactState);
   }
   return state;
 }
 @NotNull
 @Override
 public List<DeploymentSource> createArtifactDeploymentSources(
     Project project, ArtifactType... artifactTypes) {
   if (project.isDefault()) return Collections.emptyList();
   Artifact[] artifacts = ArtifactManager.getInstance(project).getArtifacts();
   List<Artifact> supportedArtifacts = new ArrayList<>();
   Set<ArtifactType> typeSet = ContainerUtil.set(artifactTypes);
   for (Artifact artifact : artifacts) {
     if (typeSet.contains(artifact.getArtifactType())) {
       supportedArtifacts.add(artifact);
     }
   }
   return createArtifactDeploymentSources(project, supportedArtifacts);
 }
  @Override
  public void execute(Hero hero, String action) {
    if (action.equals(AC_READ)) {

      if (hero.buff(Blindness.class) != null)
        GLog.w("You cannot read from the book while blinded.");
      else if (!isEquipped(hero)) GLog.i("You need to equip your spellbook to do that.");
      else if (charge == 0) GLog.i("Your spellbook is out of energy for now.");
      else if (cursed) GLog.i("Your cannot read from a cursed spellbook.");
      else {
        charge--;

        Scroll scroll;
        do {
          scroll = (Scroll) Generator.random(Generator.Category.SCROLL);
        } while (scroll == null
            ||
            // gotta reduce the rate on these scrolls or that'll be all the item does.
            ((scroll instanceof ScrollOfIdentify
                    || scroll instanceof ScrollOfRemoveCurse
                    || scroll instanceof ScrollOfMagicMapping)
                && Random.Int(2) == 0));

        scroll.ownedByBook = true;
        scroll.execute(hero, AC_READ);
      }

    } else if (action.equals(AC_ADD)) {
      GameScene.selectItem(itemSelector, mode, inventoryTitle);
    } else super.execute(hero, action);
  }
Пример #15
0
 /**
  * Helper method to remove an Artifact. If the Artifact refers to a directory recursively removes
  * the contents of the directory.
  */
 protected void deleteOutput(Artifact output) throws IOException {
   Path path = output.getPath();
   try {
     // Optimize for the common case: output artifacts are files.
     path.delete();
   } catch (IOException e) {
     // Only try to recursively delete a directory if the output root is known. This is just a
     // sanity check so that we do not start deleting random files on disk.
     // TODO(bazel-team): Strengthen this test by making sure that the output is part of the
     // output tree.
     if (path.isDirectory(Symlinks.NOFOLLOW) && output.getRoot() != null) {
       FileSystemUtils.deleteTree(path);
     } else {
       throw e;
     }
   }
 }
 protected void addSpecificHeaders(Artifact artifact, BufferedReader bufferedreader, Writer writer)
     throws Exception {
   mMetricsHeaderProcessor.setProcessTag(artifact.getTag());
   mJavaHeaderProcessor.process("ContentType", "JavaCrash", writer);
   mDetUtil.processHeaders(bufferedreader, writer, mJavaHeaderProcessor);
   if (JAVA_STACK_TRACE_TAGS.contains(artifact.getTag())) {
     bufferedreader =
         extractJavaCrashInfoFromCrashBody(bufferedreader, writer, mJavaHeaderProcessor);
     if (bufferedreader != null) {
       Integer integer = mCrashDuplicateCount.getCount(bufferedreader);
       if (integer != null && integer.intValue() > 1) {
         mJavaHeaderProcessor.process("CrashDuplicateCount", integer.toString(), writer);
       }
     }
     artifact.setCrashDescriptor(bufferedreader);
   }
 }
Пример #17
0
 /**
  * If the action might read directories as inputs in a way that is unsound wrt dependency
  * checking, this method must be called.
  */
 protected void checkInputsForDirectories(
     EventHandler eventHandler, MetadataHandler metadataHandler) {
   // Report "directory dependency checking" warning only for non-generated directories (generated
   // ones will be reported earlier).
   for (Artifact input : getMandatoryInputs()) {
     // Assume that if the file did not exist, we would not have gotten here.
     if (input.isSourceArtifact() && !metadataHandler.isRegularFile(input)) {
       eventHandler.handle(
           Event.warn(
               getOwner().getLocation(),
               "input '"
                   + input.prettyPrint()
                   + "' to "
                   + getOwner().getLabel()
                   + " is a directory; dependency checking of directories is unsound"));
     }
   }
 }
Пример #18
0
 /** If the action might create directories as outputs this method must be called. */
 protected void checkOutputsForDirectories(EventHandler eventHandler) {
   for (Artifact output : getOutputs()) {
     Path path = output.getPath();
     String ownerString = Label.print(getOwner().getLabel());
     if (path.isDirectory()) {
       eventHandler.handle(
           new Event(
               EventKind.WARNING,
               getOwner().getLocation(),
               "output '"
                   + output.prettyPrint()
                   + "' of "
                   + ownerString
                   + " is a directory; dependency checking of directories is unsound",
               ownerString));
     }
   }
 }
Пример #19
0
 /** Hit up the server */
 public void refreshDiscussion() {
   assetService.loadDiscussionForAsset(
       artifact.getUuid(),
       new GenericCallback<List<DiscussionRecord>>() {
         public void onSuccess(List<DiscussionRecord> result) {
           updateCommentList(result);
         }
       });
 }
Пример #20
0
  public void setValues(Process otherElement) {
    super.setValues(otherElement);

    setName(otherElement.getName());
    setExecutable(otherElement.isExecutable());
    setDocumentation(otherElement.getDocumentation());
    if (otherElement.getIoSpecification() != null) {
      setIoSpecification(otherElement.getIoSpecification().clone());
    }

    executionListeners = new ArrayList<ActivitiListener>();
    if (otherElement.getExecutionListeners() != null
        && otherElement.getExecutionListeners().size() > 0) {
      for (ActivitiListener listener : otherElement.getExecutionListeners()) {
        executionListeners.add(listener.clone());
      }
    }

    candidateStarterUsers = new ArrayList<String>();
    if (otherElement.getCandidateStarterUsers() != null
        && otherElement.getCandidateStarterUsers().size() > 0) {
      candidateStarterUsers.addAll(otherElement.getCandidateStarterUsers());
    }

    candidateStarterGroups = new ArrayList<String>();
    if (otherElement.getCandidateStarterGroups() != null
        && otherElement.getCandidateStarterGroups().size() > 0) {
      candidateStarterGroups.addAll(otherElement.getCandidateStarterGroups());
    }

    flowElementList = new ArrayList<FlowElement>();
    if (otherElement.getFlowElements() != null && otherElement.getFlowElements().size() > 0) {
      for (FlowElement element : otherElement.getFlowElements()) {
        flowElementList.add(element.clone());
      }
    }

    artifactList = new ArrayList<Artifact>();
    if (otherElement.getArtifacts() != null && otherElement.getArtifacts().size() > 0) {
      for (Artifact artifact : otherElement.getArtifacts()) {
        artifactList.add(artifact.clone());
      }
    }
  }
  @Test
  public void testPOJOSearchWithSearchHandle() {
    PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class);
    PojoPage<Artifact> p;
    this.loadSimplePojos(products);
    QueryManager queryMgr = client.newQueryManager();
    StringQueryDefinition qd = queryMgr.newStringDefinition();
    qd.setCriteria("Acme");
    SearchHandle results = new SearchHandle();
    products.setPageLength(11);
    p = products.search(qd, 1, results);
    assertEquals("total no of pages", 5, p.getTotalPages());
    System.out.println(p.getTotalPages());
    long pageNo = 1, count = 0;
    do {
      count = 0;
      p = products.search(qd, pageNo, results);

      while (p.iterator().hasNext()) {
        Artifact a = p.iterator().next();
        validateArtifact(a);
        assertTrue("Artifact Id is even", a.getId() % 2 == 0);
        assertTrue("Company name contains Acme", a.getManufacturer().getName().contains("Acme"));
        count++;
        //				System.out.println(a.getId()+" "+a.getManufacturer().getName() +"  "+count);
      }
      assertEquals("Page size", count, p.size());
      pageNo = pageNo + p.getPageSize();
      MatchDocumentSummary[] mds = results.getMatchResults();
      assertEquals("Size of the results summary", 11, mds.length);
      for (MatchDocumentSummary md : mds) {
        assertTrue("every uri should contain the class name", md.getUri().contains("Artifact"));
      }
      String[] facetNames = results.getFacetNames();
      for (String fname : facetNames) {
        System.out.println(fname);
      }
      assertEquals("Total resulr from search handle ", 55, results.getTotalResults());
      //			assertTrue("Search Handle metric results ",results.getMetrics().getTotalTime()>0);
    } while (!p.isLastPage() && pageNo < p.getTotalSize());
    assertEquals("Page start check", 45, p.getStart());
    assertEquals("page number after the loop", 5, p.getPageNumber());
    assertEquals("total no of pages", 5, p.getTotalPages());
  }
Пример #22
0
  private void showNewCommentButton() {
    newCommentLayout.clear();

    HorizontalPanel hp = new HorizontalPanel();

    Button createNewComment = new Button(constants.AddADiscussionComment());
    createNewComment.setEnabled(!this.readOnly);
    hp.add(createNewComment);

    if (UserCapabilities.INSTANCE.hasCapability(Capability.SHOW_ADMIN)) {
      Button adminClearAll = new Button(constants.EraseAllComments());
      adminClearAll.setEnabled(!readOnly);
      hp.add(adminClearAll);
      adminClearAll.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent sender) {
              if (Window.confirm(constants.EraseAllCommentsWarning())) {
                assetService.clearAllDiscussionsForAsset(
                    artifact.getUuid(),
                    new GenericCallback<java.lang.Void>() {
                      public void onSuccess(Void v) {
                        updateCommentList(new ArrayList<DiscussionRecord>());
                      }
                    });
              }
            }
          });
    }

    final String feedURL =
        GWT.getModuleBaseURL()
            + "feed/discussion?package="
            + ((Asset) artifact).getMetaData().getModuleName()
            + "&assetName="
            + URL.encode(artifact.getName())
            + "&viewUrl="
            + Util.getSelfURL();
    Image image = new Image(images.feed());
    image.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent arg0) {
            Window.open(feedURL, "_blank", null);
          }
        });
    hp.add(image);

    newCommentLayout.add(hp);

    newCommentLayout.setCellHorizontalAlignment(hp, HasHorizontalAlignment.ALIGN_RIGHT);
    createNewComment.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent sender) {
            showAddNewComment();
          }
        });
  }
  @Test(expected = ClassCastException.class)
  public void testPOJOqbeSearchWithoutSearchHandle() {
    PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class);
    PojoPage<Artifact> p;
    this.loadSimplePojos(products);
    QueryManager queryMgr = client.newQueryManager();
    String queryAsString =
        "{\"$query\":{"
            + "\"$and\":[{\"name\":{\"$word\":\"cogs\",\"$exact\": false}}]"
            + ",\"$not\":[{\"name\":{\"$word\":\"special\",\"$exact\": false}}]"
            + "}}";

    PojoQueryDefinition qd =
        (PojoQueryDefinition)
            queryMgr.newRawQueryByExampleDefinition(
                new StringHandle(queryAsString).withFormat(Format.JSON));
    qd.setCollections("odd");
    products.setPageLength(11);
    p = products.search(qd, 1);
    assertEquals("total no of pages", 4, p.getTotalPages());
    //		System.out.println(p.getTotalPages());
    long pageNo = 1, count = 0;
    do {
      count = 0;

      p = products.search(qd, pageNo);

      while (p.iterator().hasNext()) {
        Artifact a = p.iterator().next();
        validateArtifact(a);
        assertFalse("Verifying document with special is not there", a.getId() % 5 == 0);
        assertTrue("Artifact Id is odd", a.getId() % 2 != 0);
        assertTrue(
            "Company name contains widgets", a.getManufacturer().getName().contains("Widgets"));
        count++;
        //				System.out.println(a.getId()+" "+a.getManufacturer().getName() +"  "+count);
      }
      assertEquals("Page size", count, p.size());
      pageNo = pageNo + p.getPageSize();
    } while (!p.isLastPage() && pageNo < p.getTotalSize());
    assertEquals("page number after the loop", 4, p.getPageNumber());
    assertEquals("total no of pages", 4, p.getTotalPages());
  }
Пример #24
0
  @Test
  public static void test() throws Exception {
    AutoTestCase.testName = "PlaceOrder";
    AutoTestCase.tester = "Subha Srinivasan";

    WebDriver driver = GeneralMethods.startDriver();

    BufferedWriter artifact =
        Artifact.OpenArtifact(GeneralMethods.getArtifactName(), testName + "  ", timeStamp);

    // Objects used
    OrderPage lp = new OrderPage(driver, "orderpage");
    AccountPage ap = new AccountPage(driver, "accountpage");

    Actions actions = new Actions(driver);
    System.out.println("* * * * * Start of " + testName + " test * * * * *");
    int localStressLoop = AutomationSettings.getLocalStressLoopIterations();

    // Test case infrastructure
    String currStepResult = null;
    String prevStepResult = null;
    String iterationStamp = "";
    String preReq = null;
    AutoTestCase.testData =
        "site=" + deployment + "  browser=" + AutomationSettings.getTestDataItem("ChromeVersion");
    lp.launchApplication();

    //  System.out.println("* * * * * *  Local stress loop iteration # " +iterationStamp);
    // Validate the purchase price

    currStepResult = lp.searchProduct("Apple iphone 4s") ? "Pass" : "Fail";
    Artifact.VerifyWriteToArtifactS(
        artifact, "Check the product link is displayed ", currStepResult);
    String totalpurchaseprice = lp.getPurchasePrice(lp.totalPrice);
    System.out.println(" the total purchase Price" + totalpurchaseprice);
    Assert.assertEquals("$282.00", totalpurchaseprice);
    Artifact.VerifyWriteToArtifactS(artifact, "Validate the purchase price ", currStepResult);

    driver.quit();
    driver = null;

    Artifact.CloseArtifact(artifact);
  }
  /**
   * Attempts to download and cache a remote artifact using a set of remote repositories. The
   * operation is not fail fast and so it keeps trying if the first repository does not have the
   * artifact in question.
   *
   * @param artifact the artifact to retrieve and cache
   * @return input stream containing the artifact content.
   * @exception IOException if an IO error occurs.
   * @exception TransitException if a transit system error occurs.
   * @exception NullArgumentException if the artifact argument is null.
   */
  public InputStream getResource(Artifact artifact)
      throws IOException, TransitException, NullArgumentException {
    File destination = getResourceFile(artifact);

    if (destination.exists()) {
      FileInputStream stream = new FileInputStream(destination);
      return new BufferedInputStream(stream);
    }

    String error = "Unresolvable artifact: [" + artifact + "]. (" + destination + ")";
    throw new ArtifactNotFoundException(error, artifact.toURI());
  }
Пример #26
0
  private void handleAuctionWon(ACLMessage msg) {
    try {
      if (msg.getContentObject() != null && msg.getContentObject() instanceof Auction) {
        final Artifact art = ((Auction) msg.getContentObject()).getArtifact();
        boughtArtifacts.add(art);

        for (Auction auction : participatingAuctions) {
          Auction match = getAuction(auction);
          if (match != null && match.getArtifact().getId() == art.getId()) {
            participatingAuctions.remove(match);
            knownAuctions.remove(match);
            break;
          }
        }
      } else {
        block();
      }
    } catch (UnreadableException ex) {
      block();
    }
  }
  /** Marshall the given parameter object, and output to a JSONWriter */
  public void marshall(Artifact artifact, JSONWriter jsonWriter) {
    if (artifact == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonWriter.object();

      if (artifact.getName() != null) {
        jsonWriter.key("name").value(artifact.getName());
      }

      if (artifact.getRevision() != null) {
        jsonWriter.key("revision").value(artifact.getRevision());
      }

      if (artifact.getLocation() != null) {
        jsonWriter.key("location");
        ArtifactLocationJsonMarshaller.getInstance().marshall(artifact.getLocation(), jsonWriter);
      }

      jsonWriter.endObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Пример #28
0
  @Test
  public void getDbModule() {
    final Module module = DataModelFactory.createModule("root", "1.0.0-SNAPSHOT");
    final Artifact artifact =
        DataModelFactory.createArtifact(
            "com.axway.root", "artifact1", "1.0.0-SNAPSHOT", "win", "component", "jar");
    module.addArtifact(artifact);

    final Artifact thirdparty =
        DataModelFactory.createArtifact("org.apache", "all", "6.8.0-5426", "", "", "jar");
    final Dependency dependency = DataModelFactory.createDependency(thirdparty, Scope.COMPILE);
    module.addDependency(dependency);

    final Module submodule = DataModelFactory.createModule("sub1", "1.0.0-SNAPSHOT");
    final Artifact artifact2 =
        DataModelFactory.createArtifact(
            "com.axway.root.sub1", "artifactSub1", "1.0.0-SNAPSHOT", "", "", "jar");
    submodule.addArtifact(artifact2);
    final Artifact thirdparty2 =
        DataModelFactory.createArtifact("org.lol", "all", "1.2.3-4", "", "", "jar");
    final Dependency dependency2 = DataModelFactory.createDependency(thirdparty2, Scope.PROVIDED);
    submodule.addDependency(dependency2);
    module.addSubmodule(submodule);

    final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class));
    final DbModule dbModule = modelMapper.getDbModule(module);
    assertEquals(module.getName(), dbModule.getName());
    assertEquals(module.getVersion(), dbModule.getVersion());
    assertEquals(1, dbModule.getArtifacts().size());
    assertEquals(artifact.getGavc(), dbModule.getArtifacts().get(0));
    assertEquals(1, dbModule.getDependencies().size());
    assertEquals(thirdparty.getGavc(), dbModule.getDependencies().get(0).getTarget());
    assertEquals(
        DbModule.generateID(module.getName(), module.getVersion()),
        dbModule.getDependencies().get(0).getSource());
    assertEquals(dependency.getScope(), dbModule.getDependencies().get(0).getScope());
    assertEquals(1, dbModule.getSubmodules().size());

    final DbModule dbSubmodule = dbModule.getSubmodules().get(0);
    assertEquals(submodule.getName(), dbSubmodule.getName());
    assertEquals(submodule.getVersion(), dbSubmodule.getVersion());
    assertEquals(1, dbSubmodule.getArtifacts().size());
    assertEquals(artifact2.getGavc(), dbSubmodule.getArtifacts().get(0));
    assertEquals(1, dbSubmodule.getDependencies().size());
    assertEquals(thirdparty2.getGavc(), dbSubmodule.getDependencies().get(0).getTarget());
    assertEquals(
        DbModule.generateID(submodule.getName(), submodule.getVersion()),
        dbSubmodule.getDependencies().get(0).getSource());
    assertEquals(dependency2.getScope(), dbSubmodule.getDependencies().get(0).getScope());
  }
  public void outputDependencies(Set<String> output) {
    for (String artifactKey : artifactKeys) {
      Artifact artifact = getArtifact(artifactKey);

      if (artifact != null) // todo fix null artifacts
      { // todo need a map of the dependsOn tasks, and the revision THIS object asked for

        boolean isSameRevision = artifact.getRequestedRevision().equals(artifact.getRevision());
        String color = isSameRevision ? "black" : "red";
        String edgeLabel =
            isSameRevision ? "" : (" label=\"" + artifact.getRequestedRevision() + "\" , ");
        String line =
            getNiceDotName()
                + " -> "
                + artifact.getNiceDotName()
                + "  ["
                + edgeLabel
                + "color=\""
                + color
                + "\"];";

        output.add(line);
        artifact.outputDependencies(
            output); // todo will this do duplicates?  Need to do a set to reduce dups?
      }
    }
  }
Пример #30
0
 private void sendNewComment(String text) {
   newCommentLayout.clear();
   newCommentLayout.add(new Image(images.spinner()));
   assetService.addToDiscussionForAsset(
       artifact.getUuid(),
       text,
       new GenericCallback<List<DiscussionRecord>>() {
         public void onSuccess(List<DiscussionRecord> result) {
           showNewCommentButton();
           updateCommentList(result);
         }
       });
 }