private void verifyGroup(String expectedName, String expectedDescription) { Map<String, Object> cols = db.selectFirst("select name as \"name\", description as \"description\", " + "created_at as \"created_at\", updated_at as \"updated_at\" " + "from groups where name='" + expectedName + "'"); assertThat(cols.get("name")).isEqualTo(expectedName); assertThat(cols.get("description")).isEqualTo(expectedDescription); assertThat(cols.get("created_at")).isNotNull(); }
@Test public void shouldCreateDesEncryptorIfCipherFileIsPresent() throws IOException { resetCipher.setupDESCipherFile(); assertThat(desCipherFile).exists(); GoCipher goCipher = new GoCipher(systemEnvironment); assertThat(goCipher.aesEncrypter).isNotNull(); assertThat(goCipher.desEncrypter).isNotNull(); }
@Test public void should_create_cache() { Storage<Element> cache = caches.createCache("foo"); assertThat(cache).isNotNull(); }
@Test public void shouldNotCreateDesCipherIfCipherFileMissing() { assertThat(desCipherFile).doesNotExist(); GoCipher goCipher = new GoCipher(systemEnvironment); assertThat(goCipher.aesEncrypter).isNotNull(); assertThat(goCipher.desEncrypter).isNull(); }
@Test public void testGetImageSizeScaleTo_useImageLayoutParams() throws Exception { // Set a defined width mView.setLayoutParams(new FrameLayout.LayoutParams(300, 300)); ImageSize expected = new ImageSize(300, 300); ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500)); Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected); }
@Test public void define_controller() { WebService.Controller controller = controller(); assertThat(controller).isNotNull(); assertThat(controller.description()).isNotEmpty(); assertThat(controller.since()).isEqualTo("3.7"); assertThat(controller.actions()).hasSize(2); }
@Test public void should_provide_list_of_extensions() { when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo"))); when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooBarProvider())); ComponentContainer container = new ComponentContainer(); ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mode, settings.asConfig()); installer.install(container, new TrueMatcher()); assertThat(container.getComponentByType(Foo.class)).isNotNull(); assertThat(container.getComponentByType(Bar.class)).isNotNull(); }
@Test public void testGetImageSizeScaleTo_useImageConfigMaxSize() throws Exception { ImageSize expected = new ImageSize(500, 500); ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500)); Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected); }
@Test public void execute_is_reentreant() throws SQLException { insertQualityGate("Test 1", null); insertQualityGate("Test 2", null); underTest.execute(); underTest.execute(); assertThat(selectAllQualityGates("NAME", "IS_BUILT_IN", "CREATED_AT", "UPDATED_AT")) .containsExactlyInAnyOrder( tuple("Test 1", false, new Date(PAST), new Date(NOW)), tuple("Test 2", false, new Date(PAST), new Date(NOW))); selectAllQualityGates("UUID").forEach(c -> assertThat(c).isNotNull()); }
@Test public void define_ws() { WebService.Controller controller = ws.controller("api/metrics"); assertThat(controller).isNotNull(); assertThat(controller.description()).isNotEmpty(); assertThat(controller.actions()).hasSize(6); }
@Test public void test_definition() { ProjectBadgesWsAction action = createFakeAction(); WebService.Context context = new WebService.Context(); ProjectBadgesWs underTest = new ProjectBadgesWs(Collections.singletonList(action)); underTest.define(context); WebService.Controller controller = context.controller("api/project_badges"); assertThat(controller).isNotNull(); assertThat(controller.description()).isNotEmpty(); assertThat(controller.since()).isEqualTo("7.1"); }
@Test public void generate_new_secret_key_if_not_set_by_settings() { assertThat(underTest.getSecretKey()).isNull(); underTest.start(); assertThat(underTest.getSecretKey()).isNotNull(); assertThat(underTest.getSecretKey().getAlgorithm()).isEqualTo(SignatureAlgorithm.HS256.getJcaName()); }
@Test public void define_index_action() { WebService.Action action = controller.action("index"); assertThat(action).isNotNull(); assertThat(action.handler()).isInstanceOf(RemovedWebServiceHandler.class); assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).isEmpty(); }
@Test public void testGetImageSizeScaleTo_useImageActualSize() throws Exception { // We layout the view to give it a width and height mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY)); mView.layout(0, 0, 200, 200); ImageSize expected = new ImageSize(200, 200); ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(590, 590)); Assertions.assertThat(result).isNotNull(); Assertions.assertThat(result.getWidth()).isEqualTo(expected.getWidth()); Assertions.assertThat(result.getHeight()).isEqualTo(expected.getHeight()); }
@Test public void define_index_action() { WebService.Controller controller = ws.controller("api/profiles"); WebService.Action restoreProfiles = controller.action("index"); assertThat(restoreProfiles).isNotNull(); assertThat(restoreProfiles.handler()).isInstanceOf(RemovedWebServiceHandler.class); assertThat(restoreProfiles.responseExampleAsString()).isNotEmpty(); assertThat(restoreProfiles.params()).isEmpty(); }
@Test public void index_with_source() { NewIndex index = new NewIndex("issues", defaultSettingsConfiguration); NewIndex.NewIndexType mapping = index.createType("issue"); mapping.setEnableSource(true); mapping = index.getTypes().get("issue"); assertThat(mapping).isNotNull(); assertThat(getAttributeAsMap(mapping, "_source")).containsExactly(entry("enabled", true)); }
@Test public void register_and_unregister() throws Exception { assertThat(getMBean()).isNull(); underTest.start(); assertThat(getMBean()).isNotNull(); underTest.stop(); assertThat(getMBean()).isNull(); }
@Override public Optional<Measure> createMeasure(FakeCounter counter, CreateMeasureContext context) { // verify the context which is passed to the method assertThat(context.getComponent()).isNotNull(); assertThat(context.getMetric()) .isIn(metricRepository.getByKey(NEW_LINES_TO_COVER_KEY), metricRepository.getByKey(NEW_COVERAGE_KEY)); return Optional.of(Measure.newMeasureBuilder().create(counter.value + metricOffset(context.getMetric()))); }
@Test public void scan_permission_on_organization_is_enough_even_without_scan_permission_on_project() { ComponentDto project = db.components().insertPrivateProject(); userSession.logIn().addPermission(SCAN, project.getOrganizationUuid()); userSession.logIn().addProjectPermission(UserRole.USER, project); ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setProjectKey(project.getKey()).setIssuesMode(true)); assertThat(repositories).isNotNull(); }