@Test public void findAnotherInfoFromCompare() { final SparseArray<IdentifiedTask> unStoredTasks = new SparseArray<>(); final SparseArray<BreakpointInfo> storedInfos = new SparseArray<>(); storeOnCache = new BreakpointStoreOnCache(storedInfos, new ArrayList<Integer>(), new HashMap<String, String>(), unStoredTasks, new ArrayList<Integer>(), keyToIdMap); final BreakpointInfo info1 = mock(BreakpointInfo.class); final BreakpointInfo info2 = mock(BreakpointInfo.class); final DownloadTask task = mock(DownloadTask.class); storedInfos.put(insertedId, info1); doReturn(true).when(info1).isSameFrom(task); doReturn(false).when(info2).isSameFrom(task); BreakpointInfo result = storeOnCache.findAnotherInfoFromCompare(task, info1); assertThat(result).isNull(); result = storeOnCache.findAnotherInfoFromCompare(task, info2); assertThat(result).isEqualToComparingFieldByField(info1); }
@Test public void toDataServiceRequest() { final ApiGatewayRequestContext context = new ApiGatewayRequestContext(); context.setAccountId(ACCOUNT_ID); final StartDeploymentRequest result = mapper.toDataServiceRequest(context, CLUSTER, ENVIRONMENT_NAME, ENVIRONMENT_REVISION_ID); assertThat(result.getEnvironmentRevisionId()).isEqualTo(ENVIRONMENT_REVISION_ID); assertThat(result.getEnvironmentId()).isEqualToComparingFieldByField(environmentId); }
@Test public void copyFromNonNull() throws Exception { GifOptions source = new GifOptions(); source.setInIsOpaque(false); source.setInSampleSize(8); gifOptions.setFrom(source); assertThat(gifOptions).isEqualToComparingFieldByField(source); }
@Test public void copyFromNull() throws Exception { GifOptions defaultOptions = new GifOptions(); gifOptions.setInIsOpaque(false); gifOptions.setInSampleSize(8); gifOptions.setFrom(null); assertThat(gifOptions).isEqualToComparingFieldByField(defaultOptions); } }
@Test public void testVersionNumbers() throws Exception { final SerializationTestUtils.TestObject testObject = new SerializationTestUtils.TestObject("t1", 1); final byte[] bytes = new ByteBufferSerializerOutput() .writeObject(mContext, testObject, SerializationTestUtils.TestObject.V1_SERIALIZER) .writeObject(mContext, testObject, SerializationTestUtils.TestObject.SERIALIZER) .getSerializedData(); final ByteBufferSerializerInput input = new ByteBufferSerializerInput(bytes); assertThat( (Object) SerializationTestUtils.TestObject.V1_SERIALIZER.deserialize(mContext, input)) .isEqualToComparingFieldByField(new SerializationTestUtils.TestObject("t1", 2)); assertThat( (Object) SerializationTestUtils.TestObject.V1_SERIALIZER.deserialize(mContext, input)) .isEqualToComparingFieldByField(testObject); }
@Test public void testVersionNumbers() throws Exception { final Serializer<SerializableObject> v1Serializer = new SerializableObject.SerializableObjectSerializer(1); final SerializableObject object = new SerializableObject.Builder().setNumber(2).setString("e").buildObject(); final byte[] bytes = new ByteBufferSerializerOutput() .writeObjectStart(1) .writeLong(object.number) .writeString(object.string) .writeObjectEnd() .getSerializedData(); final SerializerInput input = new ByteBufferSerializerInput(bytes); final SerializationContext context = SerializationContext.ALWAYS_RELEASE; final SerializableObject deserializedObject = input.readObject(context, v1Serializer); assertThat(deserializedObject).isEqualToComparingFieldByField(object); }
@Test public void deserializeUnwrappedList () throws Exception { // given Root rootObject = givenRootObject(); // when Root rootResult = xmlMapper.readValue(rootXml, Root.class); // then assertThat(rootResult.name).isEqualTo(rootObject.name); assertThat(rootResult.unwrapped).hasSize(2); assertThat(rootResult.unwrapped.get(0)).isEqualToComparingFieldByField(rootObject.unwrapped.get(0)); } }
@Test public void loadsFromXml() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><compiledFiles compilationTime=\"2\">\n" + " <file>file</file>\n" + "</compiledFiles>\n"; // Setup a new eventReader XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(xml)); CompiledFiles uut = CompiledFiles.readThrowExceptions(eventReader); final CompiledFiles expected = new CompiledFiles(2, Collections.singleton("file")); assertThat(uut).isEqualToComparingFieldByField(expected); }
@Test public void createsFromCollection() throws Exception { final CompiledFiles compiledFiles = new CompiledFiles((long) 2); compiledFiles.addAll(Collections.singleton(new File("file"))); CompiledFiles uut = compiledFiles; final CompiledFiles expected = new CompiledFiles(2, Collections.singleton(new File("file").getAbsolutePath())); assertThat(uut).isEqualToComparingFieldByField(expected); } }
@Test public void datasourceClicked() { Object[] pathObjects = new Object[]{ root, datasource}; TreePath path = new TreePath(pathObjects); assertThat(sut.getContextMenu(path).get()) .isEqualToComparingFieldByField(new DataSourceContextMenu(dataSourceApi)); }
@Test public void propertyClicked() { TreePath path = new TreePath(getTreePath(Neo4jTreeNodeType.PROPERTY_KEYS, Neo4jTreeNodeType.PROPERTY_KEY)); assertThat(sut.getContextMenu(path).get()) .isEqualToComparingFieldByField(new MetadataContextMenu(Neo4jTreeNodeType.PROPERTY_KEY, dataSourceApi, PROPERTY)); }
@Test public void personLabelClicked() { TreePath path = new TreePath(getTreePath(Neo4jTreeNodeType.LABELS, Neo4jTreeNodeType.LABEL)); assertThat(sut.getContextMenu(path).get()) .isEqualToComparingFieldByField(new MetadataContextMenu(Neo4jTreeNodeType.LABEL, dataSourceApi, LABEL)); }
@Test public void relationshipClicked() { TreePath path = new TreePath(getTreePath(Neo4jTreeNodeType.RELATIONSHIPS, Neo4jTreeNodeType.RELATIONSHIP)); assertThat(sut.getContextMenu(path).get()) .isEqualToComparingFieldByField(new MetadataContextMenu(Neo4jTreeNodeType.RELATIONSHIP, dataSourceApi, REL)); }
public <T> ResultMatcher containsObjectAsJson(Object expectedObject, Class<T> targetClass) { return mvcResult -> { String json = mvcResult.getResponse().getContentAsString(); T actualObject = objectMapper.readValue(json, targetClass); assertThat(expectedObject).isEqualToComparingFieldByField(actualObject); }; }
@Test void Should_Return_Expected_Constructor_Assertion() throws NoSuchMethodException { // given final TestAssertions testAssertions = new TestAssertions(); final Constructor<Pojo> declaredConstructor = Pojo.class.getDeclaredConstructor(); final ConstructorAssertions expectedResult = new ConstructorAssertions(declaredConstructor); // when final ConstructorAssertions result = testAssertions.assertThatConstructor(declaredConstructor); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
@Test void Should_Return_Expected_Getter_Assertion() { // given final TestAssertions testAssertions = new TestAssertions(); final String objectUnderTest = "objectUnderTest"; final GetterAssertions expectedResult = new GetterAssertions(objectUnderTest); // when final GetterAssertions result = testAssertions.assertThatGetMethodFor(objectUnderTest); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
@Test void Should_Return_Expected_Setter_Assertion() { // given final TestAssertions testAssertions = new TestAssertions(); final String objectUnderTest = "objectUnderTest"; final SetterAssertions expectedResult = new SetterAssertions(objectUnderTest); // when final SetterAssertions result = testAssertions.assertThatSetMethodFor(objectUnderTest); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
@Test void Should_Return_Expected_Equal_Assertion() { // given final TestAssertions testAssertions = new TestAssertions(); final String objectUnderTest = "objectUnderTest"; final EqualAssertions expectedResult = new EqualAssertions(objectUnderTest); // when final EqualAssertions result = testAssertions.assertThatEqualsMethodFor(objectUnderTest); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
@Test void Should_Return_Expected_ToString_Assertion() { // given final TestAssertions testAssertions = new TestAssertions(); final String objectUnderTest = "objectUnderTest"; final ToStringAssertions expectedResult = new ToStringAssertions(objectUnderTest); // when final ToStringAssertions result = testAssertions.assertThatToStringMethodFor(objectUnderTest); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }
@Test void Should_Return_Expected_HashCode_Assertion() { // given final TestAssertions testAssertions = new TestAssertions(); final String objectUnderTest = "objectUnderTest"; final HashCodeAssertions expectedResult = new HashCodeAssertions(objectUnderTest); // when final HashCodeAssertions result = testAssertions.assertThatHashCodeMethodFor(objectUnderTest); // then assertThat(result).isEqualToComparingFieldByField(expectedResult); }