Java Code Examples for org.junit.Assert#assertEquals()
The following examples show how to use
org.junit.Assert#assertEquals() .
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 File: PaymentsAccountServiceClientTest.java From google-ads-java with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("all") public void listPaymentsAccountsTest() { ListPaymentsAccountsResponse expectedResponse = ListPaymentsAccountsResponse.newBuilder().build(); mockPaymentsAccountService.addResponse(expectedResponse); String customerId = "customerId-1772061412"; ListPaymentsAccountsResponse actualResponse = client.listPaymentsAccounts(customerId); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockPaymentsAccountService.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListPaymentsAccountsRequest actualRequest = (ListPaymentsAccountsRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
Example 2
Source File: GithubServerTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void testMissingUrlParam() throws Exception { Map resp = request() .status(400) .jwtToken(token) .crumb( crumb ) .data(ImmutableMap.of("name", "foo")) .post("/organizations/jenkins/scm/github-enterprise/servers/") .build(Map.class); Assert.assertNotNull(resp); List errors = (List) resp.get("errors"); Assert.assertEquals(1, errors.size()); Map error1 = (Map) errors.get(0); Assert.assertEquals("apiUrl", error1.get("field")); Assert.assertEquals("MISSING", error1.get("code")); Assert.assertEquals("apiUrl is required", error1.get("message")); }
Example 3
Source File: TestELParser.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void bug56185() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(factory); TesterBeanC beanC = new TesterBeanC(); ValueExpression var = factory.createValueExpression(beanC, TesterBeanC.class); context.getVariableMapper().setVariable("myBean", var); ValueExpression ve = factory.createValueExpression(context, "${(myBean.int1 > 1 and myBean.myBool) or "+ "((myBean.myBool or myBean.myBool1) and myBean.int1 > 1)}", Boolean.class); Assert.assertEquals(Boolean.FALSE, ve.getValue(context)); beanC.setInt1(2); beanC.setMyBool1(true); Assert.assertEquals(Boolean.TRUE, ve.getValue(context)); }
Example 4
Source File: MetaUpdateTest2.java From x-pipe with Apache License 2.0 | 6 votes |
@Test public void addKeepers2() throws Exception { String cluster = "cluster-test", shard = "shard-test", dc = "SHAJQ"; when(redisService.findKeepersByDcClusterShard(dc, cluster, shard)).thenReturn(null); KeeperBasicInfo keeper1 = new KeeperBasicInfo(); keeper1.setHost("127.0.0.1"); keeper1.setPort(6379); keeper1.setKeeperContainerId(1); keepers = Lists.newArrayList(keeper1); when(keeperAdvancedService.findBestKeepers(eq(dc), eq(RedisProtocol.REDIS_PORT_DEFAULT), any(), eq(cluster))) .thenReturn(keepers); when(redisService.insertKeepers(anyString(), anyString(), anyString(), eq(keepers))) .thenReturn(2 - keepers.size()); Assert.assertEquals(1, metaUpdate.addKeepers(dc, cluster, new ShardTbl().setShardName(shard))); }
Example 5
Source File: TextUtilTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void testAppendNullByte() { Text text = new Text(new byte[] {1, 2, 3}); TextUtil.appendNullByte(text); Assert.assertEquals(4, text.getLength()); Assert.assertEquals(0, text.getBytes()[3]); }
Example 6
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputDoubleArrayFromMatrixDML() { System.out.println("MLContextTest - output double array from matrix DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2);"; double[][] matrix = ml.execute(dml(s).out("M")).getMatrix("M").to2DDoubleArray(); Assert.assertEquals(1.0, matrix[0][0], 0); Assert.assertEquals(2.0, matrix[0][1], 0); Assert.assertEquals(3.0, matrix[1][0], 0); Assert.assertEquals(4.0, matrix[1][1], 0); }
Example 7
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testIntDouble() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1), new DeferredJavaObject(2.5d)}); Assert.assertEquals("1:2.5", ret.toString()); }
Example 8
Source File: RaptorClientTest.java From raptor with Apache License 2.0 | 5 votes |
@Test public void getGet1() { HelloRequest helloRequest = new HelloRequest(); helloRequest.setName("ppdai"); HelloReply reply = moreService.testGet1(helloRequest); Assert.assertEquals("testGet1", reply.getMessage()); }
Example 9
Source File: BooleanDimEncTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private void testSerDes(BooleanDimEnc enc, String valueStr) { DataTypeSerializer<Object> ser = enc.asDataTypeSerializer(); byte[] buf = new byte[enc.getLengthOfEncoding()]; ser.serialize(valueStr, ByteBuffer.wrap(buf)); String decode = (String) ser.deserialize(ByteBuffer.wrap(buf)); Assert.assertEquals(valueStr, decode); }
Example 10
Source File: ProtoDomainTest.java From metastore with Apache License 2.0 | 5 votes |
@Test public void getFileOptionByName() throws IOException { ProtoDomain domain = TestSets.baseAddFileOption(); Descriptors.FieldDescriptor fd = domain.getOptions().getFileOptionByName("test.v1.file_option_1"); Assert.assertEquals("test.v1.file_option_1", fd.getFullName()); }
Example 11
Source File: RpcLoggerFactoryTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Test public void getLogger() throws Exception { Assert.assertNull(RpcLoggerFactory.getLogger(null, "appname1")); Logger logger1 = RpcLoggerFactory.getLogger("xxx", "appname1"); Assert.assertNotNull(logger1); Logger logger2 = RpcLoggerFactory.getLogger("xxx", "appname1"); Assert.assertNotNull(logger1); Assert.assertEquals(logger1, logger2); Logger logger3 = RpcLoggerFactory.getLogger("xxx", "appname2"); Assert.assertFalse(logger1.equals(logger3)); }
Example 12
Source File: RepairStepTest.java From dcos-cassandra-service with Apache License 2.0 | 5 votes |
@Test public void testInitial() { Mockito.when(cassandraState.get(REPAIR_NODE_0)).thenReturn(Optional.empty()); final RepairContext context = RepairContext.create(Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); final RepairStep step = new RepairStep(NODE_0, cassandraState, provider, context); Assert.assertEquals(REPAIR_NODE_0, step.getName()); Assert.assertEquals(NODE_0, step.getDaemon()); Assert.assertTrue(step.isPending()); }
Example 13
Source File: StringSearchTest.java From logstash-filter-dissect with Apache License 2.0 | 5 votes |
@Test public void testIndexOfOneByteSearch() throws Exception { final byte[] source = "aaa bbb ccc ddd".getBytes(); final Delimiter delimiter = Delimiter.create(" "); final int p = delimiter.indexOf(source, 0); Assert.assertEquals(3, p); }
Example 14
Source File: ELBDeregisterInstanceStepTest.java From pipeline-aws-plugin with Apache License 2.0 | 5 votes |
@Test public void gettersWorkAsExpected() throws Exception { ELBDeregisterInstanceStep step = new ELBDeregisterInstanceStep("my-target-group-arn", "my-instance-id", 8888); Assert.assertEquals("my-target-group-arn", step.getTargetGroupARN()); Assert.assertEquals("my-instance-id", step.getInstanceID()); Assert.assertEquals(8888, step.getPort()); }
Example 15
Source File: TestHeaderProcessor.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Test public void testSetValueDateFixed() throws Exception { Date date = new Date(1586957400199L); String strDate = "2020-04-15T13:30:00.199+0000"; createClientRequest(); HeaderProcessor processor = createProcessor("h1", Date.class); processor.setValue(clientRequest, date); Assert.assertEquals(strDate, headers.get("h1")); }
Example 16
Source File: filterByTests.java From spring-boot-rest-api-helpers with MIT License | 4 votes |
@Test @DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD) public void three_level_fetch_actors_of_movies_with_director_first_name_exact() { Director lana = new Director(); lana.setFirstName("Lana"); lana.setLastName("Wachowski"); directorRepository.save(lana); Director other = new Director(); other.setFirstName("other"); other.setLastName("Other"); directorRepository.save(other); Movie matrix = new Movie(); matrix.setName("The Matrix"); matrix.setDirector(lana); movieRepository.save(matrix); Movie constantine = new Movie(); constantine.setName("Constantine"); constantine.setDirector(other); movieRepository.save(constantine); Movie it = new Movie(); it.setName("IT"); it.setDirector(other); movieRepository.save(it); Actor keanu = new Actor(); keanu.setFirstName("Keanu"); keanu.setLastName("Reeves"); keanu.setMovies(Arrays.asList(matrix, constantine)); actorRepository.save(keanu); Actor otherActor = new Actor(); otherActor.setFirstName("other"); otherActor.setLastName("other"); actorRepository.save(otherActor); Iterable<Actor> actors = actorController.filterBy("{movies: {director: {firstName:Lana}}}", null, null); Assert.assertEquals(1, IterableUtil.sizeOf(actors)); }
Example 17
Source File: TestContainerStateManagerIntegration.java From hadoop-ozone with Apache License 2.0 | 4 votes |
@Test public void testUpdateContainerState() throws IOException { NavigableSet<ContainerID> containerList = containerStateManager .getMatchingContainerIDs(OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.OPEN); int containers = containerList == null ? 0 : containerList.size(); Assert.assertEquals(0, containers); // Allocate container1 and update its state from // OPEN -> CLOSING -> CLOSED -> DELETING -> DELETED ContainerWithPipeline container1 = scm.getClientProtocolServer() .allocateContainer( SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.OPEN).size(); Assert.assertEquals(1, containers); containerManager .updateContainerState(container1.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.FINALIZE); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.CLOSING).size(); Assert.assertEquals(1, containers); containerManager .updateContainerState(container1.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.CLOSE); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.CLOSED).size(); Assert.assertEquals(1, containers); containerManager .updateContainerState(container1.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.DELETE); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.DELETING).size(); Assert.assertEquals(1, containers); containerManager .updateContainerState(container1.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.CLEANUP); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.DELETED).size(); Assert.assertEquals(1, containers); // Allocate container1 and update its state from // OPEN -> CLOSING -> CLOSED ContainerWithPipeline container3 = scm.getClientProtocolServer() .allocateContainer( SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE); containerManager .updateContainerState(container3.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.FINALIZE); containerManager .updateContainerState(container3.getContainerInfo().containerID(), HddsProtos.LifeCycleEvent.CLOSE); containers = containerStateManager.getMatchingContainerIDs( OzoneConsts.OZONE, SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), HddsProtos.LifeCycleState.CLOSED).size(); Assert.assertEquals(1, containers); }
Example 18
Source File: NewDataflowProjectWizardDefaultRunOptionsPageTest.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
@Test public void testAccountEmail_none() { page.createControl(shellCreator.getShell()); Assert.assertEquals("", page.getAccountEmail()); }
Example 19
Source File: MathTest.java From Bytecoder with Apache License 2.0 | 4 votes |
@Test public void testSqrt() { Assert.assertEquals(3d, Math.sqrt(9d), 0); }
Example 20
Source File: ReappearingEventTest.java From hipparchus with Apache License 2.0 | 4 votes |
@Test public void testGragg() throws MathIllegalArgumentException, MathIllegalStateException { double tEnd = test(2); Assert.assertEquals(10.0, tEnd, 1e-7); }