@Test public void qualifiers_from_key() { assertThat(Qualifier.fromKey(Qualifiers.PROJECT)).isEqualTo(Qualifier.PROJECT); assertThat(Qualifier.fromKey("42")).isNull(); }
@Test public void value_of_status() { assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); assertThat(TestCase.Status.of("OK")).isEqualTo(TestCase.Status.OK); assertThat(TestCase.Status.of(null)).isNull(); } }
@Test public void testCreatingSingleValueUsingValueOfOnEnumeration() { assertThat(Converters.create(HttpMethod.class, "GET")).isEqualTo(HttpMethod.GET); try { assertThat(Converters.create(HttpMethod.class, null)).isNull(); fail("Exception expected"); } catch (IllegalArgumentException e) { // OK. } // Invalid value try { assertThat(Converters.create(HttpMethod.class, "FOO_IS_NOT_A_METHOD")).isNull(); fail("Exception expected"); } catch (IllegalArgumentException e) { // OK. } }
@Test public void testEnums() { assertThat(AllTypes.NestedEnum.fromValue(1)).isEqualTo(A); assertThat(AllTypes.NestedEnum.fromValue(10)).isNull(); assertThat(A.getValue()).isEqualTo(1); }
@Test public void allocateFromFragmentWithBadIndexesReturnsNull() { Slab chunk = new SlabImpl(96); this.freeListManager = createFreeListManager(ma, new Slab[] {chunk}); assertThat(this.freeListManager.allocateFromFragment(-1, 32)).isNull(); assertThat(this.freeListManager.allocateFromFragment(1, 32)).isNull(); }
@Test public void syntaxNotRequired() throws Exception { String proto = "message Foo {}"; ProtoFileElement parsed = ProtoParser.parse(location, proto); assertThat(parsed.syntax()).isNull(); }
@Test public void setTargetWillSetTXStateStubIfTargetIsDifferentFromLocalMember() { TXStateProxyImpl tx = spy(new TXStateProxyImpl(cache, txManager, txId, false)); assertThat(tx.hasRealDeal()).isFalse(); assertThat(tx.getTarget()).isNull(); DistributedMember remoteMember = mock(InternalDistributedMember.class); tx.setTarget(remoteMember); assertThat(tx.getTarget()).isEqualTo(remoteMember); assertThat(tx.isRealDealLocal()).isFalse(); assertThat(tx.hasRealDeal()).isTrue(); }
@Test public void createCrosshairByEmptyConstructor_hasStrokeTypeIsNull() { //when Crosshair crosshair = new Crosshair(); //then Assertions.assertThat(crosshair.getStyle()).isNull(); }
@Test public void setTargetWillSetTargetToItselfAndSetTXStateIfRealDealIsNull() { TXStateProxyImpl tx = spy(new TXStateProxyImpl(cache, txManager, txId, false)); assertThat(tx.hasRealDeal()).isFalse(); assertThat(tx.getTarget()).isNull(); tx.setTarget(member); assertThat(tx.getTarget()).isEqualTo(member); assertThat(tx.isRealDealLocal()).isTrue(); }
@Test public void createLineByEmptyConstructor_lineHasStyleIsNull() { //when Line line = new Line(); //then Assertions.assertThat(line.getStyle()).isNull(); }
@Test public void convert_deprecated_priority() { assertThat(KeyValueFormat.newPriorityConverter().format(RulePriority.BLOCKER)).isEqualTo("BLOCKER"); assertThat(KeyValueFormat.newPriorityConverter().format(null)).isEqualTo(""); assertThat(KeyValueFormat.newPriorityConverter().parse("MAJOR")).isEqualTo(RulePriority.MAJOR); assertThat(KeyValueFormat.newPriorityConverter().parse("")).isNull(); }
@Test public void findSameTask_nonMatch() { final DownloadTask task = mock(DownloadTask.class); assertThat(dispatcher.findSameTask(task)).isNull(); }
@Test public void setTargetToItSelfIfRealDealIsTXStateAndTargetIsSameAsLocalMember() { TXStateProxyImpl tx = spy(new TXStateProxyImpl(cache, txManager, txId, false)); tx.setLocalTXState(new TXState(tx, true)); assertThat(tx.isRealDealLocal()).isTrue(); assertThat(tx.getTarget()).isNull(); tx.setTarget(member); assertThat(tx.getTarget()).isEqualTo(member); assertThat(tx.isRealDealLocal()).isTrue(); }
@Test public void testRemovingExecutor() throws Exception { final Executor executor = this.executorDao.addExecutor("localhost1", 12345); assertThat(executor).isNotNull(); this.executorDao.removeExecutor("localhost1", 12345); final Executor fetchedExecutor = this.executorDao.fetchExecutor("localhost1", 12345); assertThat(fetchedExecutor).isNull(); }
@Test public void commenceWhenNoSubscriberThenNothingHappens() { this.entryPoint.commence(this.exchange, new BadCredentialsException("")); assertThat(getResponse().getHeaders()).isEmpty(); assertThat(getResponse().getStatusCode()).isNull(); }
@Test(expected = AssertionError.class) public void setTargetThrowsIfIfRealDealIsTXStateAndTargetIsDifferentFromLocalMember() { TXStateProxyImpl tx = spy(new TXStateProxyImpl(cache, txManager, txId, false)); tx.setLocalTXState(new TXState(tx, true)); assertThat(tx.getTarget()).isNull(); DistributedMember remoteMember = mock(InternalDistributedMember.class); tx.setTarget(remoteMember); } }
@Test public void createTreeMapByDefaultConstructor_hasModeAndStickyAndRoundAndRatioAreNulls() { //given treeMap = createWidget(); //then assertThat(treeMap.getMode()).isNull(); assertThat(treeMap.getRatio()).isNull(); assertThat(treeMap.getSticky()).isNull(); assertThat(treeMap.getRound()).isNull(); }
@Test public void testHandlesNulls() { handle.execute("insert into intervals(id, foo) values(?, ?)", 5, null); final Duration d = handle.createQuery("select foo from intervals where id=?") .bind(0, 5) .mapTo(Duration.class) .findOnly(); assertThat(d).isNull(); }
@Test public void accept_new_externally_defined_Rules() { RuleKey ruleKey = RuleKey.of("external_eslint", "no-cond-assign"); underTest.addOrUpdateAddHocRuleIfNeeded(ruleKey, () -> new NewAdHocRule(ScannerReport.ExternalIssue.newBuilder().setEngineId("eslint").setRuleId("no-cond-assign").build())); assertThat(underTest.getByKey(ruleKey)).isNotNull(); assertThat(underTest.getByKey(ruleKey).getType()).isNull(); RuleDao ruleDao = dbClient.ruleDao(); Optional<RuleDefinitionDto> ruleDefinitionDto = ruleDao.selectDefinitionByKey(dbClient.openSession(false), ruleKey); assertThat(ruleDefinitionDto).isNotPresent(); }
@Test public void testAssignAndUnassignExecutor() throws Exception { final String host = "localhost"; final int port = 12345; final Executor executor = this.executorDao.addExecutor(host, port); final ExecutableFlow flow = TestUtils.createTestExecutableFlow("exectest1", "exec1"); this.executionFlowDao.uploadExecutableFlow(flow); this.assignExecutor.assignExecutor(executor.getId(), flow.getExecutionId()); final Executor fetchExecutor = this.executorDao .fetchExecutorByExecutionId(flow.getExecutionId()); assertThat(fetchExecutor).isEqualTo(executor); this.assignExecutor.unassignExecutor(flow.getExecutionId()); assertThat(this.executorDao.fetchExecutorByExecutionId(flow.getExecutionId())).isNull(); }