use of org.junit.Assert.assertTrue in project flow by vaadin.
the class BootstrapHandlerTest method no_body_size_or_page_configurator_still_adds_margin_for_body.
// 2344
@Test
public void no_body_size_or_page_configurator_still_adds_margin_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(RootNavigationTarget.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style containing margin", styleTag.get().toString().startsWith("<style type=\"text/css\">body {margin:0;}"));
}
use of org.junit.Assert.assertTrue in project OpenGrok by OpenGrok.
the class ProjectMessageTest method testAdd.
@Test
public void testAdd() throws Exception {
Assert.assertTrue(env.getRepositories().isEmpty());
Assert.assertTrue(env.getProjects().isEmpty());
// Add a group matching the project to be added.
String groupName = "mercurialgroup";
Group group = new Group(groupName, "mercurial.*");
env.getGroups().add(group);
Assert.assertTrue(env.hasGroups());
Assert.assertEquals(1, env.getGroups().stream().filter(g -> g.getName().equals(groupName)).collect(Collectors.toSet()).size());
Assert.assertEquals(0, group.getRepositories().size());
Assert.assertEquals(0, group.getProjects().size());
// Prepare project addition.
Message m = new ProjectMessage();
m.setText("add");
m.addTag("mercurial");
// Add a sub-repository.
String repoPath = repository.getSourceRoot() + File.separator + "mercurial";
File mercurialRoot = new File(repoPath);
File subDir = new File(mercurialRoot, "usr");
Assert.assertTrue(subDir.mkdir());
String subRepoPath = repoPath + File.separator + "usr" + File.separator + "closed";
File mercurialSubRoot = new File(subRepoPath);
MercurialRepositoryTest.runHgCommand(mercurialRoot, "clone", mercurialRoot.getAbsolutePath(), subRepoPath);
// Add the project.
env.setScanningDepth(3);
m.apply(env);
// Check that the project was added properly.
Assert.assertTrue(env.getProjects().containsKey("mercurial"));
Assert.assertEquals(1, env.getProjects().size());
Assert.assertEquals(2, env.getRepositories().size());
Assert.assertEquals(1, group.getRepositories().size());
Assert.assertEquals(0, group.getProjects().size());
Assert.assertEquals(1, group.getRepositories().stream().filter(p -> p.getName().equals("mercurial")).collect(Collectors.toSet()).size());
// Check that HistoryGuru now includes the project in its list.
Set<String> directoryNames = HistoryGuru.getInstance().getRepositories().stream().map(ri -> ri.getDirectoryName()).collect(Collectors.toSet());
Assert.assertTrue("though it should contain the top root,", directoryNames.contains(repoPath) || directoryNames.contains(mercurialRoot.getCanonicalPath()));
Assert.assertTrue("though it should contain the sub-root,", directoryNames.contains(subRepoPath) || directoryNames.contains(mercurialSubRoot.getCanonicalPath()));
// Add more projects and check that they have been added incrementally.
// At the same time, it checks that multiple projects can be added
// with single message.
m.setTags(new TreeSet<>());
m.addTag("git");
m.addTag("svn");
m.apply(env);
Assert.assertEquals(3, env.getProjects().size());
Assert.assertEquals(4, env.getRepositories().size());
Assert.assertTrue(env.getProjects().containsKey("git"));
Assert.assertTrue(env.getProjects().containsKey("svn"));
Assert.assertFalse(HistoryGuru.getInstance().getRepositories().stream().map(ri -> ri.getDirectoryName()).collect(Collectors.toSet()).contains("git"));
Assert.assertFalse(HistoryGuru.getInstance().getRepositories().stream().map(ri -> ri.getDirectoryName()).collect(Collectors.toSet()).contains("svn"));
}
use of org.junit.Assert.assertTrue in project keycloak by keycloak.
the class AuthorizationTest method testEnableAuthorizationServices.
@Test
public void testEnableAuthorizationServices() {
ClientResource clientResource = getClientResource();
ClientRepresentation resourceServer = getResourceServer();
RealmResource realm = realmsResouce().realm(getRealmId());
UserRepresentation serviceAccount = realm.users().search(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX + resourceServer.getClientId()).get(0);
Assert.assertNotNull(serviceAccount);
List<RoleRepresentation> serviceAccountRoles = realm.users().get(serviceAccount.getId()).roles().clientLevel(resourceServer.getId()).listEffective();
Assert.assertTrue(serviceAccountRoles.stream().anyMatch(roleRepresentation -> "uma_protection".equals(roleRepresentation.getName())));
enableAuthorizationServices(false);
enableAuthorizationServices(true);
serviceAccount = clientResource.getServiceAccountUser();
Assert.assertNotNull(serviceAccount);
realm = realmsResouce().realm(getRealmId());
serviceAccountRoles = realm.users().get(serviceAccount.getId()).roles().clientLevel(resourceServer.getId()).listEffective();
Assert.assertTrue(serviceAccountRoles.stream().anyMatch(roleRepresentation -> "uma_protection".equals(roleRepresentation.getName())));
JSPolicyRepresentation policy = new JSPolicyRepresentation();
policy.setName("should be removed");
policy.setCode("");
clientResource.authorization().policies().js().create(policy);
List<ResourceRepresentation> defaultResources = clientResource.authorization().resources().resources();
assertEquals(1, defaultResources.size());
List<PolicyRepresentation> defaultPolicies = clientResource.authorization().policies().policies();
assertEquals(3, defaultPolicies.size());
enableAuthorizationServices(false);
enableAuthorizationServices(true);
ResourceServerRepresentation settings = clientResource.authorization().getSettings();
assertEquals(PolicyEnforcerConfig.EnforcementMode.ENFORCING.name(), settings.getPolicyEnforcementMode().name());
assertTrue(settings.isAllowRemoteResourceManagement());
assertEquals(resourceServer.getId(), settings.getClientId());
defaultResources = clientResource.authorization().resources().resources();
assertEquals(1, defaultResources.size());
defaultPolicies = clientResource.authorization().policies().policies();
assertEquals(2, defaultPolicies.size());
serviceAccount = clientResource.getServiceAccountUser();
Assert.assertNotNull(serviceAccount);
serviceAccountRoles = realm.users().get(serviceAccount.getId()).roles().clientLevel(resourceServer.getId()).listEffective();
Assert.assertTrue(serviceAccountRoles.stream().anyMatch(roleRepresentation -> "uma_protection".equals(roleRepresentation.getName())));
}
use of org.junit.Assert.assertTrue in project gridss by PapenfussLab.
the class SequentialEvidenceAllocatorTest method RemoteOverlap_localLookup_should_split_on_referenceIndex_and_direction.
@Test
public void RemoteOverlap_localLookup_should_split_on_referenceIndex_and_direction() {
final ProcessingContext pc = getContext();
pc.getVariantCallingParameters().writeFiltered = true;
pc.getVariantCallingParameters().minScore = 0;
pc.getVariantCallingParameters().breakendMargin = 0;
StubSAMEvidenceSource ses = new StubSAMEvidenceSource(pc, null, 0, 0, 100);
ses.evidence.add(SCE(FWD, Read(0, 1, "1S1M1S")));
ses.evidence.add(SCE(BWD, Read(0, 1, "1S1M1S")));
// ses.evidence.add(SCE(BWD, Read(1, 1, "1S1M1S")));
// ses.evidence.add(SCE(FWD, Read(1, 1, "1S1M1S")));
SequentialEvidenceAllocator allocator = new SequentialEvidenceAllocator(pc, ImmutableList.of((VariantContextDirectedBreakpoint) TestHelper.minimalVariant().breakpoint(new BreakpointSummary(1, FWD, 1, 1, 1, 0, FWD, 1, 1, 1), "").phredScore(1).id("call").make()).iterator(), ses.evidence.iterator(), Integer.MAX_VALUE, true);
// shouldn't crash
VariantEvidenceSupport ves = allocator.next();
Assert.assertTrue(ves.support.stream().allMatch(e -> ves.variant.getBreakendSummary().overlaps(e.getBreakendSummary())));
}
use of org.junit.Assert.assertTrue in project flink by apache.
the class FutureUtilsTest method testFutureContinuation.
private void testFutureContinuation(BiFunction<CompletableFuture<?>, Executor, CompletableFuture<?>> testFunctionGenerator) {
CompletableFuture<?> startFuture = new CompletableFuture<>();
final AtomicBoolean runWithExecutor = new AtomicBoolean(false);
Executor executor = r -> {
r.run();
runWithExecutor.set(true);
};
// branch for a start future that has not completed
CompletableFuture<?> continuationFuture = testFunctionGenerator.apply(startFuture, executor);
Assert.assertFalse(continuationFuture.isDone());
startFuture.complete(null);
Assert.assertTrue(runWithExecutor.get());
Assert.assertTrue(continuationFuture.isDone());
// branch for a start future that was completed
runWithExecutor.set(false);
continuationFuture = testFunctionGenerator.apply(startFuture, executor);
Assert.assertFalse(runWithExecutor.get());
Assert.assertTrue(continuationFuture.isDone());
}
Aggregations