Java Code Examples for java.util.EnumSet#of()
The following examples show how to use
java.util.EnumSet#of() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kaif File: ClientAppUserAccessTokenArgumentResolverTest.java License: Apache License 2.0 | 6 votes |
@Test public void insufficientScope() throws Exception { Account account = accountCitizen("user1"); ClientAppUserAccessToken token = new ClientAppUserAccessToken(account.getAccountId(), account.getAuthorities(), EnumSet.of(ClientAppScope.ARTICLE), account.getUsername() + "-client-id", account.getUsername() + "-client-secret"); when(clientAppService.verifyAccessToken("a-token")).thenReturn(Optional.of(token)); mockMvc.perform(get("/v1/echo/current-time")// .header(HttpHeaders.AUTHORIZATION, "Bearer a-token ") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isForbidden()) .andExpect(header().string("WWW-Authenticate", q("Bearer realm='Kaif API', error='insufficient_scope', error_description='require scope public', scope='public'"))); }
Example 2
Source Project: audiveris File: ShapeSet.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Report the void template notes suitable for the provided sheet. * * @param sheet provided sheet or null * @return the void template notes, perhaps limited by sheet processing switches */ public static EnumSet<Shape> getVoidTemplateNotes (Sheet sheet) { final EnumSet<Shape> set = EnumSet.of(NOTEHEAD_VOID, WHOLE_NOTE, NOTEHEAD_VOID_SMALL); if (sheet == null) { return set; } final ProcessingSwitches switches = sheet.getStub().getProcessingSwitches(); if (!switches.getValue(Switch.smallVoidHeads)) { set.remove(NOTEHEAD_VOID_SMALL); } return set; }
Example 3
Source Project: hottub File: FlagOpTest.java License: GNU General Public License v2.0 | 5 votes |
protected void testFlagsClearSequence(Supplier<StatefulTestOp<Integer>> cf) { EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED); EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED); EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class); List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>(); for (StreamOpFlag f : EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) { ops.add(cf.get()); ops.add(new TestFlagExpectedOp<>(f.clear(), known.clone(), preserve.clone(), notKnown.clone())); known.remove(f); preserve.remove(f); notKnown.add(f); } ops.add(cf.get()); ops.add(new TestFlagExpectedOp<>(0, known.clone(), preserve.clone(), notKnown.clone())); TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0])); @SuppressWarnings("rawtypes") IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]); withData(data).ops(opsArray). without(StreamTestScenario.CLEAR_SIZED_SCENARIOS). exercise(); }
Example 4
Source Project: cyberduck File: B2LargeUploadPartServiceTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testFind() throws Exception { final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final B2StartLargeFileResponse startResponse = session.getClient().startLargeFileUpload( new B2FileidProvider(session).withCache(cache).getFileid(bucket, new DisabledListProgressListener()), file.getName(), null, Collections.emptyMap()); assertEquals(1, new B2LargeUploadPartService(session, new B2FileidProvider(session).withCache(cache)).find(file).size()); session.getClient().cancelLargeFileUpload(startResponse.getFileId()); }
Example 5
Source Project: cyberduck File: GraphTimestampFeatureTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testSetTimestamp() throws Exception { final Path drive = new OneDriveHomeFinderService(session).find(); final Path file = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new GraphTouchFeature(session).touch(file, new TransferStatus().withMime("x-application/cyberduck")); assertNotNull(new GraphAttributesFinderFeature(session).find(file)); final long modified = Instant.now().minusSeconds(5 * 24 * 60 * 60).getEpochSecond() * 1000; new GraphTimestampFeature(session).setTimestamp(file, modified); assertEquals(modified, new GraphAttributesFinderFeature(session).find(file).getModificationDate()); assertEquals(modified, new DefaultAttributesFinderFeature(session).find(file).getModificationDate()); new GraphDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
Example 6
Source Project: spring-analysis-note File: RestTemplateTests.java License: MIT License | 5 votes |
@Test public void optionsForAllow() throws Exception { mockSentRequest(OPTIONS, "https://example.com"); mockResponseStatus(HttpStatus.OK); HttpHeaders responseHeaders = new HttpHeaders(); EnumSet<HttpMethod> expected = EnumSet.of(GET, POST); responseHeaders.setAllow(expected); given(response.getHeaders()).willReturn(responseHeaders); Set<HttpMethod> result = template.optionsForAllow("https://example.com"); assertEquals("Invalid OPTIONS result", expected, result); verify(response).close(); }
Example 7
Source Project: piranha File: DefaultWebApplicationTest.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test getEffectiveSessionTrackingModes method. */ @Test public void testGetEffectiveSessionTrackingModes() { DefaultWebApplication webApp = new DefaultWebApplication(); Set<SessionTrackingMode> trackingModes = EnumSet.of(SessionTrackingMode.URL); webApp.setSessionTrackingModes(trackingModes); assertTrue(webApp.getEffectiveSessionTrackingModes().contains(SessionTrackingMode.URL)); }
Example 8
Source Project: cyberduck File: SDSDelegatingMoveFeatureTest.java License: GNU General Public License v3.0 | 5 votes |
@Test(expected = NotfoundException.class) public void testMoveNotFound() throws Exception { final Path room = new Path( new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.triplecrypt)); final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session).withCache(cache); new SDSMoveFeature(session, nodeid).move(test, new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); }
Example 9
Source Project: cyberduck File: DefaultPathPredicateTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testPredicateVersionIdFile() { final Path t = new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withVersionId("1")); assertTrue(new DefaultPathPredicate(t).test(t)); assertTrue(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withVersionId("1")))); assertFalse(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withVersionId("2")))); }
Example 10
Source Project: netbeans File: ModuleClassPaths.java License: Apache License 2.0 | 5 votes |
@Override public Set<ClassPath.Flag> getFlags() { getResources(); //Compute incomplete status return incomplete ? EnumSet.of(ClassPath.Flag.INCOMPLETE) : Collections.emptySet(); }
Example 11
Source Project: cyberduck File: PathTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testDictionaryFileSymbolicLink() { Path path = new Path("/path", EnumSet.of(Path.Type.file, Path.Type.symboliclink)); assertEquals(path, new PathDictionary().deserialize(path.serialize(SerializerFactory.get()))); assertEquals(EnumSet.of(Path.Type.file, Path.Type.symboliclink), new PathDictionary().deserialize(path.serialize(SerializerFactory.get())).getType()); }
Example 12
Source Project: cyberduck File: DAVReadFeatureTest.java License: GNU General Public License v3.0 | 5 votes |
@Test public void testReadRange() throws Exception { final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); session.getFeature(Touch.class).touch(test, new TransferStatus()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final byte[] content = new RandomStringGenerator.Builder().build().generate(1000).getBytes(); final OutputStream out = local.getOutputStream(false); assertNotNull(out); IOUtils.write(content, out); out.close(); new DAVUploadFeature(new DAVWriteFeature(session)).upload( test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus().length(content.length), new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); status.setOffset(100L); final InputStream in = new DAVReadFeature(session).read(test, status.length(content.length - 100), new DisabledConnectionCallback()); assertNotNull(in); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100); new StreamCopier(status, status).transfer(in, buffer); final byte[] reference = new byte[content.length - 100]; System.arraycopy(content, 100, reference, 0, content.length - 100); assertArrayEquals(reference, buffer.toByteArray()); in.close(); new DAVDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
Example 13
Source Project: cyberduck File: SFTPCryptomatorInteroperabilityTest.java License: GNU General Public License v3.0 | 5 votes |
/** * Create long file/folder with Cryptomator, read with Cyberduck */ @Test public void testCryptomatorInteroperability() throws Exception { // create folder final java.nio.file.Path targetFolder = cryptoFileSystem.getPath("/", new AlphanumericRandomStringService().random()); Files.createDirectory(targetFolder); // create file and write some random content java.nio.file.Path targetFile = targetFolder.resolve(new AlphanumericRandomStringService().random()); final byte[] content = RandomUtils.nextBytes(20); Files.write(targetFile, content); // read with Cyberduck and compare final Host host = new Host(new SFTPProtocol(), "localhost", PORT_NUMBER, new Credentials("empty", "empty")); final SFTPSession session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path home = new SFTPHomeDirectoryService(session).find(); final Path vault = new Path(home, "vault", EnumSet.of(Path.Type.directory)); final CryptoVault cryptomator = new CryptoVault(vault).load(session, new DisabledPasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) { return new VaultCredentials(passphrase); } }, new DisabledPasswordStore()); session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); Path p = new Path(new Path(vault, targetFolder.getFileName().toString(), EnumSet.of(Path.Type.directory)), targetFile.getFileName().toString(), EnumSet.of(Path.Type.file)); final InputStream read = new CryptoReadFeature(session, new SFTPReadFeature(session), cryptomator).read(p, new TransferStatus(), new DisabledConnectionCallback()); final byte[] readContent = new byte[content.length]; IOUtils.readFully(read, readContent); assertArrayEquals(content, readContent); session.close(); }
Example 14
Source Project: activemq-artemis File: QueueCommandTest.java License: Apache License 2.0 | 5 votes |
@Test public void testUpdateCoreQueue() throws Exception { final String queueName = "updateQueue"; final SimpleString queueNameString = new SimpleString(queueName); final String addressName = "address"; final SimpleString addressSimpleString = new SimpleString(addressName); final int oldMaxConsumers = -1; final RoutingType oldRoutingType = RoutingType.MULTICAST; final boolean oldPurgeOnNoConsumers = false; final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST)); server.addAddressInfo(addressInfo); server.createQueue(new QueueConfiguration(queueNameString).setAddress(addressSimpleString).setRoutingType(oldRoutingType).setMaxConsumers(oldMaxConsumers).setPurgeOnNoConsumers(oldPurgeOnNoConsumers).setAutoCreateAddress(false)); final int newMaxConsumers = 1; final RoutingType newRoutingType = RoutingType.ANYCAST; final boolean newPurgeOnNoConsumers = true; final UpdateQueue updateQueue = new UpdateQueue(); updateQueue.setName(queueName); updateQueue.setPurgeOnNoConsumers(newPurgeOnNoConsumers); updateQueue.setAnycast(true); updateQueue.setMulticast(false); updateQueue.setMaxConsumers(newMaxConsumers); updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error))); checkExecutionPassed(updateQueue); final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString); assertEquals("maxConsumers", newMaxConsumers, queueQueryResult.getMaxConsumers()); assertEquals("routingType", newRoutingType, queueQueryResult.getRoutingType()); assertTrue("purgeOnNoConsumers", newPurgeOnNoConsumers == queueQueryResult.isPurgeOnNoConsumers()); }
Example 15
Source Project: fenixedu-cms File: CmsBootstrapper.java License: GNU Lesser General Public License v3.0 | 4 votes |
private static EnumSet<Permission> getAuthorPermissions() { return EnumSet .of(Permission.CREATE_POST, Permission.DELETE_POSTS, Permission.DELETE_POSTS_PUBLISHED, Permission.SEE_POSTS, Permission.EDIT_POSTS, Permission.EDIT_POSTS_PUBLISHED, Permission.LIST_CATEGORIES, Permission.CREATE_CATEGORY, Permission.PUBLISH_POSTS, Permission.LIST_MENUS); }
Example 16
Source Project: attic-polygene-java File: Servlets.java License: Apache License 2.0 | 4 votes |
public FilterAssembler on( DispatcherType first, DispatcherType... rest ) { dispatchers = EnumSet.of( first, rest ); return this; }
Example 17
Source Project: floodlight_with_topoguard File: MockEntityClassifier.java License: Apache License 2.0 | 4 votes |
@Override public EnumSet<IDeviceService.DeviceField> getKeyFields() { return EnumSet.of(MAC, VLAN, SWITCH, PORT); }
Example 18
Source Project: lua-for-android File: DeferredAttr.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
LambdaReturnScanner() { super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); }
Example 19
Source Project: components File: TAzureStorageQueuePurgeDefinition.java License: Apache License 2.0 | 4 votes |
@Override public Set<ConnectorTopology> getSupportedConnectorTopologies() { return EnumSet.of(ConnectorTopology.NONE); }
Example 20
Source Project: jdk-1.7-annotated File: NumericShaper.java License: Apache License 2.0 | 2 votes |
/** * Returns a shaper for the provided Unicode * range. All Latin-1 (EUROPEAN) digits are converted to the * corresponding decimal digits of the specified Unicode range. * * @param singleRange the Unicode range given by a {@link * NumericShaper.Range} constant. * @return a non-contextual {@code NumericShaper}. * @throws NullPointerException if {@code singleRange} is {@code null} * @since 1.7 */ public static NumericShaper getShaper(Range singleRange) { return new NumericShaper(singleRange, EnumSet.of(singleRange)); }