aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
blob: f76cfd13af1f48fe2bde664e5c97d26f16a7b007 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2;

import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class RequestTest {

    @Test
    public void testGetResultBeforeCompletion() {
        Request<String> r = new Request<String>(Request.MasterState.MUST_BE_MASTER) {
            @Override
            public String calculateResult(Context context) {
                return "foo";
            }
        };
        try{
            r.getResult();
            assertTrue(false);
        } catch (InternalFailure e) {
        } catch (Exception e) {
            assertTrue(false);
        }
        r.notifyCompleted();
        try{
            r.getResult();
            assertTrue(false);
        } catch (InternalFailure e) {
        } catch (Exception e) {
            assertTrue(false);
        }
    }

}