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);
  }
  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);
    }
  }
  @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)));
    }
  }
Example #4
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)));
  }
Example #5
0
  /** 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());
    }
  }
 /** Checks that the authorization headers are equal, modulo ordering of the parameters */
 private void assertEqualAuthorizationHeaders(String h1, String h2) {
   String[] a1 = h1.split(",?\\s*");
   Arrays.sort(a1);
   String[] a2 = h2.split(",?\\s*");
   Arrays.sort(a2);
   assertEquals(Arrays.asList(a1), Arrays.asList(a2));
 }
Example #8
0
 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));
   }
 }
  @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"));
  }
 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();
  }
 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()]);
 }
  @Test
  public void testEntityOnlyContainsProjectedProperties() throws Exception {
    Entity a =
        createEntity("Product", 1).withProperty("name", "b").withProperty("price", 1L).store();

    Entity b =
        createEntity("Product", 2).withProperty("name", "a").withProperty("price", 2L).store();

    Query query =
        new Query("Product")
            .addProjection(new PropertyProjection("price", Long.class))
            .setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("a", "b")));
    Entity firstResult = service.prepare(query).asList(FetchOptions.Builder.withDefaults()).get(0);

    assertEquals(1, firstResult.getProperties().size());
    assertEquals("price", firstResult.getProperties().keySet().iterator().next());

    query =
        new Query("Product")
            .setKeysOnly()
            .setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("a", "b")));
    firstResult = service.prepare(query).asList(FetchOptions.Builder.withDefaults()).get(0);

    assertEquals(0, firstResult.getProperties().size());
  }
  @Test
  public void testProjectionOfCollectionPropertyWithFilterOnCollectionProperty() throws Exception {
    Entity e =
        createEntity("Product", 1)
            .withProperty("name", Arrays.asList("aaa", "bbb"))
            .withProperty("price", Arrays.asList(10L, 20L))
            .store();

    Query query =
        new Query("Product")
            .addProjection(new PropertyProjection("name", String.class))
            .setFilter(new Query.FilterPredicate("price", GREATER_THAN, 0L))
            .addSort("price")
            .addSort("name");

    PreparedQuery preparedQuery = service.prepare(query);
    List<Entity> results = preparedQuery.asList(withDefaults());
    assertEquals(4, results.size());

    assertEquals(e.getKey(), results.get(0).getKey());
    assertEquals(e.getKey(), results.get(1).getKey());
    assertEquals(e.getKey(), results.get(2).getKey());
    assertEquals(e.getKey(), results.get(3).getKey());

    assertEquals("aaa", results.get(0).getProperty("name"));
    assertEquals("bbb", results.get(1).getProperty("name"));
    assertEquals("aaa", results.get(2).getProperty("name"));
    assertEquals("bbb", results.get(3).getProperty("name"));
  }
  @Test
  public void testProjectionOfCollectionProperties() throws Exception {
    Entity e =
        createEntity("test", 1)
            .withProperty("prop", Arrays.asList("bbb", "ccc", "aaa"))
            .withProperty("prop2", Arrays.asList("xxx", "yyy"))
            .store();

    Query query =
        new Query("test")
            .addProjection(new PropertyProjection("prop", String.class))
            .addSort("prop");

    PreparedQuery preparedQuery = service.prepare(query);
    List<Entity> results = preparedQuery.asList(withDefaults());
    assertEquals(3, results.size());

    Entity firstResult = results.get(0);
    Entity secondResult = results.get(1);
    Entity thirdResult = results.get(2);

    assertEquals(e.getKey(), firstResult.getKey());
    assertEquals(e.getKey(), secondResult.getKey());
    assertEquals(e.getKey(), thirdResult.getKey());
    assertEquals("aaa", firstResult.getProperty("prop"));
    assertEquals("bbb", secondResult.getProperty("prop"));
    assertEquals("ccc", thirdResult.getProperty("prop"));
  }
  private void assertIAEThrownByBothAsTypeMethodsForAllTypesExceptFor(
      RawValue raw, Class<?>... types) {
    HashSet<Class<?>> allTypes =
        new HashSet<Class<?>>(
            Arrays.asList(
                (Class<?>) Byte.class,
                Short.class,
                Integer.class,
                Long.class,
                Float.class,
                Double.class,
                Boolean.class,
                Date.class,
                String.class,
                Text.class,
                ShortBlob.class,
                Blob.class,
                GeoPt.class,
                PostalAddress.class,
                PhoneNumber.class,
                Email.class,
                User.class,
                IMHandle.class,
                Link.class,
                Category.class,
                Rating.class,
                Key.class,
                BlobKey.class));

    allTypes.removeAll(Arrays.asList(types));

    assertIAEThrownByBothAsTypeMethods(raw, allTypes.toArray(new Class[allTypes.size()]));
  }
  private String getInfo() {
    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
    // from wso2
    //    	Client client
    // =factory.createClient("http://10.41.87.107:9764/services/PMWebService?wsdl");
    Client client = factory.createClient("http://10.41.87.107:8280/pmservice/1.0.0?wsdl");
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    headers.put("Content-Type", Arrays.asList("text/xml; charset=utf-8"));
    headers.put("Authorization", Arrays.asList(token));
    client.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
    // from gis
    // Wrong Info: tns.StringArray cannot be cast to java.lang.String
    // Client client =factory.createClient("http://10.41.87.37:7789/snt?wsdl");

    Object[] obj = null;
    try {
      // from wso2
      obj = client.invoke("getPMInfo");

      // from gis
      // obj = client.invoke("getAccidentDataforCamera");
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (obj != null) return (String) obj[0];
    return null;
  }
Example #18
0
  @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());
  }
  @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 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);
  }
Example #21
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");
 }
  @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.");
  }
Example #23
0
 // 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));
   }
 }
  @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) {
    }
  }
  /**
   * 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());
  }
  @SuppressWarnings("unchecked")
  protected void handleMouseDown(ListViewEvent<M> e) {
    if (locked) return;
    M sel = listStore.getAt(e.getIndex());

    if (isSelected(sel) && !e.isControlKey()) {
      return;
    }

    if (selectionMode == SelectionMode.SINGLE) {
      if (isSelected(sel) && e.isControlKey()) {
        deselect(sel);
      } else if (!isSelected(sel)) {
        select(sel, false);
      }
    } else {
      if (e.isShiftKey() && lastSelected != null) {
        int last = listStore.indexOf(lastSelected);
        int index = e.getIndex();
        int a = (last > index) ? index : last;
        int b = (last < index) ? index : last;
        select(a, b, e.isControlKey());
        lastSelected = listStore.getAt(last);
        listView.focusItem(index);
        // view.focusRow(index);
      } else if (isSelected(sel) && e.isControlKey()) {
        doDeselect(Arrays.asList(sel), false);
      } else {
        doSelect(Arrays.asList(sel), e.isControlKey(), false);
        listView.focusItem(e.getIndex());
        // view.focusRow(e.rowIndex);
      }
    }
  }
  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"));
  }
Example #28
0
  public void testGetWriterMIMETypes() {
    Set<String> expectedMIMETypes =
        new HashSet<String>(Arrays.asList(new String[] {"image/x-png", "image/png", "image/jpeg"}));

    Set<String> actualMIMETypes = new HashSet<String>(Arrays.asList(ImageIO.getWriterMIMETypes()));
    assertTrue(actualMIMETypes.containsAll(expectedMIMETypes));
  }
 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;
   }
 }
Example #30
0
 public void testStandardJob_adjustCacheHints() {
   final CalculationJob job1 =
       new CalculationJob(
           createJobSpecification(),
           0,
           null,
           Arrays.asList(JOB_ITEM_A, JOB_ITEM_AB),
           CacheSelectHint.allPrivate());
   final CalculationJob job2 =
       new CalculationJob(
           createJobSpecification(),
           0,
           new long[] {job1.getSpecification().getJobId()},
           Arrays.asList(JOB_ITEM_BC),
           CacheSelectHint.privateValues(Arrays.asList(VS_B)));
   job1.addTail(job2);
   final CalculationJob adj1 =
       StandardJob.adjustCacheHints(
           job1,
           new HashMap<
               ValueSpecification,
               Triple<
                   CalculationJob,
                   ? extends Set<ValueSpecification>,
                   ? extends Set<ValueSpecification>>>());
   assertNotNull(adj1.getTail());
   final CalculationJob adj2 = adj1.getTail().iterator().next();
   assertEquals(adj1.getJobItems(), job1.getJobItems());
   assertEquals(adj2.getJobItems(), job2.getJobItems());
   assertTrue(adj1.getCacheSelectHint().isPrivateValue(VS_A));
   assertFalse(adj1.getCacheSelectHint().isPrivateValue(VS_B));
   assertFalse(adj2.getCacheSelectHint().isPrivateValue(VS_B));
   assertFalse(adj2.getCacheSelectHint().isPrivateValue(VS_C));
 }