public void testFirst(){ Second sec = mock(Second.class); when(sec.doSecond()).thenReturn("Stubbed Second"); First first = new First(); Field privateField = PrivateObject.class. getDeclaredField("second"); privateField.setAccessible(true); privateField.set(first, sec); assertEquals("Stubbed Second", first.doSecond()); }
@RunWith(MockitoJUnitRunner.class) public class YourTest { @Mock Second second; @InjectMocks First first = new First(); public void testFirst(){ when(second.doSecond()).thenReturn("Stubbed Second"); assertEquals("Stubbed Second", first.doSecond()); } }
var first = new First({ creator: req.decoded.id, object1: [{<object1_1>},{<object1_2>},{<object1_3>},{<object1_4>}], object2: req.body.object2 });
public class ExampleTest { @Test public void firstShouldCallSecond(@Mocked final Second secondMock) { new NonStrictExpectations() {{ secondMock.doJob(); result = "Mocked!!!"; }}; String actual = new First().doSecond(); assertEquals("Mocked!!!", actual); } }
FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); First first_act = new First(); fragmentTransaction.replace(R.id.fragment_container, first_act); fragmentTransaction.addToBackStack("first_act"); fragmentTransaction.commit();
@Stateless public class ManageSomethingBean implements ManageSomething { @PersistenceContext(unitName="firstDB") private EntityManager firstEM; @PersistenceContext(unitName="secondDB") private EntityManager secondEM; // some annotations public void storeSomething(Object value) { firstEM.persist(new First(value)); secondEM.persist(new Second(value)); } }
/** * Constructor FirstBy creates a new FirstBy instance. Use this constructor when used with a {@link AggregateBy} * instance. * * @param firstFields of type Fields */ @ConstructorProperties({"firstFields"}) public FirstBy( Fields firstFields ) { super( firstFields, new FirstPartials( firstFields ), new First( firstFields ) ); }
/** * Constructor FirstBy creates a new FirstBy instance. Use this constructor when used with a {@link AggregateBy} * instance. * * @param firstFields of type Fields */ @ConstructorProperties({"argumentFields", "firstFields"}) public FirstBy( Fields argumentFields, Fields firstFields ) { super( argumentFields, new FirstPartials( argumentFields ), new First( firstFields ) ); }
[HttpPost] public ActionResult Index(IndexViewModel model) { var firstModel = (new First()).CloneMatching(model); var lastModel = (new Last()).CloneMatching(model); return RedirectToAction("Thanks"); }
@Test public void testFirst(@Mocked final Second sec) { new NonStrictExpectations() {{ sec.doSecond(); result = "Stubbed Second"; }}; First first = new First(); assertEquals("Stubbed Second", first.doSecond()); }
public enum YourEnum { FIRST(new First()), SECOND(new Other()), private final Tile tile; private YourEnum(int code, Tile t) { this.code = code; this.tile = t; } public Tile getTile() { return tile; } }
@RunWith(PowerMockRunner.class) @PrepareForTest(First.class) public class TestFirst { @Test public void mockSecond() throws Exception{ Second mock = PowerMockito.mock(Second.class); PowerMockito.whenNew(Second.class).withNoArguments().thenReturn(mock); PowerMockito.when(mock.doSecond()).thenReturn("from mock"); First first = new First(); assertEquals("from mock", first.doSecond()); } }
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { First one = new First(); JFrame frame = new JFrame("Frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(one); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); }
First f = new First(); f.setSomeInt( 10 ); ... int x = f.getSomeInt();
public class Second { Stage primaryStage2; First a=new First(); public void open(){ primaryStage2=new Stage(); StackPane root = new StackPane(); Scene scene = new Scene(root, 300, 250); primaryStage2.setScene(scene); a.primaryStage3.close(); primaryStage2.show(); } }
... First first = new First(); entityManager.save(first); //<- the id is updated Second second = new Second(); second.setB(300); second.setA(first.getA()); first.setSeconds( new ArrayList()); first.getSeconds().add(second); entityManager.save(second); entityManager.getTransaction().commit();
@Test public void testFirst() { Aggregator aggregator = new First(); Tuple[] arguments = new Tuple[]{new Tuple( new Double( 1.0 ) ), new Tuple( new Double( 3.0 ) ), new Tuple( new Double( 2.0 ) ), new Tuple( new Double( 4.0 ) ), new Tuple( new Double( -5.0 ) )}; Fields resultFields = new Fields( "field" ); TupleListCollector resultEntryCollector = invokeAggregator( aggregator, arguments, resultFields ); Tuple tuple = resultEntryCollector.iterator().next(); assertEquals( "got expected value after aggregate", 1.0, tuple.getDouble( 0 ), 0.0d ); }
@Test public void testFirstN() { Aggregator aggregator = new First( 3 ); Tuple[] arguments = new Tuple[]{new Tuple( new Double( 1.0 ) ), new Tuple( new Double( 3.0 ) ), new Tuple( new Double( 2.0 ) ), new Tuple( new Double( 4.0 ) ), new Tuple( new Double( -5.0 ) )}; Fields resultFields = new Fields( "field" ); TupleListCollector resultEntryCollector = invokeAggregator( aggregator, arguments, resultFields ); Iterator<Tuple> iterator = resultEntryCollector.iterator(); assertEquals( "got expected value after aggregate", 1.0, iterator.next().getDouble( 0 ), 0.0d ); assertEquals( "got expected value after aggregate", 3.0, iterator.next().getDouble( 0 ), 0.0d ); assertEquals( "got expected value after aggregate", 2.0, iterator.next().getDouble( 0 ), 0.0d ); }
public FirstAssembly( Pipe previous ) { Pipe pipe = new Pipe( "first", previous ); pipe = new Each( pipe, new Identity() ); pipe = new GroupBy( pipe, Fields.ALL ); pipe = new Every( pipe, new First(), Fields.RESULTS ); setTails( pipe ); } }
public FirstAssembly( Pipe previous ) { Pipe pipe = new Pipe( "first", previous ); pipe = new Each( pipe, new Identity() ); pipe = new GroupBy( pipe, Fields.ALL ); pipe = new Every( pipe, new First(), Fields.RESULTS ); setTails( pipe ); } }