public boolean equals(Object object) {
    if (Util.THIS.isLoggable()) /* then */ Util.THIS.debug("-=#| TreeNodeFilter.equals");

    if ((object instanceof TreeNodeFilter) == false) {
      return false;
    }

    TreeNodeFilter peer = (TreeNodeFilter) object;

    Set thisSet = new HashSet(Arrays.asList(this.nodeTypes));
    Set peerSet = new HashSet(Arrays.asList(peer.nodeTypes));

    if (Util.THIS.isLoggable()) /* then */ Util.THIS.debug("-=#|    thisSet = " + thisSet);
    if (Util.THIS.isLoggable()) /* then */ Util.THIS.debug("-=#|    peerSet = " + peerSet);
    if (Util.THIS.isLoggable()) /* then */
      Util.THIS.debug("-=#|    acceptPolicy? " + (this.acceptPolicy == peer.acceptPolicy));
    if (Util.THIS.isLoggable()) /* then */
      Util.THIS.debug("-=#|    nodeTypes   ? " + (thisSet.equals(peerSet)));

    if (this.acceptPolicy != peer.acceptPolicy) {
      return false;
    }

    return thisSet.equals(peerSet);
  }
  @Override
  public void setUp() throws Exception {
    solo = new Solo(getInstrumentation(), getActivity());

    FlashcardActivityState state = FlashcardActivityState_.getInstance_(solo.getCurrentActivity());
    state.setBox(1);

    DatabaseOpenHelper openHelper = new DatabaseOpenHelper(solo.getCurrentActivity());
    cardDao = openHelper.getDao(Card.class);
    cardDao.queryForAll().size();
    List<List<String>> cards =
        Arrays.asList(
            Arrays.asList("111", "AAA", "1"),
            Arrays.asList("222", "BBB", "1"),
            Arrays.asList("333", "CCC", "1"),
            Arrays.asList("444", "DDD", "1"),
            Arrays.asList("555", "EEE", "1"),
            Arrays.asList("666", "FFF", "2"),
            Arrays.asList("777", "GGG", "2"),
            Arrays.asList("888", "HHH", "3"),
            Arrays.asList("999", "III", "3"));
    for (List<String> card : cards) {
      createCardForTest(card.get(0), card.get(1), Integer.valueOf(card.get(2)));
    }
  }
  private String[] expStringToArray(String exp) {

    String[] splitExp = new String[exp.length()];
    Arrays.fill(splitExp, "");

    int j = 0;
    for (int i = 0; i < exp.length(); ++i) {
      char ch = exp.charAt(i);

      if (ch == '+' || ch == '-') {
        splitExp[++j] += ch;
      } else if (ch == '*' || ch == '/') {
        splitExp[++j] += ch;
        ++j;
      } else {
        splitExp[j] += ch;
      }
    }

    ArrayList<String> utilityArray = new ArrayList<>(Arrays.asList(splitExp));
    Predicate<String> p = (s) -> s.equals("");

    utilityArray.removeIf(p);
    splitExp = new String[0];
    splitExp = utilityArray.toArray(splitExp);
    return splitExp;
  }
  private void mountFiles(String path, Class<?> clazz) {
    try {
      List<Resource> list = new ArrayList<>();
      String packagePath = clazz.getPackage().getName().replace('.', '/');

      PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
      Resource[] res = resolver.getResources("classpath:" + packagePath + "/*.png");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }
      res = resolver.getResources("classpath:" + packagePath + "/*.gif");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }

      for (Resource resource : list) {
        URI uri = resource.getURI();
        File file = new File(uri.toString());
        mountResource(
            path + "/" + file.getName(), new SharedResourceReference(clazz, file.getName()));
      }
    } catch (Exception ex) {
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't mount files", ex);
    }
  }
  public Chunk(World par1World, int par2, int par3) {
    this.storageArrays = new ExtendedBlockStorage[16];
    this.blockBiomeArray = new byte[256];
    this.precipitationHeightMap = new int[256];
    this.updateSkylightColumns = new boolean[256];
    this.isGapLightingUpdated = false;
    this.chunkTileEntityMap = new HashMap();
    this.isTerrainPopulated = false;
    this.isModified = false;
    this.hasEntities = false;
    this.lastSaveTime = 0L;
    this.sendUpdates = false;
    this.field_82912_p = 0;
    this.queuedLightChecks = 4096;
    this.field_76653_p = false;
    this.entityLists = new List[16];
    this.worldObj = par1World;
    this.xPosition = par2;
    this.zPosition = par3;
    this.heightMap = new int[256];

    for (int var4 = 0; var4 < this.entityLists.length; ++var4) {
      this.entityLists[var4] = new ArrayList();
    }

    Arrays.fill(this.precipitationHeightMap, -999);
    Arrays.fill(this.blockBiomeArray, (byte) -1);
  }
  /**
   * Loads the contents of the given locations into memory.
   *
   * @param locations locations to add (of type {@link java.io.File &lt;File&gt;}).
   * @throws IOException if an I/O error occurred.
   */
  public synchronized void loadAll(List locations) throws IOException {
    if (locations == null) {
      return;
    }

    Set data = new HashSet(1000);

    for (Iterator i = locations.iterator(); i.hasNext(); ) {
      File location = (File) i.next();
      ClassRepositoryEntry entry = loadEntry(location);

      if (entry != null) {
        data.addAll(entry.getData());

        if (Loggers.IO.isDebugEnabled()) {
          Loggers.IO.debug("ClassRepository: Loaded " + data.size() + " classes from " + location);
        }
      }
    }

    if (!data.isEmpty()) {
      data.addAll(Arrays.asList(_content));
      _content = (String[]) data.toArray(EMPTY_STRING_ARRAY);
      Arrays.sort(_content);
    }
  }
  Object invoke(String methodName, Object... parameters)
      throws IllegalAccessException, InvocationTargetException {
    String mid = methodId(methodName, parameters.length);
    List<Method> methods = methodCache.get(mid);
    Method method = null;

    if (methods == null) {
      throw new IllegalAccessException("No method " + mid); // NOI18N
    }
    if (methods.size() == 1) {
      method = methods.get(0);
    } else {
      Class[] parClasses = new Class[parameters.length];

      for (int i = 0; i < parameters.length; i++) {
        Class cl = parameters[i].getClass();
        if (primitiveTypes.containsKey(cl)) {
          cl = primitiveTypes.get(cl);
        }
        parClasses[i] = cl;
      }
      for (Method m : methods) {
        if (Arrays.deepEquals(m.getParameterTypes(), parClasses)) {
          method = m;
          break;
        }
      }
    }
    if (method == null) {
      throw new IllegalArgumentException(
          instance + " " + methodName + " " + Arrays.toString(parameters));
    }
    return method.invoke(instance, parameters);
  }
Beispiel #8
1
  public SelectMany05Bean() {

    HobbitBean[] hobbits = {
      new HobbitBean("Bilbo", "Ring Finder"),
      new HobbitBean("Frodo", "Ring Bearer"),
      new HobbitBean("Merry", "Trouble Maker"),
      new HobbitBean("Pippin", "Trouble Maker")
    };

    Set<SelectItem> items = new LinkedHashSet<SelectItem>();
    for (HobbitBean hobbit : hobbits) {
      items.add(new SelectItem(hobbit.getName()));
    }
    hobbitCollection = new TreeSet<HobbitBean>();
    hobbitCollection.addAll(Arrays.asList(hobbits));
    possibleValues = Collections.unmodifiableSet(items);
    initialSortedSetValues = new TreeSet<String>(Collections.reverseOrder());
    initialSortedSetValues.add("Pippin");
    initialSortedSetValues.add("Frodo");
    initialCollectionValues = new LinkedHashSet<String>(2);
    initialCollectionValues.add("Bilbo");
    initialCollectionValues.add("Merry");
    initialSetValues = new CopyOnWriteArraySet<String>(); // not Cloneable
    initialSetValues.add("Frodo");
    initialListValues = new Vector<String>();
    initialListValues.add("Bilbo");
    initialListValues.add("Pippin");
    initialListValues.add("Merry");
    hobbitDataModel =
        new ListDataModel<HobbitBean>(new ArrayList<HobbitBean>(Arrays.asList(hobbits)));
  }
 public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
   List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
   Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
   if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
     int[] suitableFPSRange = null;
     for (int[] fpsRange : supportedPreviewFpsRanges) {
       int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
       int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
       if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) {
         suitableFPSRange = fpsRange;
         break;
       }
     }
     if (suitableFPSRange == null) {
       Log.i(TAG, "No suitable FPS range?");
     } else {
       int[] currentFpsRange = new int[2];
       parameters.getPreviewFpsRange(currentFpsRange);
       if (Arrays.equals(currentFpsRange, suitableFPSRange)) {
         Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange));
       } else {
         Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange));
         parameters.setPreviewFpsRange(
             suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
             suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
       }
     }
   }
 }
 static void validateColumnPath(String tablename, ColumnPath column_path)
     throws InvalidRequestException {
   validateTable(tablename);
   ColumnFamilyType cfType = validateColumnFamily(tablename, column_path.column_family);
   if (cfType == ColumnFamilyType.Standard) {
     if (column_path.super_column != null) {
       throw new InvalidRequestException(
           "supercolumn parameter is invalid for standard CF " + column_path.column_family);
     }
     if (column_path.column == null) {
       throw new InvalidRequestException(
           "column parameter is not optional for standard CF " + column_path.column_family);
     }
   } else {
     if (column_path.super_column == null)
       throw new InvalidRequestException(
           "supercolumn parameter is not optional for super CF " + column_path.column_family);
   }
   if (column_path.column != null) {
     validateColumns(
         tablename,
         column_path.column_family,
         column_path.super_column,
         Arrays.asList(column_path.column));
   }
   if (column_path.super_column != null) {
     validateColumns(
         tablename, column_path.column_family, null, Arrays.asList(column_path.super_column));
   }
 }
 // column_path_or_parent is a ColumnPath for remove, where the "column" is optional even for a
 // standard CF
 static void validateColumnPathOrParent(String tablename, ColumnPath column_path_or_parent)
     throws InvalidRequestException {
   validateTable(tablename);
   ColumnFamilyType cfType = validateColumnFamily(tablename, column_path_or_parent.column_family);
   if (cfType == ColumnFamilyType.Standard) {
     if (column_path_or_parent.super_column != null) {
       throw new InvalidRequestException(
           "supercolumn may not be specified for standard CF "
               + column_path_or_parent.column_family);
     }
   }
   if (column_path_or_parent.column != null) {
     validateColumns(
         tablename,
         column_path_or_parent.column_family,
         column_path_or_parent.super_column,
         Arrays.asList(column_path_or_parent.column));
   }
   if (column_path_or_parent.super_column != null) {
     validateColumns(
         tablename,
         column_path_or_parent.column_family,
         null,
         Arrays.asList(column_path_or_parent.super_column));
   }
 }
Beispiel #12
0
 /**
  * Adds a record to the table and the ID index.
  *
  * @param i index in the table where the record should be inserted
  * @param pre pre value
  * @param fid first ID value
  * @param nid last ID value
  * @param inc increment value
  * @param oid original ID value
  */
 private void add(
     final int i, final int pre, final int fid, final int nid, final int inc, final int oid) {
   if (rows == pres.length) {
     final int s = Array.newSize(rows);
     pres = Arrays.copyOf(pres, s);
     fids = Arrays.copyOf(fids, s);
     nids = Arrays.copyOf(nids, s);
     incs = Arrays.copyOf(incs, s);
     oids = Arrays.copyOf(oids, s);
   }
   if (i < rows) {
     final int destPos = i + 1;
     final int length = rows - i;
     System.arraycopy(pres, i, pres, destPos, length);
     System.arraycopy(fids, i, fids, destPos, length);
     System.arraycopy(nids, i, nids, destPos, length);
     System.arraycopy(incs, i, incs, destPos, length);
     System.arraycopy(oids, i, oids, destPos, length);
   }
   pres[i] = pre;
   fids[i] = fid;
   nids[i] = nid;
   incs[i] = inc;
   oids[i] = oid;
   ++rows;
 }
  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    CustomConversions conversions =
        new CustomConversions(
            Arrays.asList(DateToDateTimeConverter.INSTANCE, DateTimeToDateConverter.INSTANCE));

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(
        new HashSet<Class<?>>(
            Arrays.asList(
                PersonWith_idPropertyOfTypeObjectId.class,
                PersonWith_idPropertyOfTypeString.class,
                PersonWithIdPropertyOfTypeObjectId.class,
                PersonWithIdPropertyOfTypeString.class,
                PersonWithIdPropertyOfTypeInteger.class,
                PersonWithIdPropertyOfPrimitiveInt.class,
                PersonWithIdPropertyOfTypeLong.class,
                PersonWithIdPropertyOfPrimitiveLong.class)));
    mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    mappingContext.afterPropertiesSet();

    MappingMongoConverter mappingConverter = new MappingMongoConverter(factory, mappingContext);
    mappingConverter.setCustomConversions(conversions);
    mappingConverter.afterPropertiesSet();

    this.mappingTemplate = new MongoTemplate(factory, mappingConverter);
  }
  @Test
  public void testClientWildcard() throws Exception {
    BaseClientDetails theclient =
        new BaseClientDetails(
            "client",
            "zones",
            "zones.*.admin",
            "authorization_code, password",
            "scim.read, scim.write",
            "http://localhost:8080/uaa");
    theclient.setAutoApproveScopes(Arrays.asList("zones.*.admin"));
    Map<String, ? extends ClientDetails> clientDetailsStore =
        Collections.singletonMap("client", theclient);

    clientDetailsService.setClientDetailsStore(clientDetailsStore);
    tokenServices.setClientDetailsService(clientDetailsService);

    authorizationRequest =
        new AuthorizationRequest("client", Collections.singleton("zones.myzone.admin"));
    authorizationRequest.setResourceIds(new HashSet<>(Arrays.asList("client", "zones")));
    authentication =
        new OAuth2Authentication(
            authorizationRequest.createOAuth2Request(),
            UaaAuthenticationTestFactory.getAuthentication(userId, userName, "olds@vmware.com"));

    accessToken = tokenServices.createAccessToken(authentication);

    endpoint.checkToken(accessToken.getValue());
  }
  /** End-to-end installation test. */
  private void doTestAutoInstallation(String id, String fullversion) throws Exception {
    Assume.assumeTrue(
        "this is a really time consuming test, so only run it when we really want",
        Boolean.getBoolean("jenkins.testJDKInstaller"));

    retrieveUpdateCenterData();

    JDKInstaller installer = new JDKInstaller(id, true);

    JDK jdk =
        new JDK(
            "test",
            tmp.getRoot().getAbsolutePath(),
            Arrays.asList(new InstallSourceProperty(Arrays.<ToolInstaller>asList(installer))));

    j.jenkins.getJDKs().add(jdk);

    FreeStyleProject p = j.createFreeStyleProject();
    p.setJDK(jdk);
    p.getBuildersList().add(new Shell("java -fullversion\necho $JAVA_HOME"));
    FreeStyleBuild b = j.buildAndAssertSuccess(p);
    @SuppressWarnings("deprecation")
    String log = b.getLog();
    System.out.println(log);
    // make sure it runs with the JDK that just got installed
    assertTrue(log.contains(fullversion));
    assertTrue(log.contains(tmp.getRoot().getAbsolutePath()));
  }
  private void drawCurve(List<Integer> numbers, boolean horizontal) {
    while (numbers.size() > 0) {
      boolean first = numbers.size() % 4 == 1;

      if (horizontal) {
        addCommand(
            Arrays.asList(
                numbers.get(first ? 1 : 0),
                first ? numbers.get(0) : Integer.valueOf(0),
                numbers.get(first ? 2 : 1),
                numbers.get(first ? 3 : 2),
                numbers.get(first ? 4 : 3),
                Integer.valueOf(0)),
            new CharStringCommand(8));
      } else {
        addCommand(
            Arrays.asList(
                first ? numbers.get(0) : Integer.valueOf(0),
                numbers.get(first ? 1 : 0),
                numbers.get(first ? 2 : 1),
                numbers.get(first ? 3 : 2),
                Integer.valueOf(0),
                numbers.get(first ? 4 : 3)),
            new CharStringCommand(8));
      }
      numbers = numbers.subList(first ? 5 : 4, numbers.size());
    }
  }
 private void drawAlternatingCurve(List<Integer> numbers, boolean horizontal) {
   while (numbers.size() > 0) {
     boolean last = numbers.size() == 5;
     if (horizontal) {
       addCommand(
           Arrays.asList(
               numbers.get(0),
               Integer.valueOf(0),
               numbers.get(1),
               numbers.get(2),
               last ? numbers.get(4) : Integer.valueOf(0),
               numbers.get(3)),
           new CharStringCommand(8));
     } else {
       addCommand(
           Arrays.asList(
               Integer.valueOf(0),
               numbers.get(0),
               numbers.get(1),
               numbers.get(2),
               numbers.get(3),
               last ? numbers.get(4) : Integer.valueOf(0)),
           new CharStringCommand(8));
     }
     numbers = numbers.subList(last ? 5 : 4, numbers.size());
     horizontal = !horizontal;
   }
 }
  public void testGlobalGrantAuthorizationCheck() {
    TestResource resource1 = new TestResource("resource1", 100);

    // create global authorization which grants all permissions to all users (on resource1):
    Authorization globalAuth = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
    globalAuth.setResource(resource1);
    globalAuth.setResourceId(ANY);
    globalAuth.addPermission(ALL);
    authorizationService.saveAuthorization(globalAuth);

    List<String> jonnysGroups = Arrays.asList(new String[] {"sales", "marketing"});
    List<String> someOneElsesGroups = Arrays.asList(new String[] {"marketing"});

    // this authorizes any user to do anything in this resource:
    assertTrue(authorizationService.isUserAuthorized("jonny", null, ALL, resource1));
    assertTrue(authorizationService.isUserAuthorized("jonny", jonnysGroups, ALL, resource1));
    assertTrue(authorizationService.isUserAuthorized("someone", null, CREATE, resource1));
    assertTrue(
        authorizationService.isUserAuthorized("someone", someOneElsesGroups, CREATE, resource1));
    assertTrue(authorizationService.isUserAuthorized("someone else", null, DELETE, resource1));
    assertTrue(authorizationService.isUserAuthorized("jonny", null, ALL, resource1, "someId"));
    assertTrue(
        authorizationService.isUserAuthorized("jonny", jonnysGroups, ALL, resource1, "someId"));
    assertTrue(authorizationService.isUserAuthorized("someone", null, CREATE, resource1, "someId"));
    assertTrue(
        authorizationService.isUserAuthorized(
            "someone else", null, DELETE, resource1, "someOtherId"));
  }
  @Test
  public void getAllCustomerCars() {
    assertFalse(customer1.getActive());
    assertFalse(customer2.getActive());
    assertFalse(customer3.getActive());

    manager.rentCarToCustomer(
        car2, customer1, Date.valueOf("2012-03-21"), Date.valueOf("2012-03-31"));
    manager.rentCarToCustomer(
        car3, customer1, Date.valueOf("2012-03-25"), Date.valueOf("2012-04-02"));
    manager.rentCarToCustomer(
        car1, customer2, Date.valueOf("2012-03-15"), Date.valueOf("2012-03-27"));

    List<Car> carsRetnedtoCustomer1 = Arrays.asList(car2, car3);
    List<Car> carsRetnedtoCustomer2 = Arrays.asList(car1);

    assertCarDeepEquals(carsRetnedtoCustomer1, manager.getAllCustomerCars(customer1));
    assertCarDeepEquals(carsRetnedtoCustomer2, manager.getAllCustomerCars(customer2));
    assertFalse(customer3.getActive());

    try {
      manager.getAllCustomerCars(null);
      fail();
    } catch (IllegalArgumentException e) {
    }

    try {
      manager.getAllCustomerCars(customerWithoutID);
      fail();
    } catch (IllegalArgumentException e) {
    }
  }
  @Override
  public ResourceSchema getSchema(String location, Job job) throws IOException {

    if (!partitionKeysSet) {
      Set<String> keys = getPartitionColumns(location, job);

      if (!(keys == null || keys.size() == 0)) {

        // re-edit the pigSchema to contain the new partition keys.
        ResourceFieldSchema[] fields = pigSchema.getFields();

        LOG.debug("Schema: " + Arrays.toString(fields));

        ResourceFieldSchema[] newFields = Arrays.copyOf(fields, fields.length + keys.size());

        int index = fields.length;

        for (String key : keys) {
          newFields[index++] = new ResourceFieldSchema(new FieldSchema(key, DataType.CHARARRAY));
        }

        pigSchema.setFields(newFields);

        LOG.debug("Added partition fields: " + keys + " to loader schema");
        LOG.debug("Schema is: " + Arrays.toString(newFields));
      }

      partitionKeysSet = true;
    }

    return pigSchema;
  }
  /**
   * Test method for {@link SubtitleProvider#loadSubtitles(Path)}. Check that multiple subtitles are
   * loaded.
   *
   * @throws IOException if there was an I/O error.
   */
  @Test
  public void testLoadSubtitles() throws IOException {
    final SubtitleFormat subtitleFormat = mock(SubtitleFormat.class);
    final SubtitleReader subtitleReader = mock(SubtitleReader.class);
    final SubtitleFile subtitleFile = mock(SubtitleFile.class);
    final SubtitleFile secondSubtitle = mock(SubtitleFile.class);
    final Path folder = subtitleFolder.newFolder().toPath();
    final Path file = folder.resolve("single.srt");
    final Path second = folder.resolve("other.srt");
    Files.createFile(file);
    Files.createFile(second);
    Files.createFile(folder.resolve("test.sub"));

    when(subtitleFormatManager.getFormatByPath(file))
        .thenReturn(new HashSet<>(Arrays.asList(subtitleFormat)));
    when(subtitleFormatManager.getFormatByPath(second))
        .thenReturn(new HashSet<>(Arrays.asList(subtitleFormat)));
    when(subtitleFormat.getReader()).thenReturn(subtitleReader);
    when(subtitleReader.readFile(file)).thenReturn(subtitleFile);
    when(subtitleReader.readFile(second)).thenReturn(secondSubtitle);
    final Map<SubtitleFile, SubtitleFormat> subtitles = subtitleProvider.loadSubtitles(folder);
    assertEquals(2, subtitles.size());
    //		final Entry<SubtitleFile, SubtitleFormat> loaded = subtitles.entrySet().iterator().next();
    //		assertEquals(subtitleFile, loaded.getKey());
    //		assertEquals(subtitleFormat, loaded.getValue());
  }
  @Test
  public void cardinality() throws IOException {
    GameMap summonersRiftFromRiot = mapsResponse.getMaps().get(SUMMONERS_RIFT);
    GameMap summonersRiftNewFromDb = mapsRepository.save(summonersRiftFromRiot);
    summonersRiftFromRiot.setMapName("NEW_MAP_NAME");

    GameMap provingGroundsFromRiot = mapsResponse.getMaps().get(HOWLING_ABYSS);
    GameMap provingGroundsFromDb = mapsRepository.save(provingGroundsFromRiot);

    GameMap twistedTreeline = mapsResponse.getMaps().get(TWISTED_TREELINE);
    GameMap summonersRiftOldFromDb = mapsRepository.save(twistedTreeline);

    // Summoner's Rift, Proving Grounds, and Twisted Treeline
    List<GameMap> mapsFromDb =
        Arrays.asList(summonersRiftNewFromDb, provingGroundsFromDb, summonersRiftOldFromDb);

    GameMap crystalScar = mapsResponse.getMaps().get(CRYSTAL_SCAR);

    // Updated Summoner's Rift, same Proving Grounds, "new" Crystal Scar, and no Twisted Treeline
    List<GameMap> mapsFromRiot =
        Arrays.asList(summonersRiftFromRiot, provingGroundsFromDb, crystalScar);

    List<GameMap> deletedMaps = ListUtils.subtract(mapsFromDb, mapsFromRiot);
    assertThat(deletedMaps).hasSize(2);
    assertThat(deletedMaps).containsOnly(summonersRiftNewFromDb, summonersRiftOldFromDb);

    List<GameMap> unmodifiedMaps = ListUtils.intersection(mapsFromDb, mapsFromRiot);
    assertThat(unmodifiedMaps).hasSize(1);
    assertThat(unmodifiedMaps).containsOnly(provingGroundsFromDb);

    List<GameMap> mapsToUpdate = ListUtils.subtract(mapsFromRiot, mapsFromDb);
    assertThat(mapsToUpdate).hasSize(2);
    assertThat(mapsToUpdate).containsOnly(summonersRiftFromRiot, crystalScar);
  }
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof RunTestsResult)) return false;
   RunTestsResult other = (RunTestsResult) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && ((this.codeCoverage == null && other.getCodeCoverage() == null)
               || (this.codeCoverage != null
                   && java.util.Arrays.equals(this.codeCoverage, other.getCodeCoverage())))
           && ((this.codeCoverageWarnings == null && other.getCodeCoverageWarnings() == null)
               || (this.codeCoverageWarnings != null
                   && java.util.Arrays.equals(
                       this.codeCoverageWarnings, other.getCodeCoverageWarnings())))
           && ((this.failures == null && other.getFailures() == null)
               || (this.failures != null
                   && java.util.Arrays.equals(this.failures, other.getFailures())))
           && this.numFailures == other.getNumFailures()
           && this.numTestsRun == other.getNumTestsRun()
           && ((this.successes == null && other.getSuccesses() == null)
               || (this.successes != null
                   && java.util.Arrays.equals(this.successes, other.getSuccesses())))
           && this.totalTime == other.getTotalTime();
   __equalsCalc = null;
   return _equals;
 }
  @Override
  public List<QValue> qValues(State s) {

    if (this.domain != null) {
      List<Action> actions =
          ActionUtils.allApplicableActionsForTypes(this.domain.getActionTypes(), s);
      List<QValue> qs = new ArrayList<QValue>(actions.size());
      for (Action ga : actions) {
        qs.add(new QValue(s, ga, this.qValue(s, ga)));
      }
      return qs;
    }

    if (this.projectionType == RewardProjectionType.DESTINATIONSTATE) {
      return Arrays.asList(new QValue(s, null, this.rf.reward(null, null, s)));
    } else if (this.projectionType == RewardProjectionType.SOURCESTATE) {
      return Arrays.asList(new QValue(s, null, this.rf.reward(null, null, s)));
    } else if (this.projectionType == RewardProjectionType.STATEACTION) {
      throw new RuntimeException(
          "RewardValueProjection cannot generate all state-action Q-values because it was not"
              + "provided the Domain to enumerate the actions. Use the RewardValueProjection(RewardFunction, RewardProjectionType, Domain) "
              + "constructor to specify it.");
    }

    throw new RuntimeException("Unknown RewardProjectionType... this shouldn't happen.");
  }
 private void performImport() {
   FileDialog dialog = new FileDialog(this.fDialog.getShell(), SWT.OPEN);
   dialog.setText("Export environment variables to file");
   String file = dialog.open();
   if (file != null) {
     File handle = new File(file);
     if (!handle.exists()) {
       String text = "Selected file not exists.";
       showErrorMessage("Environment import", text);
       return;
     }
     EnvironmentVariable[] vars = null;
     try {
       vars = EnvironmentVariablesFileUtils.load(file);
     } catch (Exception e) {
       showErrorMessage("Environment import", e.getMessage());
     }
     if (vars != null) {
       EnvironmentVariable[] variables = this.fEnvironmentVariablesContentProvider.getVariables();
       Set nvars = new HashSet();
       nvars.addAll(Arrays.asList(vars));
       nvars.addAll(Arrays.asList(variables));
       this.fEnvironmentVariablesContentProvider.setVariables(
           (EnvironmentVariable[]) nvars.toArray(new EnvironmentVariable[nvars.size()]));
     }
   }
 }
  /** @param args */
  public static void main(String[] args) {
    // no non-initialized components
    List<Class<?>> components = Arrays.asList(new Class<?>[] {});
    List<Class<?>> ensembles = Arrays.asList(new Class<?>[] {BalanceHSEnsemble.class});
    KnowledgeManager km = new RepositoryKnowledgeManager(new LocalKnowledgeRepository());
    Scheduler scheduler = new MultithreadedScheduler();
    AbstractDEECoObjectProvider dop = new ClassDEECoObjectProvider(components, ensembles);
    // the dynamic runtime enables the developper to register/unregister components at runtime
    DynamicRuntime drt = new DynamicRuntime(km, scheduler);
    drt.registerComponentsAndEnsembles(dop);

    scpComponents =
        new ArrayList<ScpHSComponent>(
            Arrays.asList(
                // 3 SCPis at the LMU Munich
                new ScpHSComponent("LMU1", ENetworkId.LMU_MUNICH),
                new ScpHSComponent("LMU2", ENetworkId.LMU_MUNICH),
                new ScpHSComponent("LMU3", ENetworkId.LMU_MUNICH),
                // 3 SCPis at the IMT Lucca
                new ScpHSComponent("IMT1", ENetworkId.IMT_LUCCA),
                new ScpHSComponent("IMT2", ENetworkId.IMT_LUCCA),
                new ScpHSComponent("IMT3", ENetworkId.IMT_LUCCA),
                new ScpHSComponent("EGM1", ENetworkId.EN_GARDEN)));
    // list of all components which are part of the system
    List<Component> cloudComponents = new ArrayList<Component>(scpComponents);
    // Singleton Instance experiencing high load with a machine running on IMT Lucca
    cloudComponents.add(new AppHSComponent("APP", "machine", "IMT1", true));

    // initialize the DEECo with input initialized components
    dop = new InitializedDEECoObjectProvider(cloudComponents, null);
    drt.registerComponentsAndEnsembles(dop);

    drt.startRuntime();
  }
Beispiel #27
0
 @Test
 public void encode_scm_accounts() {
   assertThat(UserDto.encodeScmAccounts(null)).isNull();
   assertThat(UserDto.encodeScmAccounts(Collections.<String>emptyList())).isNull();
   assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo"))).isEqualTo("\nfoo\n");
   assertThat(UserDto.encodeScmAccounts(Arrays.asList("foo", "bar"))).isEqualTo("\nfoo\nbar\n");
 }
  @Test
  public void testSimpleFilter() throws Exception {
    final InetAddress oneNinetyTwo = addr("192.168.0.1");

    final List<InetAddress> addresses = Arrays.asList(oneNinetyTwo);
    m_filterDao.setActiveIPAddressList(addresses);

    final OnmsNode node = new OnmsNode(null, "foo");
    node.setId(1);
    node.setForeignSource("foo");
    node.setForeignId("bar");
    node.setSysObjectId(".1.2.3.4.5");
    final OnmsIpInterface iface = new OnmsIpInterface(oneNinetyTwo, node);
    final OnmsServiceType serviceType = new OnmsServiceType("SNMP");
    final OnmsMonitoredService service = new OnmsMonitoredService(iface, serviceType);
    m_monitoredServiceDao.setMatching(Arrays.asList(service));

    final Response response = m_configResource.getAgentsJson("example1", "SNMP");
    assertEquals(200, response.getStatus());
    final Object entity = response.getEntity();
    assertNotNull(entity);
    assertTrue(entity instanceof GenericEntity<?>);
    @SuppressWarnings("unchecked")
    final List<AgentResponse> agentResponses =
        (List<AgentResponse>) ((GenericEntity<?>) entity).getEntity();
    System.err.println(agentResponses);
    assertEquals(1, agentResponses.size());
    assertEquals(oneNinetyTwo, agentResponses.get(0).getAddress());
    assertEquals(1161, agentResponses.get(0).getPort().intValue());
    assertEquals(".1.2.3.4.5", agentResponses.get(0).getParameters().get("sysObjectId"));
    assertEquals("1", agentResponses.get(0).getParameters().get("nodeId"));
    assertEquals("foo", agentResponses.get(0).getParameters().get("foreignSource"));
    assertEquals("bar", agentResponses.get(0).getParameters().get("foreignId"));
  }
  /*
   * encrypt magic String 64 times in ECB
   */
  private byte[] encryptMagicString() {
    int[] text = {
      MAGIC_STRING[0],
      MAGIC_STRING[1],
      MAGIC_STRING[2],
      MAGIC_STRING[3],
      MAGIC_STRING[4],
      MAGIC_STRING[5]
    };
    for (int i = 0; i < 64; i++) {
      for (int j = 0; j < MAGIC_STRING_LENGTH; j += 2) {
        int left = text[j];
        int right = text[j + 1];

        left ^= P[0];
        for (int k = 1; k < ROUNDS; k += 2) {
          right ^= F(left) ^ P[k];
          left ^= F(right) ^ P[k + 1];
        }
        right ^= P[ROUNDS + 1];
        // swap values:
        text[j] = right;
        text[j + 1] = left;
      }
    }
    byte[] result = new byte[24]; // holds 192 bit key
    intToBigEndian(text, result, 0);
    Arrays.fill(text, 0);
    Arrays.fill(P, 0);
    Arrays.fill(S, 0);

    return result;
  }
 public static String[] getSupportedCodecs() {
   List<String> codecs = new ArrayList<>();
   codecs.addAll(Arrays.asList(SUPPORTED_VIDEO_CODECS));
   codecs.addAll(Arrays.asList(SUPPORTED_AUDIO_CODECS));
   codecs.addAll(Arrays.asList(SUPPORTED_SUBTITLE_CODECS));
   return codecs.toArray(new String[codecs.size()]);
 }