Refine search
@Test public void getActiveProfiles_fromSystemProperties() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo"); assertThat(Arrays.asList(environment.getActiveProfiles()), hasItem("foo")); System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); }
@Override protected boolean handleDirectory(File directory, int depth, Collection results) throws IOException { assertThat(directories, hasItem(directory.getName())); return true; }
@Test public void setDefaultProfiles() { environment.setDefaultProfiles(); assertThat(environment.getDefaultProfiles().length, is(0)); environment.setDefaultProfiles("pd1"); assertThat(Arrays.asList(environment.getDefaultProfiles()), hasItem("pd1")); environment.setDefaultProfiles("pd2", "pd3"); assertThat(Arrays.asList(environment.getDefaultProfiles()), not(hasItem("pd1"))); assertThat(Arrays.asList(environment.getDefaultProfiles()), hasItems("pd2", "pd3")); }
@Test public void testStopJobAfterSavepoint() throws Exception { setUpWithCheckpointInterval(10L); final String savepointLocation = cancelWithSavepoint(); final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(); assertThat(jobStatus, isOneOf(JobStatus.CANCELED, JobStatus.CANCELLING)); final List<Path> savepoints; try (Stream<Path> savepointFiles = Files.list(savepointDirectory)) { savepoints = savepointFiles.map(Path::getFileName).collect(Collectors.toList()); } assertThat(savepoints, hasItem(Paths.get(savepointLocation).getFileName())); }
@Test public void shouldRegisterAllGoConfigValidators() { List<String> list = (List<String>) CollectionUtils.collect(MagicalGoConfigXmlLoader.VALIDATORS, o -> o.getClass().getCanonicalName()); assertThat(list, hasItem(ArtifactDirValidator.class.getCanonicalName())); assertThat(list, hasItem(EnvironmentAgentValidator.class.getCanonicalName())); assertThat(list, hasItem(ServerIdImmutabilityValidator.class.getCanonicalName())); assertThat(list, hasItem(CommandRepositoryLocationValidator.class.getCanonicalName())); assertThat(list, hasItem(TokenGenerationKeyImmutabilityValidator.class.getCanonicalName())); }
@Test public void testStopJobAfterSavepointWithDeactivatedPeriodicCheckpointing() throws Exception { // set checkpointInterval to Long.MAX_VALUE, which means deactivated checkpointing setUpWithCheckpointInterval(Long.MAX_VALUE); final String savepointLocation = cancelWithSavepoint(); final JobStatus jobStatus = clusterClient.getJobStatus(jobGraph.getJobID()).get(60, TimeUnit.SECONDS); assertThat(jobStatus, isOneOf(JobStatus.CANCELED, JobStatus.CANCELLING)); final List<Path> savepoints; try (Stream<Path> savepointFiles = Files.list(savepointDirectory)) { savepoints = savepointFiles.map(Path::getFileName).collect(Collectors.toList()); } assertThat(savepoints, hasItem(Paths.get(savepointLocation).getFileName())); }
private void assertion(AdminsConfig actualView) { assertThat(actualView, hasItem((Admin) new AdminUser(new CaseInsensitiveString("jez")))); assertThat(actualView, hasItem((Admin) new AdminUser(new CaseInsensitiveString("lqiao")))); assertThat(actualView, hasItem((Admin) new AdminRole(new CaseInsensitiveString("mingle")))); }
@Test public void nextNumberValue() { HashSet<Class<? extends NumberValue>> seen = new HashSet<>( NUMBER_TYPES ); for ( int i = 0; i < ITERATIONS; i++ ) { NumberValue numberValue = randomValues.nextNumberValue(); assertThat( NUMBER_TYPES, hasItem( numberValue.getClass() ) ); seen.remove( numberValue.getClass() ); } assertThat( seen, empty() ); }
@Test public void testRequestAttributeMatcher() throws Exception { String producibleMediaTypes = HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE; this.mockMvc.perform(get("/1")) .andExpect(request().attribute(producibleMediaTypes, hasItem(MediaType.APPLICATION_JSON))) .andExpect(request().attribute(producibleMediaTypes, not(hasItem(MediaType.APPLICATION_XML)))); }
@Theory public void theoryParentsKnowTheirChildren(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(directory())); Resource parent = res.parent(); assumeThat(path, parent, notNullValue()); // Make sure this resource has a parent Collection<Resource> result = parent.list(); assertThat(path, result, hasItem(res)); // this assumed equals was written! }
@Test public void shouldUnderstandEnvironmentsForAgent() { assertThat(configs.environmentsForAgent("agent-one"), hasItem("uat")); }
@Test public void hamcrestMatchers() throws Exception { this.mockServer.expect(requestTo("/composers")) .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(jsonPath("$.composers[0].name").value(equalTo("Johann Sebastian Bach"))) .andExpect(jsonPath("$.performers[1].name").value(equalTo("Yehudi Menuhin"))) .andExpect(jsonPath("$.composers[0].name", startsWith("Johann"))) .andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy"))) .andExpect(jsonPath("$.performers[1].name", containsString("di Me"))) .andExpect(jsonPath("$.composers[1].name", isIn(Arrays.asList("Johann Sebastian Bach", "Johannes Brahms")))) .andExpect(jsonPath("$.composers[:3].name", hasItem("Johannes Brahms"))) .andRespond(withSuccess()); executeAndVerify(); }
@Theory public void theoryAddingFileToDirectoryAddsResource(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(directory())); File dir = res.dir(); File file = new File(dir, "newFileCreatedDirectly"); assumeTrue(file.createNewFile()); Resource child = getResource(Paths.path(res.path(), "newFileCreatedDirectly")); Collection<Resource> children = res.list(); assertThat(child, is(defined())); assertThat(children, hasItem(child)); }
@Test public void shouldGetAllTasks() { ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled()); registry.registerImplementer(Task.class, AntTask.class, ExecTask.class, NantTask.class, RakeTask.class, FetchTask.class, FetchPluggableArtifactTask.class); List<String> tasks = ConfigUtil.allTasks(registry); assertThat(tasks.size(), is(5)); assertThat(tasks, hasItem("ant")); assertThat(tasks, hasItem("exec")); assertThat(tasks, hasItem("nant")); assertThat(tasks, hasItem("rake")); assertThat(tasks, hasItem("fetchartifact")); } }
@Test public void getDefaultProfiles() { assertThat(environment.getDefaultProfiles(), equalTo(new String[] {RESERVED_DEFAULT_PROFILE_NAME})); environment.getPropertySources().addFirst(new MockPropertySource().withProperty(DEFAULT_PROFILES_PROPERTY_NAME, "pd1")); assertThat(environment.getDefaultProfiles().length, is(1)); assertThat(Arrays.asList(environment.getDefaultProfiles()), hasItem("pd1")); }
@Test public void shouldHaveActionRemoveIfThereAreNoAgents() { List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents); assertThat(selections, hasItem(new TriStateSelection("one", TriStateSelection.Action.remove))); assertThat(selections, hasItem(new TriStateSelection("two", TriStateSelection.Action.remove))); assertThat(selections.size(), is(2)); }
@Test public void canGetUrisForNode() { Map<String, List<String>> extensions = manager.getExensionsFor( GraphDatabaseService.class ); List<String> methods = extensions.get( FunctionalTestPlugin.class.getSimpleName() ); assertNotNull( methods ); assertThat( methods, hasItem( FunctionalTestPlugin.CREATE_NODE ) ); }
@Test public void cacheResourcesConfiguration() throws Exception { WebContentInterceptor interceptor = new WebContentInterceptor(); interceptor.setCacheSeconds(10); interceptor.preHandle(request, response, null); Iterable<String> cacheControlHeaders = response.getHeaders("Cache-Control"); assertThat(cacheControlHeaders, Matchers.hasItem("max-age=10")); }
@Test public void testGetSpringConfigurationClasses() { assertThat(module.getSpringConfigurationClasses(),hasItem(this.getClass())); } @Test
@Test public void listConfig() throws Exception { // When List<Object[]> config = callListConfig( "" ); List<String> names = config.stream() .map( o -> o[0].toString() ) .collect( Collectors.toList() ); // The size of the config is not fixed so just make sure it's the right magnitude assertTrue( names.size() > 10 ); assertThat( names, hasItem( GraphDatabaseSettings.record_format.name() ) ); // Should not contain "unsupported.*" configs assertEquals( names.stream() .filter( n -> n.startsWith( "unsupported" ) ) .count(), 0 ); }