Skip to content

Commit

Permalink
Merge pull request pentaho#5268 from tmcsantos/dev
Browse files Browse the repository at this point in the history
[CLEANUP] - Trying to fix inconsistent test failure in CI
  • Loading branch information
Marc Batchelor authored Apr 17, 2018
2 parents 003d591 + 7a975c5 commit d3b48f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@


import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.junit.rules.RestorePDIEngineEnvironment;

import java.util.Collections;

Expand All @@ -33,6 +35,7 @@
import static org.hamcrest.core.IsEqual.equalTo;

public class MetaXmlSerializerTest {
@ClassRule public static RestorePDIEngineEnvironment env = new RestorePDIEngineEnvironment();

@Before public void before() throws KettleException {
KettleEnvironment.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,28 @@
package org.pentaho.di.core.util.serialization;

import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.junit.rules.RestorePDIEngineEnvironment;
import org.pentaho.di.repository.ObjectId;
import org.pentaho.di.repository.Repository;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.pentaho.di.core.util.serialization.MetaXmlSerializer.serialize;
import static org.pentaho.di.core.util.serialization.StepMetaProps.from;

@RunWith ( MockitoJUnitRunner.class )
public class RepoSerializerTest {
@ClassRule public static RestorePDIEngineEnvironment env = new RestorePDIEngineEnvironment();

@Mock private Repository repo;
@Mock private ObjectId transId, stepId;
Expand All @@ -52,22 +55,25 @@ public class RepoSerializerTest {

@Test
public void testSerialize() throws KettleException {
String serialized = serialize( from( stepMeta ) );

RepoSerializer
.builder()
.repo( repo )
.stepId( stepId )
.transId( transId )
.stepMeta( stepMeta )
.serialize();

verify( repo, times( 1 ) )
.saveStepAttribute( transId, stepId, "step-xml",
serialize( from( stepMeta ) ) );
.saveStepAttribute( transId, stepId, "step-xml", serialized );
}

@Test
public void testDeserialize() throws KettleException {
StepMetaPropsTest.FooMeta blankMeta = new StepMetaPropsTest.FooMeta();
when( repo.getStepAttributeString( stepId, "step-xml" ) ).thenReturn( serialize( from( stepMeta ) ) );
String serialized = serialize( from( stepMeta ) );
doReturn( serialized ).when( repo ).getStepAttributeString( stepId, "step-xml" );

RepoSerializer
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.google.common.base.Objects;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
Expand All @@ -31,6 +32,7 @@
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.variables.VariableSpace;
import org.pentaho.di.core.variables.Variables;
import org.pentaho.di.junit.rules.RestorePDIEngineEnvironment;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.StepDataInterface;
Expand All @@ -49,6 +51,7 @@
import static org.junit.Assert.assertThat;

public class StepMetaPropsTest {
@ClassRule public static RestorePDIEngineEnvironment env = new RestorePDIEngineEnvironment();


@InjectionSupported ( localizationPrefix = "stuff", groups = { "stuffGroup" } ) static class FooMeta
Expand Down

0 comments on commit d3b48f8

Please sign in to comment.